<?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=Agohil</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=Agohil"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Agohil"/>
	<updated>2026-09-14T22:59:20Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1586_AnonymousChatBetweenAuthorAndReviewer&amp;diff=99649</id>
		<title>CSC/ECE 517 Fall 2015 E1586 AnonymousChatBetweenAuthorAndReviewer</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1586_AnonymousChatBetweenAuthorAndReviewer&amp;diff=99649"/>
		<updated>2015-11-13T21:46:36Z</updated>

		<summary type="html">&lt;p&gt;Agohil: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1586 AnonymousChatBetweenAuthorAndReviewer'''&lt;br /&gt;
&lt;br /&gt;
This page provides a brief description of the '''Expertiza''' project. The project is aimed at developing an email based anonymous session between author and a reviewer so that reviewers can ask questions to the authors for any doubts related to the assignments during peer reviewing.&lt;br /&gt;
&lt;br /&gt;
==Project==&lt;br /&gt;
&lt;br /&gt;
=== Introduction to Expertiza ===&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a peer review based system which provides an incremental class based learning together with the instructors and the peers. This project has been developed together by faculty and students using [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza handles assignment submissions, team formations, assignment reviews and grades, etc.&lt;br /&gt;
&lt;br /&gt;
=== Purpose ===&lt;br /&gt;
During reviews, many times reviewers will be having questions about the submitted material and if it's a blocker there is no way that the reviewer can progress further with the review.  As a result, reviewers will end up submitting the empty or incomplete review.&lt;br /&gt;
&lt;br /&gt;
=== Scope ===&lt;br /&gt;
This project is limited to an email based conversation for asking questions and answers. The reviewers would ask questions related to assignment submission doubts to which authors can respond. All this would be taken care as email responses using a link provided in the email. This project does not cater to any live interactive session with spontaneous back-to-back questions and responses.&lt;br /&gt;
&lt;br /&gt;
Following tasks would be incorporated in the project:&lt;br /&gt;
* Provide a ‘TextArea’ input field on review forms, where any reviewer can type in their questions.&lt;br /&gt;
* Create a new button ‘Ask for Quick Help’ on the review forms.&lt;br /&gt;
* An email would be send to the author with the link where he can respond to the questions asked by the reviewers for their submitted work.&lt;br /&gt;
* Reviewers would be notified by an email when authors respond to the the questions.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Discussion of Resolution ===&lt;br /&gt;
&lt;br /&gt;
We will make the following modifications to implement the chat feature:- &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Create a new model which will help extract,store and validate data in the database table which contains information about the interaction between the author/s and reviewer.&lt;br /&gt;
&lt;br /&gt;
*Edit the view which is used by the response controller to incorporate the text area input field on the review form where the reviewer can ask his/her initial query.&lt;br /&gt;
&lt;br /&gt;
*Create a new controller which will contain methods to send emails to the author and reviewers as well as retrieve and display the chat history between the two.&lt;br /&gt;
&lt;br /&gt;
*Create a new view which will facilitate the author to respond to the queries asked by the reviewer. The reviewer can also use this view to ask any follow up questions.&lt;br /&gt;
&lt;br /&gt;
=== Mock-Ups ===&lt;br /&gt;
The sample question box would look like:&lt;br /&gt;
&lt;br /&gt;
[[File: ARSNMockup1.JPG]]&lt;br /&gt;
&lt;br /&gt;
An interface with the question would be displayed on opening a link from the email.&lt;br /&gt;
The authors can reply the query which reviewers ask.&lt;br /&gt;
&lt;br /&gt;
[[File: ARSNMockup2.JPG]]&lt;br /&gt;
&lt;br /&gt;
=== Design Patterns ===&lt;br /&gt;
The implementation team expects that the following design patterns be used in the solution:&lt;br /&gt;
 &lt;br /&gt;
* '''Observer Pattern'''&amp;lt;ref&amp;gt;Observer Design Pattern https://en.wikipedia.org/wiki/Observer_pattern&amp;lt;/ref&amp;gt;: The observer pattern is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods. For example, we are notifying the team members whenever the reviewer submits the query.&lt;br /&gt;
&lt;br /&gt;
* '''Iterator Pattern''': In our instance, we need to display the entire chat history of a particular interaction, hence we can use the iterator design pattern to iterate through the previous chat messages.&lt;br /&gt;
&lt;br /&gt;
=== Database Design ===&lt;br /&gt;
&lt;br /&gt;
[[File:DatabaseTable.jpg]]&lt;br /&gt;
&lt;br /&gt;
The above figure shows the schema of a new table which will be created in Expertiza to store relevant information about the chat. It contains the following attributes:&lt;br /&gt;
* id: This attribute is auto-generated by rails when we create a table and is auto incremented with each record. It is also the primary key of our table.&lt;br /&gt;
* assignment_id: Stores the ID of the assignment for which the interaction between author and reviewer is taking place.&lt;br /&gt;
* reviewer_id: Stores the ID of the reviewer who asks the questions.&lt;br /&gt;
* team_id: Stores the ID of the team to which the topic belongs.&lt;br /&gt;
* type_flag: Flag which is used to indicate if the particular tuple contains a question or answer. It can take two values, 'Q' for question and 'A' for answer.&lt;br /&gt;
* content: Stores the question asked by the reviewer or the response given by the author/s depending on the value of the type flag.&lt;br /&gt;
&lt;br /&gt;
Records for a particular interaction can be identified by using a combination of assignment_id, reviewer_id and team_id.&lt;br /&gt;
&lt;br /&gt;
=== Use Cases ===&lt;br /&gt;
'''Name:''' Send a question to the author/s about their work.&amp;lt;br&amp;gt;&lt;br /&gt;
'''Actor:''' Reviewer. &amp;lt;br&amp;gt;&lt;br /&gt;
'''Description:''' The reviewer enters his question in the text area which is provided and clicks on the &amp;quot;Ask question&amp;quot; button which is provided as shown in the mock up. On clicking this button an email is sent to the author/s along which a link to answer the question.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Name:''' Answer the question which has been asked by the reviewer.&amp;lt;br&amp;gt;&lt;br /&gt;
'''Actor:''' Author/s&amp;lt;br&amp;gt;&lt;br /&gt;
'''Description:''' The author/s click on the link received in their email and are redirected to a page where they can answer the question. Once they submit the answer, an email is sent to the reviewer notifying him/her that their question has been answered.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:ARSNUsecase.jpeg]]&lt;br /&gt;
&lt;br /&gt;
=== Proposed Tests ===&lt;br /&gt;
1. For use case 1, test whether all the team members receive email with the question.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. For use case 2, test whether the reviewer receive email with the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
3. Test whether all the previous interactions are displayed as chat history.&amp;lt;br/&amp;gt;&lt;br /&gt;
4. The 'Ask Question' button should not be enabled until some text has been entered in the text area.&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
'''Files created/modified'''&lt;br /&gt;
&lt;br /&gt;
*Create a new model '''ReviewChat''' .&lt;br /&gt;
&lt;br /&gt;
*Create a new controller '''ReviewChats'''.&lt;br /&gt;
&lt;br /&gt;
*Create new views as discussed in the design.&lt;br /&gt;
&lt;br /&gt;
*Modify view expertiza/app/views/response/response.html.erb to incorporate text box and corresponding submit button.&lt;br /&gt;
&lt;br /&gt;
'''Flowchart'''&lt;br /&gt;
&lt;br /&gt;
[[File: ARSNFlowchart1.png]]&lt;br /&gt;
&lt;br /&gt;
'''Flow'''&lt;br /&gt;
&lt;br /&gt;
*The reviewer enters his question in the text area provided and clicks on the &amp;quot;Ask Question&amp;quot; button.&lt;br /&gt;
*On clicking this button the appropriate method is called in ReviewChats controller which sends an email to all the authors of the topic indicating that a question has been asked about their work. The email contains a link which when clicked on will redirect the author to the appropriate view where he/she can answer the question.&lt;br /&gt;
*On answering the question, the reviewer receives an email indicating that his question has been answered. It also contains a link which redirects the reviewer to the appropriate view where the answer will be displayed.&lt;br /&gt;
*This view also contains the chat history between the author/s and the reviewer for the entire duration of the interaction.&lt;br /&gt;
&lt;br /&gt;
== Suggestions for Future Improvements ==&lt;br /&gt;
&lt;br /&gt;
* This can be extended to a live interactive author-reviewer anonymous chat session inside the Expertiza reviews window.&lt;br /&gt;
* A purging script can be developed which will clear all the interaction records every semester.&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
&lt;br /&gt;
* Expertiza Github repository&amp;lt;ref&amp;gt;Expertiza Github repository https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Agohil</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1586_AnonymousChatBetweenAuthorAndReviewer&amp;diff=99368</id>
		<title>CSC/ECE 517 Fall 2015 E1586 AnonymousChatBetweenAuthorAndReviewer</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1586_AnonymousChatBetweenAuthorAndReviewer&amp;diff=99368"/>
		<updated>2015-11-10T04:50:17Z</updated>

		<summary type="html">&lt;p&gt;Agohil: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1586 AnonymousChatBetweenAuthorAndReviewer'''&lt;br /&gt;
&lt;br /&gt;
This page provides a brief description of the '''Expertiza''' project. The project is aimed at developing an email based anonymous session between author and a reviewer so that reviewers can ask questions to the authors for any doubts related to the assignments during peer reviewing.&lt;br /&gt;
&lt;br /&gt;
==Project==&lt;br /&gt;
&lt;br /&gt;
=== Introduction to Expertiza ===&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a peer review based system which provides an incremental class based learning together with the instructors and the peers. This project has been developed together by faculty and students using [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza handles assignment submissions, team formations, assignment reviews and grades, etc.&lt;br /&gt;
&lt;br /&gt;
=== Purpose ===&lt;br /&gt;
During reviews, many times reviewers will be having questions about the submitted material and if it's a blocker there is no way that the reviewer can progress further with the review.  As a result, reviewers will end up submitting the empty or incomplete review.&lt;br /&gt;
&lt;br /&gt;
=== Scope ===&lt;br /&gt;
This project is limited to an email based conversation for asking questions and answers. The reviewers would ask questions related to assignment submission doubts to which authors can respond. All this would be taken care as email responses using a link provided in the email. This project does not cater to any live interactive session with spontaneous back-to-back questions and responses.&lt;br /&gt;
&lt;br /&gt;
Following tasks would be incorporated in the project:&lt;br /&gt;
* Provide a ‘TextArea’ input field on review forms, where any reviewer can type in their questions.&lt;br /&gt;
* Create a new button ‘Ask for Quick Help’ on the review forms.&lt;br /&gt;
* An email would be send to the author with the link where he can respond to the questions asked by the reviewers for their submitted work.&lt;br /&gt;
* Reviewers would be notified by an email when authors respond to the the questions.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Discussion of Resolution ===&lt;br /&gt;
&lt;br /&gt;
We will make the following modifications to implement the chat feature:- &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Create a new model which will help extract,store and validate data in the database table which contains information about the interaction between the author/s and reviewer.&lt;br /&gt;
&lt;br /&gt;
*Edit the view which is used by the response controller to incorporate the text area input field on the review form where the reviewer can ask his/her initial query.&lt;br /&gt;
&lt;br /&gt;
*Create a new controller which will contain methods to send emails to the author and reviewers as well as retrieve and display the chat history between the two.&lt;br /&gt;
&lt;br /&gt;
*Create a new view which will facilitate the author to respond to the queries asked by the reviewer. The reviewer can also use this view to ask any follow up questions.&lt;br /&gt;
&lt;br /&gt;
=== Mock-Ups ===&lt;br /&gt;
The sample question box would look like:&lt;br /&gt;
&lt;br /&gt;
[[File: ARSNMockup1.JPG]]&lt;br /&gt;
&lt;br /&gt;
An interface with the question would be displayed on opening a link from the email.&lt;br /&gt;
The authors can reply the query which reviewers ask.&lt;br /&gt;
&lt;br /&gt;
[[File: ARSNMockup2.JPG]]&lt;br /&gt;
&lt;br /&gt;
=== Database Design ===&lt;br /&gt;
&lt;br /&gt;
[[File:DatabaseTable.jpg]]&lt;br /&gt;
&lt;br /&gt;
The above figure shows the schema of a new table which will be created in Expertiza to store relevant information about the chat. It contains the following attributes:&lt;br /&gt;
* id: This attribute is auto-generated by rails when we create a table and is auto incremented with each record. It is also the primary key of our table.&lt;br /&gt;
* assignment_id: Stores the ID of the assignment for which the interaction between author and reviewer is taking place.&lt;br /&gt;
* reviewer_id: Stores the ID of the reviewer who asks the questions.&lt;br /&gt;
* team_id: Stores the ID of the team to which the topic belongs.&lt;br /&gt;
* type_flag: Flag which is used to indicate if the particular tuple contains a question or answer. It can take two values, 'Q' for question and 'A' for answer.&lt;br /&gt;
* content: Stores the question asked by the reviewer or the response given by the author/s depending on the value of the type flag.&lt;br /&gt;
&lt;br /&gt;
Records for a particular interaction can be identified by using a combination of assignment_id, reviewer_id and team_id.&lt;br /&gt;
&lt;br /&gt;
=== Use Cases ===&lt;br /&gt;
'''Name:''' Send a question to the author/s about their work.&amp;lt;br&amp;gt;&lt;br /&gt;
'''Actor:''' Reviewer. &amp;lt;br&amp;gt;&lt;br /&gt;
'''Description:''' The reviewer enters his question in the text area which is provided and clicks on the &amp;quot;Ask question&amp;quot; button which is provided as shown in the mock up. On clicking this button an email is sent to the author/s along which a link to answer the question.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Name:''' Answer the question which has been asked by the reviewer.&amp;lt;br&amp;gt;&lt;br /&gt;
'''Actor:''' Author/s&amp;lt;br&amp;gt;&lt;br /&gt;
'''Description:''' The author/s click on the link received in their email and are redirected to a page where they can answer the question. Once they submit the answer, an email is sent to the reviewer notifying him/her that their question has been answered.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Proposed Tests ===&lt;br /&gt;
1. For use case 1, test whether all the team members receive email with the question.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. For use case 2, test whether the reviewer receive email with the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
3. Test whether all the previous interactions are displayed as chat history.&amp;lt;br/&amp;gt;&lt;br /&gt;
4. The 'Ask Question' button should not be enabled until some text has been entered in the text area.&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
'''Files created/modified:-'''&lt;br /&gt;
&lt;br /&gt;
*Create a new model chat_feedback.rb &lt;br /&gt;
&lt;br /&gt;
*Create a new controller review_interactions_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Create new views as discussed in the design.&lt;br /&gt;
&lt;br /&gt;
*Modify view expertiza/app/views/response/response.html.erb to incorporate text box and corresponding submit button.&lt;br /&gt;
&lt;br /&gt;
'''Flow:-'''&lt;br /&gt;
&lt;br /&gt;
*The reviewer enters his question in the text area provided and clicks on the &amp;quot;Ask Question&amp;quot; button.&lt;br /&gt;
*On clicking this button the appropriate method is called in review_interactions_controller.rb which sends an email to all the authors of the topic indicating that a question has been asked about their work. The email contains a link which when clicked on will redirect the author to the appropriate view where he/she can answer the question.&lt;br /&gt;
*On answering the question, the reviewer receives an email indicating that his question has been answered. It also contains a link which redirects the reviewer to the appropriate view where the answer will be displayed.&lt;br /&gt;
*This view also contains the chat history between the author/s and the reviewer for the entire duration of the interaction.&lt;br /&gt;
&lt;br /&gt;
== Suggestions for Future Improvements ==&lt;br /&gt;
&lt;br /&gt;
* This can be extended to a live interactive author-reviewer anonymous chat session inside the Expertiza reviews window.&lt;br /&gt;
* A purging script can be developed which will clear all the interaction records every semester.&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
&lt;br /&gt;
* Expertiza Github repository&amp;lt;ref&amp;gt;Expertiza Github repository https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Agohil</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1586_AnonymousChatBetweenAuthorAndReviewer&amp;diff=99366</id>
		<title>CSC/ECE 517 Fall 2015 E1586 AnonymousChatBetweenAuthorAndReviewer</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1586_AnonymousChatBetweenAuthorAndReviewer&amp;diff=99366"/>
		<updated>2015-11-10T04:40:54Z</updated>

		<summary type="html">&lt;p&gt;Agohil: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1586 AnonymousChatBetweenAuthorAndReviewer'''&lt;br /&gt;
&lt;br /&gt;
This page provides a brief description of the '''Expertiza''' project. The project is aimed at developing an email based anonymous session between author and a reviewer so that reviewers can ask questions to the authors for any doubts related to the assignments during peer reviewing.&lt;br /&gt;
&lt;br /&gt;
==Project==&lt;br /&gt;
&lt;br /&gt;
=== Introduction to Expertiza ===&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a peer review based system which provides an incremental class based learning together with the instructors and the peers. This project has been developed together by faculty and students using [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza handles assignment submissions, team formations, assignment reviews and grades, etc.&lt;br /&gt;
&lt;br /&gt;
=== Purpose ===&lt;br /&gt;
During reviews, many times reviewers will be having questions about the submitted material and if it's a blocker there is no way that the reviewer can progress further with the review.  As a result, reviewers will end up submitting the empty or incomplete review.&lt;br /&gt;
&lt;br /&gt;
=== Scope ===&lt;br /&gt;
This project is limited to an email based conversation for asking questions and answers. The reviewers would ask questions related to assignment submission doubts to which authors can respond. All this would be taken care as email responses using a link provided in the email. This project does not cater to any live interactive session with spontaneous back-to-back questions and responses.&lt;br /&gt;
&lt;br /&gt;
Following tasks would be incorporated in the project:&lt;br /&gt;
* Provide a ‘TextArea’ input field on review forms, where any reviewer can type in their questions.&lt;br /&gt;
* Create a new button ‘Ask for Quick Help’ on the review forms.&lt;br /&gt;
* An email would be send to the author with the link where he can respond to the questions asked by the reviewers for their submitted work.&lt;br /&gt;
* Reviewers would be notified by an email when authors respond to the the questions.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Discussion of Resolution ===&lt;br /&gt;
&lt;br /&gt;
We will make the following modifications to implement the chat feature:- &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Create a new model which will help extract,store and validate data in the database table which contains information about the interaction between the author/s and reviewer.&lt;br /&gt;
&lt;br /&gt;
*Edit the view which is used by the response controller to incorporate the text area input field on the review form where the reviewer can ask his/her initial query.&lt;br /&gt;
&lt;br /&gt;
*Create a new controller which will contain methods to send emails to the author and reviewers as well as retrieve and display the chat history between the two.&lt;br /&gt;
&lt;br /&gt;
*Create a new view which will facilitate the author to respond to the queries asked by the reviewer. The reviewer can also use this view to ask any follow up questions.&lt;br /&gt;
&lt;br /&gt;
=== Mock-Ups ===&lt;br /&gt;
The sample question box would look like:&lt;br /&gt;
&lt;br /&gt;
[[File: ARSNMockup1.JPG]]&lt;br /&gt;
&lt;br /&gt;
An interface with the question would be displayed on opening a link from the email.&lt;br /&gt;
The authors can reply the query which reviewers ask.&lt;br /&gt;
&lt;br /&gt;
[[File: ARSNMockup2.JPG]]&lt;br /&gt;
&lt;br /&gt;
=== Database Design ===&lt;br /&gt;
&lt;br /&gt;
[[File:DatabaseTable.jpg]]&lt;br /&gt;
&lt;br /&gt;
The above figure shows the schema of a new table which will be created in Expertiza to store relevant information about the chat. It contains the following attributes:&lt;br /&gt;
* id: This attribute is auto-generated by rails when we create a table and is auto incremented with each record. It is also the primary key of our table.&lt;br /&gt;
* assignment_id: Stores the ID of the assignment for which the interaction between author and reviewer is taking place.&lt;br /&gt;
* reviewer_id: Stores the ID of the reviewer who asks the questions.&lt;br /&gt;
* team_id: Stores the ID of the team to which the topic belongs.&lt;br /&gt;
* type_flag: Flag which is used to indicate if the particular tuple contains a question or answer. It can take two values, 'Q' for question and 'A' for answer.&lt;br /&gt;
* content: Stores the question asked by the reviewer or the response given by the author/s depending on the value of the type flag.&lt;br /&gt;
&lt;br /&gt;
Records for a particular interaction can be identified by using a combination of assignment_id, reviewer_id and team_id.&lt;br /&gt;
&lt;br /&gt;
=== Use Cases ===&lt;br /&gt;
'''Name:''' Send a question to the author/s about their work.&amp;lt;br&amp;gt;&lt;br /&gt;
'''Actor:''' Reviewer. &amp;lt;br&amp;gt;&lt;br /&gt;
'''Description:''' The reviewer enters his question in the text area which is provided and clicks on the &amp;quot;Ask question&amp;quot; button which is provided as shown in the mock up. On clicking this button an email is sent to the author/s along which a link to answer the question.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Name:''' Answer the question which has been asked by the reviewer.&amp;lt;br&amp;gt;&lt;br /&gt;
'''Actor:''' Author/s&amp;lt;br&amp;gt;&lt;br /&gt;
'''Description:''' The author/s click on the link received in their email and are redirected to a page where they can answer the question. Once they submit the answer, an email is sent to the reviewer notifying him/her that their question has been answered.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Proposed Tests ===&lt;br /&gt;
1. Test whether all the team members receive email with the question.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Test whether previous interactions are displayed as chat history.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
'''Files created/modified:-'''&lt;br /&gt;
&lt;br /&gt;
*Create a new model chat_feedback.rb &lt;br /&gt;
&lt;br /&gt;
*Create a new controller review_interactions_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Create new views as discussed in the design.&lt;br /&gt;
&lt;br /&gt;
*Modify view expertiza/app/views/response/response.html.erb to incorporate text box and corresponding submit button.&lt;br /&gt;
&lt;br /&gt;
'''Flow:-'''&lt;br /&gt;
&lt;br /&gt;
*The reviewer enters his question in the text area provided and clicks on the &amp;quot;Ask Question&amp;quot; button.&lt;br /&gt;
*On clicking this button the appropriate method is called in review_interactions_controller.rb which sends an email to all the authors of the topic indicating that a question has been asked about their work. The email contains a link which when clicked on will redirect the author to the appropriate view where he/she can answer the question.&lt;br /&gt;
*On answering the question, the reviewer receives an email indicating that his question has been answered. It also contains a link which redirects the reviewer to the appropriate view where the answer will be displayed.&lt;br /&gt;
*This view also contains the chat history between the author/s and the reviewer for the entire duration of the interaction.&lt;br /&gt;
&lt;br /&gt;
== Suggestions for Future Improvements ==&lt;br /&gt;
&lt;br /&gt;
* This can be extended to a live interactive author-reviewer anonymous chat session inside the Expertiza reviews window.&lt;br /&gt;
* A purging script can be developed which will clear all the interaction records every semester.&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
&lt;br /&gt;
* Expertiza Github repository&amp;lt;ref&amp;gt;Expertiza Github repository https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Agohil</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1566_ARB&amp;diff=99189</id>
		<title>CSC/ECE 517 Fall 2015/oss E1566 ARB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1566_ARB&amp;diff=99189"/>
		<updated>2015-11-09T22:35:03Z</updated>

		<summary type="html">&lt;p&gt;Agohil: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;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;
== 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>Agohil</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1566_ARB&amp;diff=99188</id>
		<title>CSC/ECE 517 Fall 2015/oss E1566 ARB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1566_ARB&amp;diff=99188"/>
		<updated>2015-11-09T22:24:32Z</updated>

		<summary type="html">&lt;p&gt;Agohil: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;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(WI)&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;
*WI1 : 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;
&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;
&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;
&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;
&lt;br /&gt;
[[File:Change1_new.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*WI2: 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;
== Testing Details==&lt;br /&gt;
&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. As the model has not been 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>Agohil</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1566_ARB&amp;diff=98717</id>
		<title>CSC/ECE 517 Fall 2015/oss E1566 ARB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1566_ARB&amp;diff=98717"/>
		<updated>2015-11-07T04:36:32Z</updated>

		<summary type="html">&lt;p&gt;Agohil: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;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&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.&lt;br /&gt;
&lt;br /&gt;
== Solutions Implemented and Delivered ==&lt;br /&gt;
&lt;br /&gt;
*WI1 : 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;
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;
This was split into the following three methods:&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;
Changes were also made to make the code follow ruby style. Finally some redundant code was commented out as it was non-functional.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Refactoring into smaller more specific methods:&lt;br /&gt;
&lt;br /&gt;
Before :&lt;br /&gt;
    def calculate_all_penalties(assignment_id)&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .                 &lt;br /&gt;
        if calculate_for_participants == true&lt;br /&gt;
          penalty_attr1 = {:deadline_type_id =&amp;gt; 1,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:submission]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr1)&lt;br /&gt;
          penalty_attr2 = {:deadline_type_id =&amp;gt; 2,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr2)&lt;br /&gt;
          penalty_attr3 = {:deadline_type_id =&amp;gt; 5,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:meta_review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr3)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      @all_penalties[participant.id] = {}&lt;br /&gt;
      @all_penalties[participant.id][:submission] = penalties[:submission]&lt;br /&gt;
      @all_penalties[participant.id][:review] = penalties[:review]&lt;br /&gt;
      @all_penalties[participant.id][:meta_review] = penalties[:meta_review]&lt;br /&gt;
      @all_penalties[participant.id][:total_penalty] = @total_penalty&lt;br /&gt;
    end&lt;br /&gt;
    unless @assignment.is_penalty_calculated&lt;br /&gt;
      @assignment.update_attribute(:is_penalty_calculated, true)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
    def calculate_all_penalties(assignment_id)&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .               &lt;br /&gt;
    if calculate_for_participants	&lt;br /&gt;
      calculate_penatly_attributes(@participant) #Refactored#Removed&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      assign_all_penalties(@participant)&lt;br /&gt;
    end&lt;br /&gt;
    unless @assignment.is_penalty_calculated      #Refactored#Removed&lt;br /&gt;
      @assignment.update_attribute(:is_penalty_calculated, true)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
New methods:&lt;br /&gt;
      def calculate_penatly_attributes(participant)&lt;br /&gt;
          penalty_attr1 = {:deadline_type_id =&amp;gt; 1,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:submission]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr1)&lt;br /&gt;
          penalty_attr2 = {:deadline_type_id =&amp;gt; 2,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr2)&lt;br /&gt;
          penalty_attr3 = {:deadline_type_id =&amp;gt; 5,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:meta_review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr3)&lt;br /&gt;
      end   &lt;br /&gt;
 &lt;br /&gt;
     def assign_all_penalties(participant)&lt;br /&gt;
      @all_penalties[participant.id] = {}&lt;br /&gt;
      @all_penalties[participant.id][:submission] = penalties[:submission]&lt;br /&gt;
      @all_penalties[participant.id][:review] = penalties[:review]&lt;br /&gt;
      @all_penalties[participant.id][:meta_review] = penalties[:meta_review]&lt;br /&gt;
      @all_penalties[participant.id][:total_penalty] = @total_penalty&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Removal of non-functional code :&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
                                       &lt;br /&gt;
      if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
        unless penalties[:submission]&lt;br /&gt;
          penalties[:submission] = 0&lt;br /&gt;
        end&lt;br /&gt;
        unless penalties[:review]&lt;br /&gt;
          penalties[:review] = 0&lt;br /&gt;
        end&lt;br /&gt;
        unless penalties[:meta_review]&lt;br /&gt;
          penalties[:meta_review] = 0&lt;br /&gt;
        end&lt;br /&gt;
        @total_penalty = (penalties[:submission] + penalties[:review] + penalties[:meta_review])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
     if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
         @total_penalty = (penalties[:submission] + penalties[:review] + penalties[:meta_review])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change of language to make it more Ruby friendly:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
   if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
    unless(penalties[:submission].zero? || penalties[:review].zero? || penalties[:meta_review].zero? )&lt;br /&gt;
&lt;br /&gt;
*WI2 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;
Before:&lt;br /&gt;
&lt;br /&gt;
   def conflict_notification&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    @assignment = Assignment.find(@participant.parent_id)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = @assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
      |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
    @reviewers_email_hash = Hash.new&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
    def conflict_notification&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    @assignment = Assignment.find(@participant.parent_id)&lt;br /&gt;
    #Refactored--&amp;gt; Replaced with a methood call&lt;br /&gt;
    list_questions (@assignment)&lt;br /&gt;
    @reviewers_email_hash = Hash.new&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
  end&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;
  def list_questions (assignment)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
        |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
  end&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;
Before:&lt;br /&gt;
    def edit&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = @assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
      |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
    @scores = @participant.scores(@questions)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
    def edit&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    #Refactored--&amp;gt; Replaced with a methood call&lt;br /&gt;
    list_questions (@assignment)&lt;br /&gt;
    @scores = @participant.scores(@questions)&lt;br /&gt;
  end&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;
  def list_questions (assignment)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
        |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Testing Details==&lt;br /&gt;
&lt;br /&gt;
There were no exiting test cases for the GradesController. We have added a new spec file 'grades_spec.rb' which covers testing scenario for the newly added method.&lt;br /&gt;
&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;/div&gt;</summary>
		<author><name>Agohil</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1566_ARB&amp;diff=98716</id>
		<title>CSC/ECE 517 Fall 2015/oss E1566 ARB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1566_ARB&amp;diff=98716"/>
		<updated>2015-11-07T04:33:56Z</updated>

		<summary type="html">&lt;p&gt;Agohil: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;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:&lt;br /&gt;
1.GradesController&lt;br /&gt;
2.GradesHelper&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&lt;br /&gt;
WI1 : Refactor calculate_all_penalties method into smaller methods&lt;br /&gt;
WI2 : Move the repeated code in conflict_notification &amp;amp; edit methods to a separate method list_questions.&lt;br /&gt;
WI3 : Refactor the code as per the Ruby style guidelines and incorporate the good practices&lt;br /&gt;
WI4 : Test the conflict_notification method to test the changes made.&lt;br /&gt;
&lt;br /&gt;
== Solutions Implemented and Delivered ==&lt;br /&gt;
&lt;br /&gt;
*WI1 : 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;
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;
This was split into the following three methods:&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;
Changes were also made to make the code follow ruby style. Finally some redundant code was commented out as it was non-functional.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Refactoring into smaller more specific methods:&lt;br /&gt;
&lt;br /&gt;
Before :&lt;br /&gt;
    def calculate_all_penalties(assignment_id)&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .                 &lt;br /&gt;
        if calculate_for_participants == true&lt;br /&gt;
          penalty_attr1 = {:deadline_type_id =&amp;gt; 1,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:submission]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr1)&lt;br /&gt;
          penalty_attr2 = {:deadline_type_id =&amp;gt; 2,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr2)&lt;br /&gt;
          penalty_attr3 = {:deadline_type_id =&amp;gt; 5,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:meta_review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr3)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      @all_penalties[participant.id] = {}&lt;br /&gt;
      @all_penalties[participant.id][:submission] = penalties[:submission]&lt;br /&gt;
      @all_penalties[participant.id][:review] = penalties[:review]&lt;br /&gt;
      @all_penalties[participant.id][:meta_review] = penalties[:meta_review]&lt;br /&gt;
      @all_penalties[participant.id][:total_penalty] = @total_penalty&lt;br /&gt;
    end&lt;br /&gt;
    unless @assignment.is_penalty_calculated&lt;br /&gt;
      @assignment.update_attribute(:is_penalty_calculated, true)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
    def calculate_all_penalties(assignment_id)&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .               &lt;br /&gt;
    if calculate_for_participants	&lt;br /&gt;
      calculate_penatly_attributes(@participant) #Refactored#Removed&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      assign_all_penalties(@participant)&lt;br /&gt;
    end&lt;br /&gt;
    unless @assignment.is_penalty_calculated      #Refactored#Removed&lt;br /&gt;
      @assignment.update_attribute(:is_penalty_calculated, true)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
New methods:&lt;br /&gt;
      def calculate_penatly_attributes(participant)&lt;br /&gt;
          penalty_attr1 = {:deadline_type_id =&amp;gt; 1,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:submission]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr1)&lt;br /&gt;
          penalty_attr2 = {:deadline_type_id =&amp;gt; 2,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr2)&lt;br /&gt;
          penalty_attr3 = {:deadline_type_id =&amp;gt; 5,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:meta_review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr3)&lt;br /&gt;
      end   &lt;br /&gt;
 &lt;br /&gt;
     def assign_all_penalties(participant)&lt;br /&gt;
      @all_penalties[participant.id] = {}&lt;br /&gt;
      @all_penalties[participant.id][:submission] = penalties[:submission]&lt;br /&gt;
      @all_penalties[participant.id][:review] = penalties[:review]&lt;br /&gt;
      @all_penalties[participant.id][:meta_review] = penalties[:meta_review]&lt;br /&gt;
      @all_penalties[participant.id][:total_penalty] = @total_penalty&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Removal of non-functional code :&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
                                       &lt;br /&gt;
      if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
        unless penalties[:submission]&lt;br /&gt;
          penalties[:submission] = 0&lt;br /&gt;
        end&lt;br /&gt;
        unless penalties[:review]&lt;br /&gt;
          penalties[:review] = 0&lt;br /&gt;
        end&lt;br /&gt;
        unless penalties[:meta_review]&lt;br /&gt;
          penalties[:meta_review] = 0&lt;br /&gt;
        end&lt;br /&gt;
        @total_penalty = (penalties[:submission] + penalties[:review] + penalties[:meta_review])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
     if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
         @total_penalty = (penalties[:submission] + penalties[:review] + penalties[:meta_review])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change of language to make it more Ruby friendly:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
   if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
    unless(penalties[:submission].zero? || penalties[:review].zero? || penalties[:meta_review].zero? )&lt;br /&gt;
&lt;br /&gt;
*WI2 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;
Before:&lt;br /&gt;
&lt;br /&gt;
   def conflict_notification&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    @assignment = Assignment.find(@participant.parent_id)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = @assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
      |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
    @reviewers_email_hash = Hash.new&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
    def conflict_notification&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    @assignment = Assignment.find(@participant.parent_id)&lt;br /&gt;
    #Refactored--&amp;gt; Replaced with a methood call&lt;br /&gt;
    list_questions (@assignment)&lt;br /&gt;
    @reviewers_email_hash = Hash.new&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
  end&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;
  def list_questions (assignment)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
        |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
  end&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;
Before:&lt;br /&gt;
    def edit&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = @assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
      |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
    @scores = @participant.scores(@questions)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
    def edit&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    #Refactored--&amp;gt; Replaced with a methood call&lt;br /&gt;
    list_questions (@assignment)&lt;br /&gt;
    @scores = @participant.scores(@questions)&lt;br /&gt;
  end&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;
  def list_questions (assignment)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
        |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Testing Details==&lt;br /&gt;
&lt;br /&gt;
There were no exiting test cases for the GradesController. We have added a new spec file 'grades_spec.rb' which covers testing scenario for the newly added method.&lt;br /&gt;
&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;/div&gt;</summary>
		<author><name>Agohil</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1566_ARB&amp;diff=98715</id>
		<title>CSC/ECE 517 Fall 2015/oss E1566 ARB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1566_ARB&amp;diff=98715"/>
		<updated>2015-11-07T04:32:48Z</updated>

		<summary type="html">&lt;p&gt;Agohil: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;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:&lt;br /&gt;
1.GradesController&lt;br /&gt;
2.GradesHelper&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&lt;br /&gt;
WI1 : Refactor calculate_all_penalties method into smaller methods&lt;br /&gt;
WI2 : Move the repeated code in conflict_notification &amp;amp; edit methods to a separate method list_questions.&lt;br /&gt;
WI3 : Refactor the code as per the Ruby style guidelines and incorporate the good practices&lt;br /&gt;
WI4 : Test the conflict_notification method to test the changes made.&lt;br /&gt;
&lt;br /&gt;
== Solutions Implemented and Delivered ==&lt;br /&gt;
&lt;br /&gt;
*WI1 : 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;
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;
This was split into the following three methods:&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;
Changes were also made to make the code follow ruby style. Finally some redundant code was commented out as it was non-functional.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Refactoring into smaller more specific methods:&lt;br /&gt;
&lt;br /&gt;
Before :&lt;br /&gt;
    def calculate_all_penalties(assignment_id)&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .                 &lt;br /&gt;
        if calculate_for_participants == true&lt;br /&gt;
          penalty_attr1 = {:deadline_type_id =&amp;gt; 1,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:submission]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr1)&lt;br /&gt;
          penalty_attr2 = {:deadline_type_id =&amp;gt; 2,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr2)&lt;br /&gt;
          penalty_attr3 = {:deadline_type_id =&amp;gt; 5,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:meta_review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr3)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      @all_penalties[participant.id] = {}&lt;br /&gt;
      @all_penalties[participant.id][:submission] = penalties[:submission]&lt;br /&gt;
      @all_penalties[participant.id][:review] = penalties[:review]&lt;br /&gt;
      @all_penalties[participant.id][:meta_review] = penalties[:meta_review]&lt;br /&gt;
      @all_penalties[participant.id][:total_penalty] = @total_penalty&lt;br /&gt;
    end&lt;br /&gt;
    unless @assignment.is_penalty_calculated&lt;br /&gt;
      @assignment.update_attribute(:is_penalty_calculated, true)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
    def calculate_all_penalties(assignment_id)&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .               &lt;br /&gt;
    if calculate_for_participants	&lt;br /&gt;
      calculate_penatly_attributes(@participant) #Refactored#Removed&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      assign_all_penalties(@participant)&lt;br /&gt;
    end&lt;br /&gt;
    unless @assignment.is_penalty_calculated      #Refactored#Removed&lt;br /&gt;
      @assignment.update_attribute(:is_penalty_calculated, true)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
New methods:&lt;br /&gt;
      def calculate_penatly_attributes(participant)&lt;br /&gt;
          penalty_attr1 = {:deadline_type_id =&amp;gt; 1,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:submission]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr1)&lt;br /&gt;
          penalty_attr2 = {:deadline_type_id =&amp;gt; 2,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr2)&lt;br /&gt;
          penalty_attr3 = {:deadline_type_id =&amp;gt; 5,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:meta_review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr3)&lt;br /&gt;
      end   &lt;br /&gt;
 &lt;br /&gt;
     def assign_all_penalties(participant)&lt;br /&gt;
      @all_penalties[participant.id] = {}&lt;br /&gt;
      @all_penalties[participant.id][:submission] = penalties[:submission]&lt;br /&gt;
      @all_penalties[participant.id][:review] = penalties[:review]&lt;br /&gt;
      @all_penalties[participant.id][:meta_review] = penalties[:meta_review]&lt;br /&gt;
      @all_penalties[participant.id][:total_penalty] = @total_penalty&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Removal of non-functional code :&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
                                       &lt;br /&gt;
      if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
        unless penalties[:submission]&lt;br /&gt;
          penalties[:submission] = 0&lt;br /&gt;
        end&lt;br /&gt;
        unless penalties[:review]&lt;br /&gt;
          penalties[:review] = 0&lt;br /&gt;
        end&lt;br /&gt;
        unless penalties[:meta_review]&lt;br /&gt;
          penalties[:meta_review] = 0&lt;br /&gt;
        end&lt;br /&gt;
        @total_penalty = (penalties[:submission] + penalties[:review] + penalties[:meta_review])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
     if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
         @total_penalty = (penalties[:submission] + penalties[:review] + penalties[:meta_review])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change of language to make it more Ruby friendly:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
   if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
    unless(penalties[:submission].zero? || penalties[:review].zero? || penalties[:meta_review].zero? )&lt;br /&gt;
&lt;br /&gt;
*WI2 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;
Before:&lt;br /&gt;
&lt;br /&gt;
   def conflict_notification&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    @assignment = Assignment.find(@participant.parent_id)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = @assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
      |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
    @reviewers_email_hash = Hash.new&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
    def conflict_notification&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    @assignment = Assignment.find(@participant.parent_id)&lt;br /&gt;
    #Refactored--&amp;gt; Replaced with a methood call&lt;br /&gt;
    list_questions (@assignment)&lt;br /&gt;
    @reviewers_email_hash = Hash.new&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
  end&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;
  def list_questions (assignment)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
        |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
  end&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;
Before:&lt;br /&gt;
    def edit&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = @assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
      |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
    @scores = @participant.scores(@questions)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
    def edit&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    #Refactored--&amp;gt; Replaced with a methood call&lt;br /&gt;
    list_questions (@assignment)&lt;br /&gt;
    @scores = @participant.scores(@questions)&lt;br /&gt;
  end&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;
  def list_questions (assignment)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
        |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Testing Details==&lt;br /&gt;
&lt;br /&gt;
There were no exiting test cases for the GradesController. We have added a new spec file 'grades_spec.rb' which covers testing scenario for the newly added method.&lt;br /&gt;
&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;
1. Login as instructor. Create a course and an assignment under that course.&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.&lt;br /&gt;
3. Create topics for the assignment&lt;br /&gt;
4. Sign in as one of the students who were added to the assignment. &lt;br /&gt;
5. Go to the assignment and sign up for a topic.&lt;br /&gt;
6. Submit student's work by clicking 'Your work' under that assignment.&lt;br /&gt;
7. Sign in as a different student which is participant of the assignment.&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).&lt;br /&gt;
9. Give reviews on first student's work.&lt;br /&gt;
10. Login as instructor or first student to look at the review grades.&lt;/div&gt;</summary>
		<author><name>Agohil</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1566_ARB&amp;diff=97989</id>
		<title>CSC/ECE 517 Fall 2015/oss E1566 ARB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1566_ARB&amp;diff=97989"/>
		<updated>2015-11-01T01:40:21Z</updated>

		<summary type="html">&lt;p&gt;Agohil: /* calculate_all_penalties */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Expertiza ==&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:&lt;br /&gt;
1.GradesController&lt;br /&gt;
2.GradesHelper&lt;br /&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;
&lt;br /&gt;
=== calculate_all_penalties ===&lt;br /&gt;
&lt;br /&gt;
This is used to calculate various penalty values for each assignment if penalty is applicable.&lt;br /&gt;
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;
This was split into the following three methods:&lt;br /&gt;
i.	calculate_all_penalties&lt;br /&gt;
ii.	calculate_penatly_attributes&lt;br /&gt;
iii.	assign_all_penalties&lt;br /&gt;
Changes were also made to make the code follow ruby style. 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;
&lt;br /&gt;
Before :&lt;br /&gt;
    def calculate_all_penalties(assignment_id)&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .                 &lt;br /&gt;
        if calculate_for_participants == true&lt;br /&gt;
          penalty_attr1 = {:deadline_type_id =&amp;gt; 1,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:submission]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr1)&lt;br /&gt;
          penalty_attr2 = {:deadline_type_id =&amp;gt; 2,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr2)&lt;br /&gt;
          penalty_attr3 = {:deadline_type_id =&amp;gt; 5,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:meta_review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr3)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      @all_penalties[participant.id] = {}&lt;br /&gt;
      @all_penalties[participant.id][:submission] = penalties[:submission]&lt;br /&gt;
      @all_penalties[participant.id][:review] = penalties[:review]&lt;br /&gt;
      @all_penalties[participant.id][:meta_review] = penalties[:meta_review]&lt;br /&gt;
      @all_penalties[participant.id][:total_penalty] = @total_penalty&lt;br /&gt;
    end&lt;br /&gt;
    unless @assignment.is_penalty_calculated&lt;br /&gt;
      @assignment.update_attribute(:is_penalty_calculated, true)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
    def calculate_all_penalties(assignment_id)&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .               &lt;br /&gt;
    if calculate_for_participants	&lt;br /&gt;
      calculate_penatly_attributes(@participant) #Refactored#Removed&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      assign_all_penalties(@participant)&lt;br /&gt;
    end&lt;br /&gt;
    unless @assignment.is_penalty_calculated      #Refactored#Removed&lt;br /&gt;
      @assignment.update_attribute(:is_penalty_calculated, true)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
New methods:&lt;br /&gt;
      def calculate_penatly_attributes(participant)&lt;br /&gt;
          penalty_attr1 = {:deadline_type_id =&amp;gt; 1,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:submission]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr1)&lt;br /&gt;
          penalty_attr2 = {:deadline_type_id =&amp;gt; 2,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr2)&lt;br /&gt;
          penalty_attr3 = {:deadline_type_id =&amp;gt; 5,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:meta_review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr3)&lt;br /&gt;
      end   &lt;br /&gt;
 &lt;br /&gt;
     def assign_all_penalties(participant)&lt;br /&gt;
      @all_penalties[participant.id] = {}&lt;br /&gt;
      @all_penalties[participant.id][:submission] = penalties[:submission]&lt;br /&gt;
      @all_penalties[participant.id][:review] = penalties[:review]&lt;br /&gt;
      @all_penalties[participant.id][:meta_review] = penalties[:meta_review]&lt;br /&gt;
      @all_penalties[participant.id][:total_penalty] = @total_penalty&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Removal of non-functional code :&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
                                       &lt;br /&gt;
      if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
        unless penalties[:submission]&lt;br /&gt;
          penalties[:submission] = 0&lt;br /&gt;
        end&lt;br /&gt;
        unless penalties[:review]&lt;br /&gt;
          penalties[:review] = 0&lt;br /&gt;
        end&lt;br /&gt;
        unless penalties[:meta_review]&lt;br /&gt;
          penalties[:meta_review] = 0&lt;br /&gt;
        end&lt;br /&gt;
        @total_penalty = (penalties[:submission] + penalties[:review] + penalties[:meta_review])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
     if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
         @total_penalty = (penalties[:submission] + penalties[:review] + penalties[:meta_review])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change of language to make it more Ruby friendly:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
    unless(penalties[:submission].zero? || penalties[:review].zero? || penalties[:meta_review].zero? )&lt;br /&gt;
&lt;br /&gt;
=== conflict_notification ===&lt;br /&gt;
&lt;br /&gt;
This 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;
Before:&lt;br /&gt;
&lt;br /&gt;
   def conflict_notification&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    @assignment = Assignment.find(@participant.parent_id)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = @assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
      |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
    @reviewers_email_hash = Hash.new&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
    def conflict_notification&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    @assignment = Assignment.find(@participant.parent_id)&lt;br /&gt;
    #Refactored--&amp;gt; Replaced with a methood call&lt;br /&gt;
    list_questions (@assignment)&lt;br /&gt;
    @reviewers_email_hash = Hash.new&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
  end&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;
  def list_questions (assignment)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
        |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=== edit ===&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;
Before:&lt;br /&gt;
    def edit&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = @assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
      |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
    @scores = @participant.scores(@questions)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
    def edit&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    #Refactored--&amp;gt; Replaced with a methood call&lt;br /&gt;
    list_questions (@assignment)&lt;br /&gt;
    @scores = @participant.scores(@questions)&lt;br /&gt;
  end&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;
  def list_questions (assignment)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
        |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;/div&gt;</summary>
		<author><name>Agohil</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1566_ARB&amp;diff=97988</id>
		<title>CSC/ECE 517 Fall 2015/oss E1566 ARB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1566_ARB&amp;diff=97988"/>
		<updated>2015-11-01T01:39:31Z</updated>

		<summary type="html">&lt;p&gt;Agohil: /* edit */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Expertiza ==&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:&lt;br /&gt;
1.GradesController&lt;br /&gt;
2.GradesHelper&lt;br /&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;
&lt;br /&gt;
=== calculate_all_penalties ===&lt;br /&gt;
&lt;br /&gt;
This is used to calculate various penalty values for each assignment if penalty is applicable.&lt;br /&gt;
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;
This was split into the following three methods:&lt;br /&gt;
i.	calculate_all_penalties&lt;br /&gt;
ii.	calculate_penatly_attributes&lt;br /&gt;
iii.	assign_all_penalties&lt;br /&gt;
Changes were also made to make the code follow ruby style. 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;
&lt;br /&gt;
Before :&lt;br /&gt;
    def calculate_all_penalties(assignment_id)&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .                 &lt;br /&gt;
        if calculate_for_participants == true&lt;br /&gt;
          penalty_attr1 = {:deadline_type_id =&amp;gt; 1,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:submission]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr1)&lt;br /&gt;
          penalty_attr2 = {:deadline_type_id =&amp;gt; 2,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr2)&lt;br /&gt;
          penalty_attr3 = {:deadline_type_id =&amp;gt; 5,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:meta_review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr3)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      @all_penalties[participant.id] = {}&lt;br /&gt;
      @all_penalties[participant.id][:submission] = penalties[:submission]&lt;br /&gt;
      @all_penalties[participant.id][:review] = penalties[:review]&lt;br /&gt;
      @all_penalties[participant.id][:meta_review] = penalties[:meta_review]&lt;br /&gt;
      @all_penalties[participant.id][:total_penalty] = @total_penalty&lt;br /&gt;
    end&lt;br /&gt;
    unless @assignment.is_penalty_calculated&lt;br /&gt;
      @assignment.update_attribute(:is_penalty_calculated, true)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
    def calculate_all_penalties(assignment_id)&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .               &lt;br /&gt;
    if calculate_for_participants	&lt;br /&gt;
      calculate_penatly_attributes(@participant) #Refactored#Removed&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      assign_all_penalties(@participant)&lt;br /&gt;
    end&lt;br /&gt;
    unless @assignment.is_penalty_calculated      #Refactored#Removed&lt;br /&gt;
      @assignment.update_attribute(:is_penalty_calculated, true)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      def calculate_penatly_attributes(participant)&lt;br /&gt;
          penalty_attr1 = {:deadline_type_id =&amp;gt; 1,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:submission]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr1)&lt;br /&gt;
          penalty_attr2 = {:deadline_type_id =&amp;gt; 2,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr2)&lt;br /&gt;
          penalty_attr3 = {:deadline_type_id =&amp;gt; 5,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:meta_review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr3)&lt;br /&gt;
      end   &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
     def assign_all_penalties(participant)&lt;br /&gt;
      @all_penalties[participant.id] = {}&lt;br /&gt;
      @all_penalties[participant.id][:submission] = penalties[:submission]&lt;br /&gt;
      @all_penalties[participant.id][:review] = penalties[:review]&lt;br /&gt;
      @all_penalties[participant.id][:meta_review] = penalties[:meta_review]&lt;br /&gt;
      @all_penalties[participant.id][:total_penalty] = @total_penalty&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Removal of non-functional code :&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
                                       &lt;br /&gt;
      if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
        unless penalties[:submission]&lt;br /&gt;
          penalties[:submission] = 0&lt;br /&gt;
        end&lt;br /&gt;
        unless penalties[:review]&lt;br /&gt;
          penalties[:review] = 0&lt;br /&gt;
        end&lt;br /&gt;
        unless penalties[:meta_review]&lt;br /&gt;
          penalties[:meta_review] = 0&lt;br /&gt;
        end&lt;br /&gt;
        @total_penalty = (penalties[:submission] + penalties[:review] + penalties[:meta_review])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
     if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
         @total_penalty = (penalties[:submission] + penalties[:review] + penalties[:meta_review])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change of language to make it more Ruby friendly:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
    unless(penalties[:submission].zero? || penalties[:review].zero? || penalties[:meta_review].zero? )&lt;br /&gt;
&lt;br /&gt;
=== conflict_notification ===&lt;br /&gt;
&lt;br /&gt;
This 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;
Before:&lt;br /&gt;
&lt;br /&gt;
   def conflict_notification&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    @assignment = Assignment.find(@participant.parent_id)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = @assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
      |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
    @reviewers_email_hash = Hash.new&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
    def conflict_notification&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    @assignment = Assignment.find(@participant.parent_id)&lt;br /&gt;
    #Refactored--&amp;gt; Replaced with a methood call&lt;br /&gt;
    list_questions (@assignment)&lt;br /&gt;
    @reviewers_email_hash = Hash.new&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
  end&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;
  def list_questions (assignment)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
        |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=== edit ===&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;
Before:&lt;br /&gt;
    def edit&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = @assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
      |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
    @scores = @participant.scores(@questions)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
    def edit&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    #Refactored--&amp;gt; Replaced with a methood call&lt;br /&gt;
    list_questions (@assignment)&lt;br /&gt;
    @scores = @participant.scores(@questions)&lt;br /&gt;
  end&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;
  def list_questions (assignment)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
        |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;/div&gt;</summary>
		<author><name>Agohil</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1566_ARB&amp;diff=97984</id>
		<title>CSC/ECE 517 Fall 2015/oss E1566 ARB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1566_ARB&amp;diff=97984"/>
		<updated>2015-11-01T01:37:22Z</updated>

		<summary type="html">&lt;p&gt;Agohil: /* calculate_all_penalties */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Expertiza ==&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:&lt;br /&gt;
1.GradesController&lt;br /&gt;
2.GradesHelper&lt;br /&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;
&lt;br /&gt;
=== calculate_all_penalties ===&lt;br /&gt;
&lt;br /&gt;
This is used to calculate various penalty values for each assignment if penalty is applicable.&lt;br /&gt;
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;
This was split into the following three methods:&lt;br /&gt;
i.	calculate_all_penalties&lt;br /&gt;
ii.	calculate_penatly_attributes&lt;br /&gt;
iii.	assign_all_penalties&lt;br /&gt;
Changes were also made to make the code follow ruby style. 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;
&lt;br /&gt;
Before :&lt;br /&gt;
    def calculate_all_penalties(assignment_id)&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .                 &lt;br /&gt;
        if calculate_for_participants == true&lt;br /&gt;
          penalty_attr1 = {:deadline_type_id =&amp;gt; 1,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:submission]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr1)&lt;br /&gt;
          penalty_attr2 = {:deadline_type_id =&amp;gt; 2,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr2)&lt;br /&gt;
          penalty_attr3 = {:deadline_type_id =&amp;gt; 5,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:meta_review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr3)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      @all_penalties[participant.id] = {}&lt;br /&gt;
      @all_penalties[participant.id][:submission] = penalties[:submission]&lt;br /&gt;
      @all_penalties[participant.id][:review] = penalties[:review]&lt;br /&gt;
      @all_penalties[participant.id][:meta_review] = penalties[:meta_review]&lt;br /&gt;
      @all_penalties[participant.id][:total_penalty] = @total_penalty&lt;br /&gt;
    end&lt;br /&gt;
    unless @assignment.is_penalty_calculated&lt;br /&gt;
      @assignment.update_attribute(:is_penalty_calculated, true)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
    def calculate_all_penalties(assignment_id)&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .               &lt;br /&gt;
    if calculate_for_participants	&lt;br /&gt;
      calculate_penatly_attributes(@participant) #Refactored#Removed&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      assign_all_penalties(@participant)&lt;br /&gt;
    end&lt;br /&gt;
    unless @assignment.is_penalty_calculated      #Refactored#Removed&lt;br /&gt;
      @assignment.update_attribute(:is_penalty_calculated, true)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      def calculate_penatly_attributes(participant)&lt;br /&gt;
          penalty_attr1 = {:deadline_type_id =&amp;gt; 1,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:submission]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr1)&lt;br /&gt;
          penalty_attr2 = {:deadline_type_id =&amp;gt; 2,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr2)&lt;br /&gt;
          penalty_attr3 = {:deadline_type_id =&amp;gt; 5,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:meta_review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr3)&lt;br /&gt;
      end   &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
     def assign_all_penalties(participant)&lt;br /&gt;
      @all_penalties[participant.id] = {}&lt;br /&gt;
      @all_penalties[participant.id][:submission] = penalties[:submission]&lt;br /&gt;
      @all_penalties[participant.id][:review] = penalties[:review]&lt;br /&gt;
      @all_penalties[participant.id][:meta_review] = penalties[:meta_review]&lt;br /&gt;
      @all_penalties[participant.id][:total_penalty] = @total_penalty&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Removal of non-functional code :&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
                                       &lt;br /&gt;
      if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
        unless penalties[:submission]&lt;br /&gt;
          penalties[:submission] = 0&lt;br /&gt;
        end&lt;br /&gt;
        unless penalties[:review]&lt;br /&gt;
          penalties[:review] = 0&lt;br /&gt;
        end&lt;br /&gt;
        unless penalties[:meta_review]&lt;br /&gt;
          penalties[:meta_review] = 0&lt;br /&gt;
        end&lt;br /&gt;
        @total_penalty = (penalties[:submission] + penalties[:review] + penalties[:meta_review])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
     if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
         @total_penalty = (penalties[:submission] + penalties[:review] + penalties[:meta_review])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change of language to make it more Ruby friendly:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
    unless(penalties[:submission].zero? || penalties[:review].zero? || penalties[:meta_review].zero? )&lt;br /&gt;
&lt;br /&gt;
=== conflict_notification ===&lt;br /&gt;
&lt;br /&gt;
This 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;
Before:&lt;br /&gt;
&lt;br /&gt;
   def conflict_notification&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    @assignment = Assignment.find(@participant.parent_id)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = @assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
      |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
    @reviewers_email_hash = Hash.new&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
    def conflict_notification&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    @assignment = Assignment.find(@participant.parent_id)&lt;br /&gt;
    #Refactored--&amp;gt; Replaced with a methood call&lt;br /&gt;
    list_questions (@assignment)&lt;br /&gt;
    @reviewers_email_hash = Hash.new&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
  end&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;
  def list_questions (assignment)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
        |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=== edit ===&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;
Before:&lt;br /&gt;
    def edit&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = @assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
      |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
    @scores = @participant.scores(@questions)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
    def edit&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    #Refactored--&amp;gt; Replaced with a methood call&lt;br /&gt;
    list_questions (@assignment)&lt;br /&gt;
    @scores = @participant.scores(@questions)&lt;br /&gt;
  end&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;
  def list_questions (assignment)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
        |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;/div&gt;</summary>
		<author><name>Agohil</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1566_ARB&amp;diff=97977</id>
		<title>CSC/ECE 517 Fall 2015/oss E1566 ARB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1566_ARB&amp;diff=97977"/>
		<updated>2015-11-01T01:30:28Z</updated>

		<summary type="html">&lt;p&gt;Agohil: /* edit */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Expertiza ==&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:&lt;br /&gt;
1.GradesController&lt;br /&gt;
2.GradesHelper&lt;br /&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;
&lt;br /&gt;
=== calculate_all_penalties ===&lt;br /&gt;
&lt;br /&gt;
This is used to calculate various penalty values for each assignment if penalty is applicable.&lt;br /&gt;
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;
This was split into the following three methods:&lt;br /&gt;
i.	calculate_all_penalties&lt;br /&gt;
ii.	calculate_penatly_attributes&lt;br /&gt;
iii.	assign_all_penalties&lt;br /&gt;
Changes were also made to make the code follow ruby style. 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;
&lt;br /&gt;
Before :&lt;br /&gt;
    def calculate_all_penalties(assignment_id)&lt;br /&gt;
    ………………………………………………………………………………………………………………………………………………………………&lt;br /&gt;
    ………………………………………………………………………………………………………………………………………………………………&lt;br /&gt;
    ………………………………………………………………………………………………………………………………………………………………                   &lt;br /&gt;
        if calculate_for_participants == true&lt;br /&gt;
          penalty_attr1 = {:deadline_type_id =&amp;gt; 1,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:submission]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr1)&lt;br /&gt;
          penalty_attr2 = {:deadline_type_id =&amp;gt; 2,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr2)&lt;br /&gt;
          penalty_attr3 = {:deadline_type_id =&amp;gt; 5,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:meta_review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr3)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      @all_penalties[participant.id] = {}&lt;br /&gt;
      @all_penalties[participant.id][:submission] = penalties[:submission]&lt;br /&gt;
      @all_penalties[participant.id][:review] = penalties[:review]&lt;br /&gt;
      @all_penalties[participant.id][:meta_review] = penalties[:meta_review]&lt;br /&gt;
      @all_penalties[participant.id][:total_penalty] = @total_penalty&lt;br /&gt;
    end&lt;br /&gt;
    unless @assignment.is_penalty_calculated&lt;br /&gt;
      @assignment.update_attribute(:is_penalty_calculated, true)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
    def calculate_all_penalties(assignment_id)&lt;br /&gt;
    ………………………………………………………………………………………………………………………………………………………………&lt;br /&gt;
    ………………………………………………………………………………………………………………………………………………………………&lt;br /&gt;
    ………………………………………………………………………………………………………………………………………………………………                     &lt;br /&gt;
    if calculate_for_participants	&lt;br /&gt;
      calculate_penatly_attributes(@participant) #Refactored#Removed&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      assign_all_penalties(@participant)&lt;br /&gt;
    end&lt;br /&gt;
    unless @assignment.is_penalty_calculated      #Refactored#Removed&lt;br /&gt;
      @assignment.update_attribute(:is_penalty_calculated, true)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      def calculate_penatly_attributes(participant)&lt;br /&gt;
          penalty_attr1 = {:deadline_type_id =&amp;gt; 1,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:submission]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr1)&lt;br /&gt;
          penalty_attr2 = {:deadline_type_id =&amp;gt; 2,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr2)&lt;br /&gt;
          penalty_attr3 = {:deadline_type_id =&amp;gt; 5,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:meta_review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr3)&lt;br /&gt;
      end   &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
     def assign_all_penalties(participant)&lt;br /&gt;
      @all_penalties[participant.id] = {}&lt;br /&gt;
      @all_penalties[participant.id][:submission] = penalties[:submission]&lt;br /&gt;
      @all_penalties[participant.id][:review] = penalties[:review]&lt;br /&gt;
      @all_penalties[participant.id][:meta_review] = penalties[:meta_review]&lt;br /&gt;
      @all_penalties[participant.id][:total_penalty] = @total_penalty&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Removal of non-functional code :&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
                                       &lt;br /&gt;
      if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
        unless penalties[:submission]&lt;br /&gt;
          penalties[:submission] = 0&lt;br /&gt;
        end&lt;br /&gt;
        unless penalties[:review]&lt;br /&gt;
          penalties[:review] = 0&lt;br /&gt;
        end&lt;br /&gt;
        unless penalties[:meta_review]&lt;br /&gt;
          penalties[:meta_review] = 0&lt;br /&gt;
        end&lt;br /&gt;
        @total_penalty = (penalties[:submission] + penalties[:review] + penalties[:meta_review])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
     if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
         @total_penalty = (penalties[:submission] + penalties[:review] + penalties[:meta_review])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change of language to make it more Ruby friendly:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
    unless(penalties[:submission].zero? || penalties[:review].zero? || penalties[:meta_review].zero? )&lt;br /&gt;
&lt;br /&gt;
=== conflict_notification ===&lt;br /&gt;
&lt;br /&gt;
This 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;
Before:&lt;br /&gt;
&lt;br /&gt;
   def conflict_notification&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    @assignment = Assignment.find(@participant.parent_id)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = @assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
      |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
    @reviewers_email_hash = Hash.new&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
    def conflict_notification&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    @assignment = Assignment.find(@participant.parent_id)&lt;br /&gt;
    #Refactored--&amp;gt; Replaced with a methood call&lt;br /&gt;
    list_questions (@assignment)&lt;br /&gt;
    @reviewers_email_hash = Hash.new&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
  end&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;
  def list_questions (assignment)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
        |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=== edit ===&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;
Before:&lt;br /&gt;
    def edit&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = @assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
      |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
    @scores = @participant.scores(@questions)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
    def edit&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    #Refactored--&amp;gt; Replaced with a methood call&lt;br /&gt;
    list_questions (@assignment)&lt;br /&gt;
    @scores = @participant.scores(@questions)&lt;br /&gt;
  end&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;
  def list_questions (assignment)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
        |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;/div&gt;</summary>
		<author><name>Agohil</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1566_ARB&amp;diff=97972</id>
		<title>CSC/ECE 517 Fall 2015/oss E1566 ARB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1566_ARB&amp;diff=97972"/>
		<updated>2015-11-01T01:26:45Z</updated>

		<summary type="html">&lt;p&gt;Agohil: /* conflict_notification */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Expertiza ==&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:&lt;br /&gt;
1.GradesController&lt;br /&gt;
2.GradesHelper&lt;br /&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;
&lt;br /&gt;
=== calculate_all_penalties ===&lt;br /&gt;
&lt;br /&gt;
This is used to calculate various penalty values for each assignment if penalty is applicable.&lt;br /&gt;
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;
This was split into the following three methods:&lt;br /&gt;
i.	calculate_all_penalties&lt;br /&gt;
ii.	calculate_penatly_attributes&lt;br /&gt;
iii.	assign_all_penalties&lt;br /&gt;
Changes were also made to make the code follow ruby style. 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;
&lt;br /&gt;
Before :&lt;br /&gt;
    def calculate_all_penalties(assignment_id)&lt;br /&gt;
    ………………………………………………………………………………………………………………………………………………………………&lt;br /&gt;
    ………………………………………………………………………………………………………………………………………………………………&lt;br /&gt;
    ………………………………………………………………………………………………………………………………………………………………                   &lt;br /&gt;
        if calculate_for_participants == true&lt;br /&gt;
          penalty_attr1 = {:deadline_type_id =&amp;gt; 1,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:submission]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr1)&lt;br /&gt;
          penalty_attr2 = {:deadline_type_id =&amp;gt; 2,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr2)&lt;br /&gt;
          penalty_attr3 = {:deadline_type_id =&amp;gt; 5,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:meta_review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr3)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      @all_penalties[participant.id] = {}&lt;br /&gt;
      @all_penalties[participant.id][:submission] = penalties[:submission]&lt;br /&gt;
      @all_penalties[participant.id][:review] = penalties[:review]&lt;br /&gt;
      @all_penalties[participant.id][:meta_review] = penalties[:meta_review]&lt;br /&gt;
      @all_penalties[participant.id][:total_penalty] = @total_penalty&lt;br /&gt;
    end&lt;br /&gt;
    unless @assignment.is_penalty_calculated&lt;br /&gt;
      @assignment.update_attribute(:is_penalty_calculated, true)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
    def calculate_all_penalties(assignment_id)&lt;br /&gt;
    ………………………………………………………………………………………………………………………………………………………………&lt;br /&gt;
    ………………………………………………………………………………………………………………………………………………………………&lt;br /&gt;
    ………………………………………………………………………………………………………………………………………………………………                     &lt;br /&gt;
    if calculate_for_participants	&lt;br /&gt;
      calculate_penatly_attributes(@participant) #Refactored#Removed&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      assign_all_penalties(@participant)&lt;br /&gt;
    end&lt;br /&gt;
    unless @assignment.is_penalty_calculated      #Refactored#Removed&lt;br /&gt;
      @assignment.update_attribute(:is_penalty_calculated, true)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      def calculate_penatly_attributes(participant)&lt;br /&gt;
          penalty_attr1 = {:deadline_type_id =&amp;gt; 1,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:submission]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr1)&lt;br /&gt;
          penalty_attr2 = {:deadline_type_id =&amp;gt; 2,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr2)&lt;br /&gt;
          penalty_attr3 = {:deadline_type_id =&amp;gt; 5,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:meta_review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr3)&lt;br /&gt;
      end   &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
     def assign_all_penalties(participant)&lt;br /&gt;
      @all_penalties[participant.id] = {}&lt;br /&gt;
      @all_penalties[participant.id][:submission] = penalties[:submission]&lt;br /&gt;
      @all_penalties[participant.id][:review] = penalties[:review]&lt;br /&gt;
      @all_penalties[participant.id][:meta_review] = penalties[:meta_review]&lt;br /&gt;
      @all_penalties[participant.id][:total_penalty] = @total_penalty&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Removal of non-functional code :&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
                                       &lt;br /&gt;
      if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
        unless penalties[:submission]&lt;br /&gt;
          penalties[:submission] = 0&lt;br /&gt;
        end&lt;br /&gt;
        unless penalties[:review]&lt;br /&gt;
          penalties[:review] = 0&lt;br /&gt;
        end&lt;br /&gt;
        unless penalties[:meta_review]&lt;br /&gt;
          penalties[:meta_review] = 0&lt;br /&gt;
        end&lt;br /&gt;
        @total_penalty = (penalties[:submission] + penalties[:review] + penalties[:meta_review])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
     if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
         @total_penalty = (penalties[:submission] + penalties[:review] + penalties[:meta_review])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change of language to make it more Ruby friendly:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
    unless(penalties[:submission].zero? || penalties[:review].zero? || penalties[:meta_review].zero? )&lt;br /&gt;
&lt;br /&gt;
=== conflict_notification ===&lt;br /&gt;
&lt;br /&gt;
This 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;
Before:&lt;br /&gt;
&lt;br /&gt;
   def conflict_notification&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    @assignment = Assignment.find(@participant.parent_id)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = @assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
      |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
    @reviewers_email_hash = Hash.new&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
    def conflict_notification&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    @assignment = Assignment.find(@participant.parent_id)&lt;br /&gt;
    #Refactored--&amp;gt; Replaced with a methood call&lt;br /&gt;
    list_questions (@assignment)&lt;br /&gt;
    @reviewers_email_hash = Hash.new&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
  end&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;
  def list_questions (assignment)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
        |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=== edit ===&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;
Before:&lt;br /&gt;
    def edit&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = @assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
      |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
    @scores = @participant.scores(@questions)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
    def edit&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    ##################################################################################&lt;br /&gt;
    #	@questions = Hash.new&lt;br /&gt;
    #    questionnaires = assignment.questionnaires&lt;br /&gt;
    #    questionnaires.each {&lt;br /&gt;
    #        |questionnaire|&lt;br /&gt;
    #      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    #    }&lt;br /&gt;
    ##################################################################################&lt;br /&gt;
    #Refactored--&amp;gt; Replaced with a methood call&lt;br /&gt;
    list_questions (@assignment)&lt;br /&gt;
    #################################################################################&lt;br /&gt;
    @scores = @participant.scores(@questions)&lt;br /&gt;
  end&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;
  def list_questions (assignment)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
        |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;/div&gt;</summary>
		<author><name>Agohil</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1566_ARB&amp;diff=97961</id>
		<title>CSC/ECE 517 Fall 2015/oss E1566 ARB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1566_ARB&amp;diff=97961"/>
		<updated>2015-11-01T01:18:37Z</updated>

		<summary type="html">&lt;p&gt;Agohil: /* Expertiza */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Expertiza ==&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:&lt;br /&gt;
1.GradesController&lt;br /&gt;
2.GradesHelper&lt;br /&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;
&lt;br /&gt;
=== calculate_all_penalties ===&lt;br /&gt;
&lt;br /&gt;
This is used to calculate various penalty values for each assignment if penalty is applicable.&lt;br /&gt;
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;
This was split into the following three methods:&lt;br /&gt;
i.	calculate_all_penalties&lt;br /&gt;
ii.	calculate_penatly_attributes&lt;br /&gt;
iii.	assign_all_penalties&lt;br /&gt;
Changes were also made to make the code follow ruby style. 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;
&lt;br /&gt;
Before :&lt;br /&gt;
    def calculate_all_penalties(assignment_id)&lt;br /&gt;
    ………………………………………………………………………………………………………………………………………………………………&lt;br /&gt;
    ………………………………………………………………………………………………………………………………………………………………&lt;br /&gt;
    ………………………………………………………………………………………………………………………………………………………………                   &lt;br /&gt;
        if calculate_for_participants == true&lt;br /&gt;
          penalty_attr1 = {:deadline_type_id =&amp;gt; 1,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:submission]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr1)&lt;br /&gt;
          penalty_attr2 = {:deadline_type_id =&amp;gt; 2,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr2)&lt;br /&gt;
          penalty_attr3 = {:deadline_type_id =&amp;gt; 5,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:meta_review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr3)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      @all_penalties[participant.id] = {}&lt;br /&gt;
      @all_penalties[participant.id][:submission] = penalties[:submission]&lt;br /&gt;
      @all_penalties[participant.id][:review] = penalties[:review]&lt;br /&gt;
      @all_penalties[participant.id][:meta_review] = penalties[:meta_review]&lt;br /&gt;
      @all_penalties[participant.id][:total_penalty] = @total_penalty&lt;br /&gt;
    end&lt;br /&gt;
    unless @assignment.is_penalty_calculated&lt;br /&gt;
      @assignment.update_attribute(:is_penalty_calculated, true)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
    def calculate_all_penalties(assignment_id)&lt;br /&gt;
    ………………………………………………………………………………………………………………………………………………………………&lt;br /&gt;
    ………………………………………………………………………………………………………………………………………………………………&lt;br /&gt;
    ………………………………………………………………………………………………………………………………………………………………                     &lt;br /&gt;
    if calculate_for_participants	&lt;br /&gt;
      calculate_penatly_attributes(@participant) #Refactored#Removed&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      assign_all_penalties(@participant)&lt;br /&gt;
    end&lt;br /&gt;
    unless @assignment.is_penalty_calculated      #Refactored#Removed&lt;br /&gt;
      @assignment.update_attribute(:is_penalty_calculated, true)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      def calculate_penatly_attributes(participant)&lt;br /&gt;
          penalty_attr1 = {:deadline_type_id =&amp;gt; 1,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:submission]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr1)&lt;br /&gt;
          penalty_attr2 = {:deadline_type_id =&amp;gt; 2,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr2)&lt;br /&gt;
          penalty_attr3 = {:deadline_type_id =&amp;gt; 5,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:meta_review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr3)&lt;br /&gt;
      end   &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
     def assign_all_penalties(participant)&lt;br /&gt;
      @all_penalties[participant.id] = {}&lt;br /&gt;
      @all_penalties[participant.id][:submission] = penalties[:submission]&lt;br /&gt;
      @all_penalties[participant.id][:review] = penalties[:review]&lt;br /&gt;
      @all_penalties[participant.id][:meta_review] = penalties[:meta_review]&lt;br /&gt;
      @all_penalties[participant.id][:total_penalty] = @total_penalty&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Removal of non-functional code :&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
                                       &lt;br /&gt;
      if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
        unless penalties[:submission]&lt;br /&gt;
          penalties[:submission] = 0&lt;br /&gt;
        end&lt;br /&gt;
        unless penalties[:review]&lt;br /&gt;
          penalties[:review] = 0&lt;br /&gt;
        end&lt;br /&gt;
        unless penalties[:meta_review]&lt;br /&gt;
          penalties[:meta_review] = 0&lt;br /&gt;
        end&lt;br /&gt;
        @total_penalty = (penalties[:submission] + penalties[:review] + penalties[:meta_review])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
     if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
         @total_penalty = (penalties[:submission] + penalties[:review] + penalties[:meta_review])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change of language to make it more Ruby friendly:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
    unless(penalties[:submission].zero? || penalties[:review].zero? || penalties[:meta_review].zero? )&lt;br /&gt;
&lt;br /&gt;
=== conflict_notification ===&lt;br /&gt;
&lt;br /&gt;
This 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;
Before:&lt;br /&gt;
&lt;br /&gt;
   def conflict_notification&lt;br /&gt;
    if session[:user].role_id !=6&lt;br /&gt;
      @instructor = session[:user]&lt;br /&gt;
    else&lt;br /&gt;
      @instructor = Ta.get_my_instructor(session[:user].id)&lt;br /&gt;
    end&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = Assignment.find(@participant.parent_id)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = @assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
      |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
    @reviewers_email_hash = Hash.new&lt;br /&gt;
    @caction = &amp;quot;view&amp;quot;&lt;br /&gt;
    @submission = params[:submission]&lt;br /&gt;
    if @submission == &amp;quot;review&amp;quot;&lt;br /&gt;
      @caction = &amp;quot;view_review&amp;quot;&lt;br /&gt;
      @symbol = &amp;quot;review&amp;quot;&lt;br /&gt;
      process_response(&amp;quot;Review&amp;quot;, &amp;quot;Reviewer&amp;quot;, @participant.reviews, &amp;quot;ReviewQuestionnaire&amp;quot;)&lt;br /&gt;
    elsif @submission == &amp;quot;review_of_review&amp;quot;&lt;br /&gt;
      @symbol = &amp;quot;metareview&amp;quot;&lt;br /&gt;
      process_response(&amp;quot;Metareview&amp;quot;, &amp;quot;Metareviewer&amp;quot;, @participant.metareviews, &amp;quot;MetareviewQuestionnaire&amp;quot;)&lt;br /&gt;
    elsif @submission == &amp;quot;review_feedback&amp;quot;&lt;br /&gt;
      @symbol = &amp;quot;feedback&amp;quot;&lt;br /&gt;
      process_response(&amp;quot;Feedback&amp;quot;, &amp;quot;Author&amp;quot;, @participant.feedback, &amp;quot;AuthorFeedbackQuestionnaire&amp;quot;)&lt;br /&gt;
    elsif @submission == &amp;quot;teammate_review&amp;quot;&lt;br /&gt;
      @symbol = &amp;quot;teammate&amp;quot;&lt;br /&gt;
      process_response(&amp;quot;Teammate Review&amp;quot;, &amp;quot;Reviewer&amp;quot;, @participant.teammate_reviews, &amp;quot;TeammateReviewQuestionnaire&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    @subject = &amp;quot; Your &amp;quot;+@collabel.downcase+&amp;quot; score for &amp;quot; + @assignment.name + &amp;quot; conflicts with another &amp;quot;+@rowlabel.downcase+&amp;quot;'s score.&amp;quot;&lt;br /&gt;
    @body = get_body_text(params[:submission])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
    def conflict_notification&lt;br /&gt;
    if session[:user].role_id !=6&lt;br /&gt;
      @instructor = session[:user]&lt;br /&gt;
    else&lt;br /&gt;
      @instructor = Ta.get_my_instructor(session[:user].id)&lt;br /&gt;
    end&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = Assignment.find(@participant.parent_id)&lt;br /&gt;
    ##################################################################################&lt;br /&gt;
    #	@questions = Hash.new&lt;br /&gt;
    #    questionnaires = assignment.questionnaires&lt;br /&gt;
    #    questionnaires.each {&lt;br /&gt;
    #        |questionnaire|&lt;br /&gt;
    #      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    #    }&lt;br /&gt;
    ##################################################################################&lt;br /&gt;
    #Refactored--&amp;gt; Replaced with a methood call&lt;br /&gt;
    list_questions (@assignment)&lt;br /&gt;
    #################################################################################&lt;br /&gt;
    @reviewers_email_hash = Hash.new&lt;br /&gt;
    @caction = &amp;quot;view&amp;quot;&lt;br /&gt;
    @submission = params[:submission]&lt;br /&gt;
    if @submission == &amp;quot;review&amp;quot;&lt;br /&gt;
      @caction = &amp;quot;view_review&amp;quot;&lt;br /&gt;
      @symbol = &amp;quot;review&amp;quot;&lt;br /&gt;
      process_response(&amp;quot;Review&amp;quot;, &amp;quot;Reviewer&amp;quot;, @participant.reviews, &amp;quot;ReviewQuestionnaire&amp;quot;)&lt;br /&gt;
    elsif @submission == &amp;quot;review_of_review&amp;quot;&lt;br /&gt;
      @symbol = &amp;quot;metareview&amp;quot;&lt;br /&gt;
      process_response(&amp;quot;Metareview&amp;quot;, &amp;quot;Metareviewer&amp;quot;, @participant.metareviews, &amp;quot;MetareviewQuestionnaire&amp;quot;)&lt;br /&gt;
    elsif @submission == &amp;quot;review_feedback&amp;quot;&lt;br /&gt;
      @symbol = &amp;quot;feedback&amp;quot;&lt;br /&gt;
      process_response(&amp;quot;Feedback&amp;quot;, &amp;quot;Author&amp;quot;, @participant.feedback, &amp;quot;AuthorFeedbackQuestionnaire&amp;quot;)&lt;br /&gt;
    elsif @submission == &amp;quot;teammate_review&amp;quot;&lt;br /&gt;
      @symbol = &amp;quot;teammate&amp;quot;&lt;br /&gt;
      process_response(&amp;quot;Teammate Review&amp;quot;, &amp;quot;Reviewer&amp;quot;, @participant.teammate_reviews, &amp;quot;TeammateReviewQuestionnaire&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    @subject = &amp;quot; Your &amp;quot;+@collabel.downcase+&amp;quot; score for &amp;quot; + @assignment.name + &amp;quot; conflicts with another &amp;quot;+@rowlabel.downcase+&amp;quot;'s score.&amp;quot;&lt;br /&gt;
    @body = get_body_text(params[:submission])&lt;br /&gt;
  end&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;
  def list_questions (assignment)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
        |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== edit ===&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;
Before:&lt;br /&gt;
    def edit&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = @assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
      |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
    @scores = @participant.scores(@questions)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
    def edit&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    ##################################################################################&lt;br /&gt;
    #	@questions = Hash.new&lt;br /&gt;
    #    questionnaires = assignment.questionnaires&lt;br /&gt;
    #    questionnaires.each {&lt;br /&gt;
    #        |questionnaire|&lt;br /&gt;
    #      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    #    }&lt;br /&gt;
    ##################################################################################&lt;br /&gt;
    #Refactored--&amp;gt; Replaced with a methood call&lt;br /&gt;
    list_questions (@assignment)&lt;br /&gt;
    #################################################################################&lt;br /&gt;
    @scores = @participant.scores(@questions)&lt;br /&gt;
  end&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;
  def list_questions (assignment)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
        |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;/div&gt;</summary>
		<author><name>Agohil</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1566_ARB&amp;diff=97959</id>
		<title>CSC/ECE 517 Fall 2015/oss E1566 ARB</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1566_ARB&amp;diff=97959"/>
		<updated>2015-11-01T01:17:14Z</updated>

		<summary type="html">&lt;p&gt;Agohil: /* calculate_all_penalties */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Expertiza ==&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 the Ruby on Rails platform and it’s code is available of 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:&lt;br /&gt;
1.GradesController&lt;br /&gt;
2.GradesHelper&lt;br /&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;
&lt;br /&gt;
=== calculate_all_penalties ===&lt;br /&gt;
&lt;br /&gt;
This is used to calculate various penalty values for each assignment if penalty is applicable.&lt;br /&gt;
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;
This was split into the following three methods:&lt;br /&gt;
i.	calculate_all_penalties&lt;br /&gt;
ii.	calculate_penatly_attributes&lt;br /&gt;
iii.	assign_all_penalties&lt;br /&gt;
Changes were also made to make the code follow ruby style. 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;
&lt;br /&gt;
Before :&lt;br /&gt;
    def calculate_all_penalties(assignment_id)&lt;br /&gt;
    ………………………………………………………………………………………………………………………………………………………………&lt;br /&gt;
    ………………………………………………………………………………………………………………………………………………………………&lt;br /&gt;
    ………………………………………………………………………………………………………………………………………………………………                   &lt;br /&gt;
        if calculate_for_participants == true&lt;br /&gt;
          penalty_attr1 = {:deadline_type_id =&amp;gt; 1,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:submission]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr1)&lt;br /&gt;
          penalty_attr2 = {:deadline_type_id =&amp;gt; 2,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr2)&lt;br /&gt;
          penalty_attr3 = {:deadline_type_id =&amp;gt; 5,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:meta_review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr3)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      @all_penalties[participant.id] = {}&lt;br /&gt;
      @all_penalties[participant.id][:submission] = penalties[:submission]&lt;br /&gt;
      @all_penalties[participant.id][:review] = penalties[:review]&lt;br /&gt;
      @all_penalties[participant.id][:meta_review] = penalties[:meta_review]&lt;br /&gt;
      @all_penalties[participant.id][:total_penalty] = @total_penalty&lt;br /&gt;
    end&lt;br /&gt;
    unless @assignment.is_penalty_calculated&lt;br /&gt;
      @assignment.update_attribute(:is_penalty_calculated, true)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
    def calculate_all_penalties(assignment_id)&lt;br /&gt;
    ………………………………………………………………………………………………………………………………………………………………&lt;br /&gt;
    ………………………………………………………………………………………………………………………………………………………………&lt;br /&gt;
    ………………………………………………………………………………………………………………………………………………………………                     &lt;br /&gt;
    if calculate_for_participants	&lt;br /&gt;
      calculate_penatly_attributes(@participant) #Refactored#Removed&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
      assign_all_penalties(@participant)&lt;br /&gt;
    end&lt;br /&gt;
    unless @assignment.is_penalty_calculated      #Refactored#Removed&lt;br /&gt;
      @assignment.update_attribute(:is_penalty_calculated, true)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      def calculate_penatly_attributes(participant)&lt;br /&gt;
          penalty_attr1 = {:deadline_type_id =&amp;gt; 1,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:submission]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr1)&lt;br /&gt;
          penalty_attr2 = {:deadline_type_id =&amp;gt; 2,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr2)&lt;br /&gt;
          penalty_attr3 = {:deadline_type_id =&amp;gt; 5,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:meta_review]}&lt;br /&gt;
          CalculatedPenalty.create(penalty_attr3)&lt;br /&gt;
      end   &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
     def assign_all_penalties(participant)&lt;br /&gt;
      @all_penalties[participant.id] = {}&lt;br /&gt;
      @all_penalties[participant.id][:submission] = penalties[:submission]&lt;br /&gt;
      @all_penalties[participant.id][:review] = penalties[:review]&lt;br /&gt;
      @all_penalties[participant.id][:meta_review] = penalties[:meta_review]&lt;br /&gt;
      @all_penalties[participant.id][:total_penalty] = @total_penalty&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Removal of non-functional code :&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
                                       &lt;br /&gt;
      if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
        unless penalties[:submission]&lt;br /&gt;
          penalties[:submission] = 0&lt;br /&gt;
        end&lt;br /&gt;
        unless penalties[:review]&lt;br /&gt;
          penalties[:review] = 0&lt;br /&gt;
        end&lt;br /&gt;
        unless penalties[:meta_review]&lt;br /&gt;
          penalties[:meta_review] = 0&lt;br /&gt;
        end&lt;br /&gt;
        @total_penalty = (penalties[:submission] + penalties[:review] + penalties[:meta_review])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
     if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
         @total_penalty = (penalties[:submission] + penalties[:review] + penalties[:meta_review])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change of language to make it more Ruby friendly:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   if(penalties[:submission] != 0 || penalties[:review] != 0 || penalties[:meta_review] != 0)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
    unless(penalties[:submission].zero? || penalties[:review].zero? || penalties[:meta_review].zero? )&lt;br /&gt;
&lt;br /&gt;
=== conflict_notification ===&lt;br /&gt;
&lt;br /&gt;
This 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;
Before:&lt;br /&gt;
&lt;br /&gt;
   def conflict_notification&lt;br /&gt;
    if session[:user].role_id !=6&lt;br /&gt;
      @instructor = session[:user]&lt;br /&gt;
    else&lt;br /&gt;
      @instructor = Ta.get_my_instructor(session[:user].id)&lt;br /&gt;
    end&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = Assignment.find(@participant.parent_id)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = @assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
      |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
    @reviewers_email_hash = Hash.new&lt;br /&gt;
    @caction = &amp;quot;view&amp;quot;&lt;br /&gt;
    @submission = params[:submission]&lt;br /&gt;
    if @submission == &amp;quot;review&amp;quot;&lt;br /&gt;
      @caction = &amp;quot;view_review&amp;quot;&lt;br /&gt;
      @symbol = &amp;quot;review&amp;quot;&lt;br /&gt;
      process_response(&amp;quot;Review&amp;quot;, &amp;quot;Reviewer&amp;quot;, @participant.reviews, &amp;quot;ReviewQuestionnaire&amp;quot;)&lt;br /&gt;
    elsif @submission == &amp;quot;review_of_review&amp;quot;&lt;br /&gt;
      @symbol = &amp;quot;metareview&amp;quot;&lt;br /&gt;
      process_response(&amp;quot;Metareview&amp;quot;, &amp;quot;Metareviewer&amp;quot;, @participant.metareviews, &amp;quot;MetareviewQuestionnaire&amp;quot;)&lt;br /&gt;
    elsif @submission == &amp;quot;review_feedback&amp;quot;&lt;br /&gt;
      @symbol = &amp;quot;feedback&amp;quot;&lt;br /&gt;
      process_response(&amp;quot;Feedback&amp;quot;, &amp;quot;Author&amp;quot;, @participant.feedback, &amp;quot;AuthorFeedbackQuestionnaire&amp;quot;)&lt;br /&gt;
    elsif @submission == &amp;quot;teammate_review&amp;quot;&lt;br /&gt;
      @symbol = &amp;quot;teammate&amp;quot;&lt;br /&gt;
      process_response(&amp;quot;Teammate Review&amp;quot;, &amp;quot;Reviewer&amp;quot;, @participant.teammate_reviews, &amp;quot;TeammateReviewQuestionnaire&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    @subject = &amp;quot; Your &amp;quot;+@collabel.downcase+&amp;quot; score for &amp;quot; + @assignment.name + &amp;quot; conflicts with another &amp;quot;+@rowlabel.downcase+&amp;quot;'s score.&amp;quot;&lt;br /&gt;
    @body = get_body_text(params[:submission])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
    def conflict_notification&lt;br /&gt;
    if session[:user].role_id !=6&lt;br /&gt;
      @instructor = session[:user]&lt;br /&gt;
    else&lt;br /&gt;
      @instructor = Ta.get_my_instructor(session[:user].id)&lt;br /&gt;
    end&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = Assignment.find(@participant.parent_id)&lt;br /&gt;
    ##################################################################################&lt;br /&gt;
    #	@questions = Hash.new&lt;br /&gt;
    #    questionnaires = assignment.questionnaires&lt;br /&gt;
    #    questionnaires.each {&lt;br /&gt;
    #        |questionnaire|&lt;br /&gt;
    #      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    #    }&lt;br /&gt;
    ##################################################################################&lt;br /&gt;
    #Refactored--&amp;gt; Replaced with a methood call&lt;br /&gt;
    list_questions (@assignment)&lt;br /&gt;
    #################################################################################&lt;br /&gt;
    @reviewers_email_hash = Hash.new&lt;br /&gt;
    @caction = &amp;quot;view&amp;quot;&lt;br /&gt;
    @submission = params[:submission]&lt;br /&gt;
    if @submission == &amp;quot;review&amp;quot;&lt;br /&gt;
      @caction = &amp;quot;view_review&amp;quot;&lt;br /&gt;
      @symbol = &amp;quot;review&amp;quot;&lt;br /&gt;
      process_response(&amp;quot;Review&amp;quot;, &amp;quot;Reviewer&amp;quot;, @participant.reviews, &amp;quot;ReviewQuestionnaire&amp;quot;)&lt;br /&gt;
    elsif @submission == &amp;quot;review_of_review&amp;quot;&lt;br /&gt;
      @symbol = &amp;quot;metareview&amp;quot;&lt;br /&gt;
      process_response(&amp;quot;Metareview&amp;quot;, &amp;quot;Metareviewer&amp;quot;, @participant.metareviews, &amp;quot;MetareviewQuestionnaire&amp;quot;)&lt;br /&gt;
    elsif @submission == &amp;quot;review_feedback&amp;quot;&lt;br /&gt;
      @symbol = &amp;quot;feedback&amp;quot;&lt;br /&gt;
      process_response(&amp;quot;Feedback&amp;quot;, &amp;quot;Author&amp;quot;, @participant.feedback, &amp;quot;AuthorFeedbackQuestionnaire&amp;quot;)&lt;br /&gt;
    elsif @submission == &amp;quot;teammate_review&amp;quot;&lt;br /&gt;
      @symbol = &amp;quot;teammate&amp;quot;&lt;br /&gt;
      process_response(&amp;quot;Teammate Review&amp;quot;, &amp;quot;Reviewer&amp;quot;, @participant.teammate_reviews, &amp;quot;TeammateReviewQuestionnaire&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    @subject = &amp;quot; Your &amp;quot;+@collabel.downcase+&amp;quot; score for &amp;quot; + @assignment.name + &amp;quot; conflicts with another &amp;quot;+@rowlabel.downcase+&amp;quot;'s score.&amp;quot;&lt;br /&gt;
    @body = get_body_text(params[:submission])&lt;br /&gt;
  end&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;
  def list_questions (assignment)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
        |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== edit ===&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;
Before:&lt;br /&gt;
    def edit&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = @assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
      |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
    @scores = @participant.scores(@questions)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
    def edit&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    ##################################################################################&lt;br /&gt;
    #	@questions = Hash.new&lt;br /&gt;
    #    questionnaires = assignment.questionnaires&lt;br /&gt;
    #    questionnaires.each {&lt;br /&gt;
    #        |questionnaire|&lt;br /&gt;
    #      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    #    }&lt;br /&gt;
    ##################################################################################&lt;br /&gt;
    #Refactored--&amp;gt; Replaced with a methood call&lt;br /&gt;
    list_questions (@assignment)&lt;br /&gt;
    #################################################################################&lt;br /&gt;
    @scores = @participant.scores(@questions)&lt;br /&gt;
  end&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;
  def list_questions (assignment)&lt;br /&gt;
    @questions = Hash.new&lt;br /&gt;
    questionnaires = assignment.questionnaires&lt;br /&gt;
    questionnaires.each {&lt;br /&gt;
        |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;/div&gt;</summary>
		<author><name>Agohil</name></author>
	</entry>
</feed>