<?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=Sbhawsi</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=Sbhawsi"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Sbhawsi"/>
	<updated>2026-06-03T04:53:59Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95927</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95927"/>
		<updated>2015-03-24T01:16:58Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E1501: Refactoring Assignments.rb==&lt;br /&gt;
This page is about an open source project based on Expertiza OSS. This project aims to refactor assignment.rb which is the largest class in Expertiza. It also aims to refactor other snippets which does not follow the Ruby style guidelines.&lt;br /&gt;
 &lt;br /&gt;
===Refactoring===&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;&amp;lt;b&amp;gt;Refactoring&amp;lt;/b&amp;gt; is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are difficult to read;&lt;br /&gt;
* Programs that does not follow the language specific guidelines;&lt;br /&gt;
* Programs that has high coupling;&lt;br /&gt;
&lt;br /&gt;
=== Introduction to Expertiza ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt;Expertiza is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned and modified from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews.&lt;br /&gt;
&lt;br /&gt;
Assignment.rb is the largest class in Expertiza, comprising 1105 lines of code which contains the assignment model and the related functionalities. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound which can be grouped into smaller, more manageable classes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
*The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores;&lt;br /&gt;
*Moreover, the querying module is database dependent which should be made database independent;&lt;br /&gt;
*There are many function names and code lines which does not follow the ruby guidelines. They should be changed to more ruby like coding style; &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate module scorable.rb===&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://guides.rubyonrails.org/active_record_basics.html ActiveRecord]&amp;lt;/ref&amp;gt;ActiveRecord concern is a pattern introduced in Rails 4.1 to separate the heavy loading done by models. It is recommended that models should be fat and should contain the business logic. This is leads to models getting too coupled. ActiveRecord Concerns solves this problem. Methods which can be logically put together are added in a &amp;lt;ref&amp;gt;[http://rubylearning.com/satishtalim/modules_mixins.html Module/Mixins]&amp;lt;/ref&amp;gt; module/mixin. This mixin is then included in the main model. The mixin can be reused by any other model if required. This makes the code align with Rails philosophy of DRY. In this case all methods related to 'scores' were collaborated together and put inside the mixin scorable.  &lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
*get_scores;&lt;br /&gt;
*get_max_score_possible;&lt;br /&gt;
*compute_reviews_hash;&lt;br /&gt;
*get_average_score;&lt;br /&gt;
&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments reduced significantly. The pull request can be viewed &amp;lt;span class=&amp;quot;plainlinks&amp;quot;&amp;gt; [https://github.com/yatish27/expertiza/commit/ddbd575e6695e8c6b4b6fff8c8aaf814a3981773 here]&amp;lt;/span&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Ruby idiomatic==&lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding was not like ruby like. The ruby community believes in small and well readable code. The code was refactored to be more readable. Many changes were done to the structure of the code to make it more Ruby like. Changes such as removing the return statements, writing .each instead of &amp;quot;for loop&amp;quot;, adding a &amp;quot;?&amp;quot; to name of methods if they return boolean values, indentations and naming conventions were improved. Few of the examples are shown below in raw form as well as Github screenshots:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac.JPG|center]]&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
This refactoring example makes the snippet small and easy to read. It also introduces more Ruby style terms like select and processes like piping instructions.&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Addition of ActiveRecord like Query==&lt;br /&gt;
ActiveRecord provides a layer on top database. Hence if no MYSQL specific query is used in the code it very simple to change the database without changing the code. Using Ruby hash for query rather than raw SQL also helps in keeping the code clean.&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 4: Ruby style guide ==&lt;br /&gt;
&amp;lt;ref&amp;gt;[https://github.com/bbatsov/rubocop Rubocop]&amp;lt;/ref&amp;gt;`Rubocop` was used to check the ruby style guide violations. Most of the Ruby style guide violations in assignment.rb class were fixed.&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac1.JPG|center]]&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 5 : Changing &amp;lt;ref&amp;gt;[http://bundler.io/gemfile.html Gemfile]&amp;lt;/ref&amp;gt;Gemfile==&lt;br /&gt;
&lt;br /&gt;
*Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.;&lt;br /&gt;
*One more gem &amp;lt;ref&amp;gt;[https://github.com/evrone/quiet_assets Quite_assets]&amp;lt;/ref&amp;gt; &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of the asset request. It mutes the asset pipeline log messages. This gem is very helpful during  development.;&lt;br /&gt;
&lt;br /&gt;
* Clean up tests: Few of the controller tests were not in the correct order. We changed them to the right order. &lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
* Feature change was not in the scope of the project. The changes are checking bad code smells and fixing them. The way to verify the changes is to make sure that it works as it was previously. Also, please have a look at the pull request for all the refactor details. You can pull the code with refactored file &amp;lt;span class=&amp;quot;plainlinks&amp;quot;&amp;gt; [https://github.com/yatish27/expertiza here]&amp;lt;/span&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/expertiza/expertiza/pull/510 Expertiza Pull request]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95901</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95901"/>
		<updated>2015-03-24T00:46:25Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E1501: Refactoring Assignments.rb==&lt;br /&gt;
This page is about an open source project based on Expertiza OSS. This project aims to refactor assignment.rb which is the largest class in Expertiza. It also aims to refactor other snippets which does not follow the Ruby style guidelines.&lt;br /&gt;
 &lt;br /&gt;
===Refactoring===&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;&amp;lt;b&amp;gt;Refactoring&amp;lt;/b&amp;gt; is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are difficult to read;&lt;br /&gt;
* Programs that does not follow the language specific guidelines;&lt;br /&gt;
* Programs that has high coupling;&lt;br /&gt;
&lt;br /&gt;
=== Introduction to Expertiza ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt;Expertiza is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned and modified from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews.&lt;br /&gt;
&lt;br /&gt;
Assignment.rb is the largest class in Expertiza, comprising 1105 lines of code which contains the assignment model and the related functionalities. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound which can be grouped into smaller, more manageable classes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
*The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores;&lt;br /&gt;
*Moreover, the querying module is database dependent which should be made database independent;&lt;br /&gt;
*There are many function names and code lines which does not follow the ruby guidelines. They should be changed to more ruby like coding style; &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate module scorable.rb===&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://guides.rubyonrails.org/active_record_basics.html ActiveRecord]&amp;lt;/ref&amp;gt;ActiveRecord concern is a pattern introduced in Rails 4.1 to separate the heavy loading done by models. It is recommended that models should be fat and should contain the business logic. This is leads to models getting too coupled. ActiveRecord Concerns solves this problem. Methods which can be logically put together are added in a &amp;lt;ref&amp;gt;[http://rubylearning.com/satishtalim/modules_mixins.html Module/Mixins]&amp;lt;/ref&amp;gt; module/mixin. This mixin is then included in the main model. The mixin can be reused by any other model if required. This makes the code align with Rails philosophy of DRY. In this case all methods related to 'scores' were collaborated together and put inside the mixin scorable.  &lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
*get_scores;&lt;br /&gt;
*get_max_score_possible;&lt;br /&gt;
*compute_reviews_hash;&lt;br /&gt;
*get_average_score;&lt;br /&gt;
&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments reduced significantly. The pull request can be viewed &amp;lt;span class=&amp;quot;plainlinks&amp;quot;&amp;gt; [https://github.com/yatish27/expertiza/commit/ddbd575e6695e8c6b4b6fff8c8aaf814a3981773 here]&amp;lt;/span&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Ruby idiomatic==&lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding was not like ruby like. The ruby community believes in small and well readable code. The code was refactored to be more readable. Many changes were done to the structure of the code to make it more Ruby like. Changes such as removing the return statements, writing .each instead of &amp;quot;for loop&amp;quot;, adding a &amp;quot;?&amp;quot; to name of methods if they return boolean values, indentations and naming conventions were improved. Few of the examples are shown below in raw form as well as Github screenshots:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac.JPG|center]]&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Addition of ActiveRecord like Query==&lt;br /&gt;
ActiveRecord provides a layer on top database. Hence if no MYSQL specific query is used in the code it very simple to change the database without changing the code. Using Ruby hash for query rather than raw SQL also helps in keeping the code clean.&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 4: Ruby style guide ==&lt;br /&gt;
&amp;lt;ref&amp;gt;[https://github.com/bbatsov/rubocop Rubocop]&amp;lt;/ref&amp;gt;`Rubocop` was used to check the ruby style guide violations. Most of the Ruby style guide violations in assignment.rb class were fixed.&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac1.JPG|center]]&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 5 : Changing &amp;lt;ref&amp;gt;[http://bundler.io/gemfile.html Gemfile]&amp;lt;/ref&amp;gt;Gemfile==&lt;br /&gt;
&lt;br /&gt;
*Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.;&lt;br /&gt;
*One more gem &amp;lt;ref&amp;gt;[https://github.com/evrone/quiet_assets Quite_assets]&amp;lt;/ref&amp;gt; &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of the asset request. It mutes the asset pipeline log messages. This gem is very helpful during  development.;&lt;br /&gt;
&lt;br /&gt;
* Clean up tests: Few of the controller tests were not in the correct order. We changed them to the right order. &lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
* Feature change was not in the scope of the project. The changes are checking bad code smells and fixing them. The way to verify the changes is to make sure that it works as it was previously. Also, please have a look at the pull request for all the refactor details. You can pull the code with refactored file &amp;lt;span class=&amp;quot;plainlinks&amp;quot;&amp;gt; [https://github.com/yatish27/expertiza here]&amp;lt;/span&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/expertiza/expertiza/pull/510 Expertiza Pull request]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95898</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95898"/>
		<updated>2015-03-24T00:42:14Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E1501: Refactoring Assignments.rb==&lt;br /&gt;
===Refactoring===&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;&amp;lt;b&amp;gt;Refactoring&amp;lt;/b&amp;gt; is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are difficult to read;&lt;br /&gt;
* Programs that does not follow the language specific guidelines;&lt;br /&gt;
* Programs that has high coupling;&lt;br /&gt;
&lt;br /&gt;
=== Introduction to Expertiza ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt;Expertiza is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned and modified from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews.&lt;br /&gt;
&lt;br /&gt;
Assignment.rb is the largest class in Expertiza, comprising 1105 lines of code which contains the assignment model and the related functionalities. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound which can be grouped into smaller, more manageable classes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
*The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores;&lt;br /&gt;
*Moreover, the querying module is database dependent which should be made database independent;&lt;br /&gt;
*There are many function names and code lines which does not follow the ruby guidelines. They should be changed to more ruby like coding style; &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate module scorable.rb===&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://guides.rubyonrails.org/active_record_basics.html ActiveRecord]&amp;lt;/ref&amp;gt;ActiveRecord concern is a pattern introduced in Rails 4.1 to separate the heavy loading done by models. It is recommended that models should be fat and should contain the business logic. This is leads to models getting too coupled. ActiveRecord Concerns solves this problem. Methods which can be logically put together are added in a &amp;lt;ref&amp;gt;[http://rubylearning.com/satishtalim/modules_mixins.html Module/Mixins]&amp;lt;/ref&amp;gt; module/mixin. This mixin is then included in the main model. The mixin can be reused by any other model if required. This makes the code align with Rails philosophy of DRY. In this case all methods related to 'scores' were collaborated together and put inside the mixin scorable.  &lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
*get_scores;&lt;br /&gt;
*get_max_score_possible;&lt;br /&gt;
*compute_reviews_hash;&lt;br /&gt;
*get_average_score;&lt;br /&gt;
&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments reduced significantly. The pull request can be viewed &amp;lt;span class=&amp;quot;plainlinks&amp;quot;&amp;gt; [https://github.com/yatish27/expertiza/commit/ddbd575e6695e8c6b4b6fff8c8aaf814a3981773 here]&amp;lt;/span&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Ruby idiomatic==&lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding was not like ruby like. The ruby community believes in small and well readable code. The code was refactored to be more readable. Many changes were done to the structure of the code to make it more Ruby like. Changes such as removing the return statements, writing .each instead of &amp;quot;for loop&amp;quot;, adding a &amp;quot;?&amp;quot; to name of methods if they return boolean values, indentations and naming conventions were improved. Few of the examples are shown below in raw form as well as Github screenshots:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac.JPG|center]]&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Addition of ActiveRecord like Query==&lt;br /&gt;
ActiveRecord provides a layer on top database. Hence if no MYSQL specific query is used in the code it very simple to change the database without changing the code. Using Ruby hash for query rather than raw SQL also helps in keeping the code clean.&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 4: Ruby style guide ==&lt;br /&gt;
&amp;lt;ref&amp;gt;[https://github.com/bbatsov/rubocop Rubocop]&amp;lt;/ref&amp;gt;`Rubocop` was used to check the ruby style guide violations. Most of the Ruby style guide violations in assignment.rb class were fixed.&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac1.JPG|center]]&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 5 : Changing &amp;lt;ref&amp;gt;[http://bundler.io/gemfile.html Gemfile]&amp;lt;/ref&amp;gt;Gemfile==&lt;br /&gt;
&lt;br /&gt;
*Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.;&lt;br /&gt;
*One more gem &amp;lt;ref&amp;gt;[https://github.com/evrone/quiet_assets Quite_assets]&amp;lt;/ref&amp;gt; &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of the asset request. It mutes the asset pipeline log messages. This gem is very helpful during  development.;&lt;br /&gt;
&lt;br /&gt;
* Clean up tests: Few of the controller tests were not in the correct order. We changed them to the right order. &lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
* Feature change was not in the scope of the project. The changes are checking bad code smells and fixing them. The way to verify the changes is to make sure that it works as it was previously. Also, please have a look at the pull request for all the refactor details. You can pull the code with refactored file &amp;lt;span class=&amp;quot;plainlinks&amp;quot;&amp;gt; [https://github.com/yatish27/expertiza here]&amp;lt;/span&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/expertiza/expertiza/pull/510 Expertiza Pull request]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95897</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95897"/>
		<updated>2015-03-24T00:41:42Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E1501: Refactoring Assignments.rb==&lt;br /&gt;
===Refactoring===&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;&amp;lt;b&amp;gt;Refactoring&amp;lt;/b&amp;gt; is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are difficult to read;&lt;br /&gt;
* Programs that does not follow the language specific guidelines;&lt;br /&gt;
* Programs that has high coupling;&lt;br /&gt;
&lt;br /&gt;
=== Introduction to Expertiza ===&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt;Expertiza is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned and modified from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews.&lt;br /&gt;
&lt;br /&gt;
Assignment.rb is the largest class in Expertiza, comprising 1105 lines of code which contains the assignment model and the related functionalities. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound which can be grouped into smaller, more manageable classes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
*The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores;&lt;br /&gt;
*Moreover, the querying module is database dependent which should be made database independent;&lt;br /&gt;
*There are many function names and code lines which does not follow the ruby guidelines. They should be changed to more ruby like coding style; &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate module scorable.rb===&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://guides.rubyonrails.org/active_record_basics.html ActiveRecord]&amp;lt;/ref&amp;gt;ActiveRecord concern is a pattern introduced in Rails 4.1 to separate the heavy loading done by models. It is recommended that models should be fat and should contain the business logic. This is leads to models getting too coupled. ActiveRecord Concerns solves this problem. Methods which can be logically put together are added in a &amp;lt;ref&amp;gt;[http://rubylearning.com/satishtalim/modules_mixins.html Module/Mixins]&amp;lt;/ref&amp;gt; module/mixin. This mixin is then included in the main model. The mixin can be reused by any other model if required. This makes the code align with Rails philosophy of DRY. In this case all methods related to 'scores' were collaborated together and put inside the mixin scorable.  &lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
*get_scores;&lt;br /&gt;
*get_max_score_possible;&lt;br /&gt;
*compute_reviews_hash;&lt;br /&gt;
*get_average_score;&lt;br /&gt;
&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments reduced significantly. The pull request can be viewed &amp;lt;span class=&amp;quot;plainlinks&amp;quot;&amp;gt; [https://github.com/yatish27/expertiza/commit/ddbd575e6695e8c6b4b6fff8c8aaf814a3981773 here]&amp;lt;/span&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Ruby idiomatic==&lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding was not like ruby like. The ruby community believes in small and well readable code. The code was refactored to be more readable. Many changes were done to the structure of the code to make it more Ruby like. Changes such as removing the return statements, writing .each instead of &amp;quot;for loop&amp;quot;, adding a &amp;quot;?&amp;quot; to name of methods if they return boolean values, indentations and naming conventions were improved. Few of the examples are shown below in raw form as well as Github screenshots:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac.JPG|center]]&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Addition of ActiveRecord like Query==&lt;br /&gt;
ActiveRecord provides a layer on top database. Hence if no MYSQL specific query is used in the code it very simple to change the database without changing the code. Using Ruby hash for query rather than raw SQL also helps in keeping the code clean.&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 4: Ruby style guide ==&lt;br /&gt;
&amp;lt;ref&amp;gt;[https://github.com/bbatsov/rubocop Rubocop]&amp;lt;/ref&amp;gt;`Rubocop` was used to check the ruby style guide violations. Most of the Ruby style guide violations in assignment.rb class were fixed.&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac1.JPG|center]]&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 5 : Changing &amp;lt;ref&amp;gt;[http://bundler.io/gemfile.html Gemfile]&amp;lt;/ref&amp;gt;Gemfile==&lt;br /&gt;
&lt;br /&gt;
*Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.;&lt;br /&gt;
*One more gem &amp;lt;ref&amp;gt;[https://github.com/evrone/quiet_assets Quite_assets]&amp;lt;/ref&amp;gt; &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of the asset request. It mutes the asset pipeline log messages. This gem is very helpful during  development.;&lt;br /&gt;
&lt;br /&gt;
* Clean up tests: Few of the controller tests were not in the correct order. We changed them to the right order. &lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
* Feature change was not in the scope of the project. The changes are checking bad code smells and fixing them. The way to verify the changes is to make sure that it works as it was previously. Also, please have a look at the pull request for all the refactor details. You can pull the code with refactored file &amp;lt;span class=&amp;quot;plainlinks&amp;quot;&amp;gt; [https://github.com/yatish27/expertiza here]&amp;lt;/span&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/expertiza/expertiza/pull/510 Expertiza Pull request]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95895</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95895"/>
		<updated>2015-03-24T00:40:32Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;&amp;lt;b&amp;gt;Refactoring&amp;lt;/b&amp;gt; is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are difficult to read;&lt;br /&gt;
* Programs that does not follow the language specific guidelines;&lt;br /&gt;
* Programs that has high coupling;&lt;br /&gt;
&lt;br /&gt;
''' Introduction to Expertiza '''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt;Expertiza is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned and modified from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews.&lt;br /&gt;
&lt;br /&gt;
Assignment.rb is the largest class in Expertiza, comprising 1105 lines of code which contains the assignment model and the related functionalities. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound which can be grouped into smaller, more manageable classes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
*The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores;&lt;br /&gt;
*Moreover, the querying module is database dependent which should be made database independent;&lt;br /&gt;
*There are many function names and code lines which does not follow the ruby guidelines. They should be changed to more ruby like coding style; &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate module scorable.rb===&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://guides.rubyonrails.org/active_record_basics.html ActiveRecord]&amp;lt;/ref&amp;gt;ActiveRecord concern is a pattern introduced in Rails 4.1 to separate the heavy loading done by models. It is recommended that models should be fat and should contain the business logic. This is leads to models getting too coupled. ActiveRecord Concerns solves this problem. Methods which can be logically put together are added in a &amp;lt;ref&amp;gt;[http://rubylearning.com/satishtalim/modules_mixins.html Module/Mixins]&amp;lt;/ref&amp;gt; module/mixin. This mixin is then included in the main model. The mixin can be reused by any other model if required. This makes the code align with Rails philosophy of DRY. In this case all methods related to 'scores' were collaborated together and put inside the mixin scorable.  &lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
*get_scores;&lt;br /&gt;
*get_max_score_possible;&lt;br /&gt;
*compute_reviews_hash;&lt;br /&gt;
*get_average_score;&lt;br /&gt;
&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments reduced significantly. The pull request can be viewed &amp;lt;span class=&amp;quot;plainlinks&amp;quot;&amp;gt; [https://github.com/yatish27/expertiza/commit/ddbd575e6695e8c6b4b6fff8c8aaf814a3981773 here]&amp;lt;/span&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Ruby idiomatic==&lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding was not like ruby like. The ruby community believes in small and well readable code. The code was refactored to be more readable. Many changes were done to the structure of the code to make it more Ruby like. Changes such as removing the return statements, writing .each instead of &amp;quot;for loop&amp;quot;, adding a &amp;quot;?&amp;quot; to name of methods if they return boolean values, indentations and naming conventions were improved. Few of the examples are shown below in raw form as well as Github screenshots:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac.JPG|center]]&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Addition of ActiveRecord like Query==&lt;br /&gt;
ActiveRecord provides a layer on top database. Hence if no MYSQL specific query is used in the code it very simple to change the database without changing the code. Using Ruby hash for query rather than raw SQL also helps in keeping the code clean.&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 4: Ruby style guide ==&lt;br /&gt;
&amp;lt;ref&amp;gt;[https://github.com/bbatsov/rubocop Rubocop]&amp;lt;/ref&amp;gt;`Rubocop` was used to check the ruby style guide violations. Most of the Ruby style guide violations in assignment.rb class were fixed.&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac1.JPG|center]]&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 5 : Changing &amp;lt;ref&amp;gt;[http://bundler.io/gemfile.html Gemfile]&amp;lt;/ref&amp;gt;Gemfile==&lt;br /&gt;
&lt;br /&gt;
*Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.;&lt;br /&gt;
*One more gem &amp;lt;ref&amp;gt;[https://github.com/evrone/quiet_assets Quite_assets]&amp;lt;/ref&amp;gt; &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of the asset request. It mutes the asset pipeline log messages. This gem is very helpful during  development.;&lt;br /&gt;
&lt;br /&gt;
* Clean up tests: Few of the controller tests were not in the correct order. We changed them to the right order. &lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
* Feature change was not in the scope of the project. The changes are checking bad code smells and fixing them. The way to verify the changes is to make sure that it works as it was previously. Also, please have a look at the pull request for all the refactor details. You can pull the code with refactored file &amp;lt;span class=&amp;quot;plainlinks&amp;quot;&amp;gt; [https://github.com/yatish27/expertiza here]&amp;lt;/span&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/expertiza/expertiza/pull/510 Expertiza Pull request]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95883</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95883"/>
		<updated>2015-03-24T00:36:06Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;&amp;lt;b&amp;gt;Refactoring&amp;lt;/b&amp;gt; is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are difficult to read;&lt;br /&gt;
* Programs that does not follow the language specific guidelines;&lt;br /&gt;
* Programs that has high coupling;&lt;br /&gt;
&lt;br /&gt;
''' Introduction to Expertiza '''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt;Expertiza is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned and modified from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews.&lt;br /&gt;
&lt;br /&gt;
Assignment.rb is the largest class in Expertiza, comprising 1105 lines of code which contains the assignment model and the related functionalities. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound which can be grouped into smaller, more manageable classes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
*The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores;&lt;br /&gt;
*Moreover, the querying module is database dependent which should be made database independent;&lt;br /&gt;
*There are many function names and code lines which does not follow the ruby guidelines. They should be changed to more ruby like coding style; &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate module scorable.rb===&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://guides.rubyonrails.org/active_record_basics.html ActiveRecord]&amp;lt;/ref&amp;gt;ActiveRecord concern is a pattern introduced in Rails 4.1 to separate the heavy loading done by models. It is recommended that models should be fat and should contain the business logic. This is leads to models getting too coupled. ActiveRecord Concerns solves this problem. Methods which can be logically put together are added in a &amp;lt;ref&amp;gt;[http://rubylearning.com/satishtalim/modules_mixins.html Module/Mixins]&amp;lt;/ref&amp;gt; module/mixin. This mixin is then included in the main model. The mixin can be reused by any other model if required. This makes the code align with Rails philosophy of DRY. In this case all methods related to 'scores' were collaborated together and put inside the mixin scorable.  &lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
*get_scores;&lt;br /&gt;
*get_max_score_possible;&lt;br /&gt;
*compute_reviews_hash;&lt;br /&gt;
*get_average_score;&lt;br /&gt;
&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments reduced significantly. The pull request can be viewed &amp;lt;span class=&amp;quot;plainlinks&amp;quot;&amp;gt; [https://github.com/yatish27/expertiza/commit/ddbd575e6695e8c6b4b6fff8c8aaf814a3981773 here]&amp;lt;/span&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Ruby idiomatic==&lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding was not like ruby like. The ruby community believes in small and well readable code. The code was refactored to be more readable. Many changes were done to the structure of the code to make it more Ruby like. Changes such as removing the return statements, writing .each instead of &amp;quot;for loop&amp;quot;, adding a &amp;quot;?&amp;quot; to name of methods if they return boolean values, indentations and naming conventions were improved. Few of the examples are shown below in raw form as well as Github screenshots:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac.JPG|center]]&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Addition of ActiveRecord like Query==&lt;br /&gt;
ActiveRecord provides a layer on top database. Hence if no MYSQL specific query is used in the code it very simple to change the database without changing the code. Using Ruby hash for query rather than raw SQL also helps in keeping the code clean.&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 4: Ruby style guide ==&lt;br /&gt;
&amp;lt;ref&amp;gt;[https://github.com/bbatsov/rubocop Rubocop]&amp;lt;/ref&amp;gt;`Rubocop` was used to check the ruby style guide violations. Most of the Ruby style guide violations in assignment.rb class were fixed.&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac1.JPG|center]]&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 5 : Changing &amp;lt;ref&amp;gt;[http://bundler.io/gemfile.html Gemfile]&amp;lt;/ref&amp;gt;Gemfile==&lt;br /&gt;
&lt;br /&gt;
*Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.;&lt;br /&gt;
*One more gem &amp;lt;ref&amp;gt;[https://github.com/evrone/quiet_assets Quite_assets]&amp;lt;/ref&amp;gt; &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of the asset request. It mutes the asset pipeline log messages. This gem is very helpful during  development.;&lt;br /&gt;
&lt;br /&gt;
* Clean up tests: Few of the controller tests were not in the correct order. We changed them to the right order. &lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
* Feature change was not in the scope of the project. The changes are checking bad code smells and fixing them. The way to verify the changes is to make sure that it works as it was previously. Also, please have a look at the pull request for all the refactor details. You can pull the code with refactored file &amp;lt;span class=&amp;quot;plainlinks&amp;quot;&amp;gt; [https://github.com/yatish27/expertiza here]&amp;lt;/span&amp;gt;..&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/expertiza/expertiza/pull/510 Expertiza Pull request]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95877</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95877"/>
		<updated>2015-03-24T00:32:22Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;&amp;lt;b&amp;gt;Refactoring&amp;lt;/b&amp;gt; is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are difficult to read;&lt;br /&gt;
* Programs that does not follow the language specific guidelines;&lt;br /&gt;
* Programs that has high coupling;&lt;br /&gt;
&lt;br /&gt;
''' Introduction to Expertiza '''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt;Expertiza is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned and modified from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews.&lt;br /&gt;
&lt;br /&gt;
Assignment.rb is the largest class in Expertiza, comprising 1105 lines of code which contains the assignment model and the related functionalities. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound which can be grouped into smaller, more manageable classes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
*The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores;&lt;br /&gt;
*Moreover, the querying module is database dependent which should be made database independent;&lt;br /&gt;
*There are many function names and code lines which does not follow the ruby guidelines. They should be changed to more ruby like coding style; &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate module scorable.rb===&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://guides.rubyonrails.org/active_record_basics.html ActiveRecord]&amp;lt;/ref&amp;gt;ActiveRecord concern is a pattern introduced in Rails 4.1 to separate the heavy loading done by models. It is recommended that models should be fat and should contain the business logic. This is leads to models getting too coupled. ActiveRecord Concerns solves this problem. Methods which can be logically put together are added in a &amp;lt;ref&amp;gt;[http://rubylearning.com/satishtalim/modules_mixins.html Module/Mixins]&amp;lt;/ref&amp;gt; module/mixin. This mixin is then included in the main model. The mixin can be reused by any other model if required. This makes the code align with Rails philosophy of DRY. In this case all methods related to 'scores' were collaborated together and put inside the mixin scorable.  &lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
*get_scores;&lt;br /&gt;
*get_max_score_possible;&lt;br /&gt;
*compute_reviews_hash;&lt;br /&gt;
*get_average_score;&lt;br /&gt;
&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments reduced significantly. The pull request can be viewed &amp;lt;span class=&amp;quot;plainlinks&amp;quot;&amp;gt; [https://github.com/yatish27/expertiza/commit/ddbd575e6695e8c6b4b6fff8c8aaf814a3981773 here]&amp;lt;/span&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Ruby idiomatic==&lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding was not like ruby like. The ruby community believes in small and well readable code. The code was refactored to be more readable. Many changes were done to the structure of the code to make it more Ruby like. Changes such as removing the return statements, writing .each instead of &amp;quot;for loop&amp;quot;, adding a &amp;quot;?&amp;quot; to name of methods if they return boolean values, indentations and naming conventions were improved. Few of the examples are shown below in raw form as well as Github screenshots:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac.JPG|center]]&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Addition of ActiveRecord like Query==&lt;br /&gt;
ActiveRecord provides a layer on top database. Hence if no MYSQL specific query is used in the code it very simple to change the database without changing the code. Using Ruby hash for query rather than raw SQL also helps in keeping the code clean.&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 4: Ruby style guide ==&lt;br /&gt;
&amp;lt;ref&amp;gt;[https://github.com/bbatsov/rubocop Rubocop]&amp;lt;/ref&amp;gt;`Rubocop` was used to check the ruby style guide violations. Most of the Ruby style guide violations in assignment.rb class were fixed.&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac1.JPG|center]]&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 5 : Changing &amp;lt;ref&amp;gt;[http://bundler.io/gemfile.html Gemfile]&amp;lt;/ref&amp;gt;Gemfile==&lt;br /&gt;
&lt;br /&gt;
*Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.;&lt;br /&gt;
*One more gem &amp;lt;ref&amp;gt;[https://github.com/evrone/quiet_assets Quite_assets]&amp;lt;/ref&amp;gt; &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of the asset request. It mutes the asset pipeline log messages. This gem is very helpful during  development.;&lt;br /&gt;
&lt;br /&gt;
* Clean up tests: Few of the controller tests were not in the correct order.  &lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
* Feature change was not in the scope of the project. The changes are checking bad code smells and fixing them. The way to verify the changes is to make sure that it works as it was previously.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/expertiza/expertiza/pull/510 Expertiza Pull request]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95873</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95873"/>
		<updated>2015-03-24T00:28:03Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;&amp;lt;b&amp;gt;Refactoring&amp;lt;/b&amp;gt; is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are difficult to read;&lt;br /&gt;
* Programs that does not follow the language specific guidelines;&lt;br /&gt;
* Programs that has high coupling;&lt;br /&gt;
&lt;br /&gt;
''' Introduction to Expertiza '''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt;Expertiza is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned and modified from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews.&lt;br /&gt;
&lt;br /&gt;
Assignment.rb is the largest class in Expertiza, comprising 1105 lines of code which contains the assignment model and the related functionalities. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound which can be grouped into smaller, more manageable classes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
*The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores;&lt;br /&gt;
*Moreover, the querying module is database dependent which should be made database independent;&lt;br /&gt;
*There are many function names and code lines which does not follow the ruby guidelines. They should be changed to more ruby like coding style; &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate module scorable.rb===&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://guides.rubyonrails.org/active_record_basics.html ActiveRecord]&amp;lt;/ref&amp;gt;ActiveRecord concern is a pattern introduced in Rails 4.1 to separate the heavy loading done by models. It is recommended that models should be fat and should contain the business logic. This is leads to models getting too coupled. ActiveRecord Concerns solves this problem. Methods which can be logically put together are added in a &amp;lt;ref&amp;gt;[http://rubylearning.com/satishtalim/modules_mixins.html Module/Mixins]&amp;lt;/ref&amp;gt; module/mixin. This mixin is then included in the main model. The mixin can be reused by any other model if required. This makes the code align with Rails philosophy of DRY. In this case all methods related to 'scores' were collaborated together and put inside the mixin scorable.  &lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
*get_scores;&lt;br /&gt;
*get_max_score_possible;&lt;br /&gt;
*compute_reviews_hash;&lt;br /&gt;
*get_average_score;&lt;br /&gt;
&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments reduced significantly. The pull request can be viewed &amp;lt;span class=&amp;quot;plainlinks&amp;quot;&amp;gt; [https://github.com/yatish27/expertiza/commit/ddbd575e6695e8c6b4b6fff8c8aaf814a3981773 here]&amp;lt;/span&amp;gt; here.&lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Ruby idiomatic==&lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding was not like ruby like. The ruby community believes in small, well readable code. The code was refactored to be more readable. Many changes were done to the structure of the code to make it more Ruby like. Changes such as removing the return statements, writing .each instead of &amp;quot;for loop&amp;quot;, adding a &amp;quot;?&amp;quot; to names of methods if they return boolean values, indentations and naming conventions were improved. Few of the examples are shown below in raw form as well as Github screenshots:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac.JPG|center]]&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Addition of ActiveRecord like Query==&lt;br /&gt;
ActiveRecord provides a layer on top database. Hence if no MYSQL specific query is used in the code it very simple to change the database without changing the code. Using Ruby hash for query rather than raw SQL also helps in keeping the code clean.&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 4: Ruby style guide ==&lt;br /&gt;
&amp;lt;ref&amp;gt;[https://github.com/bbatsov/rubocop Rubocop]&amp;lt;/ref&amp;gt;`Rubocop` was used to check the ruby style guide violations. Most of the Ruby style guide violations in assignment.rb class were fixed.&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac1.JPG|center]]&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 5 : Changing &amp;lt;ref&amp;gt;[http://bundler.io/gemfile.html Gemfile]&amp;lt;/ref&amp;gt;Gemfile==&lt;br /&gt;
&lt;br /&gt;
*Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.;&lt;br /&gt;
*One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of the asset request. This is very helpful during  development.;&lt;br /&gt;
&lt;br /&gt;
* Clean up tests: Few of the controller tests were not in the correct order.  &lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
* Feature change was not in the scope of the project. The changes are checking bad code smells and fixing them. The way to verify the changes is to make sure that it works as it was previously.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/expertiza/expertiza/pull/510 Expertiza Pull request]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95870</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95870"/>
		<updated>2015-03-24T00:22:55Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;&amp;lt;b&amp;gt;Refactoring&amp;lt;/b&amp;gt; is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are difficult to read;&lt;br /&gt;
* Programs that does not follow the language specific guidelines;&lt;br /&gt;
* Programs that has high coupling;&lt;br /&gt;
&lt;br /&gt;
''' Introduction to Expertiza '''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt;Expertiza is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned and modified from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews.&lt;br /&gt;
&lt;br /&gt;
Assignment.rb is the largest class in Expertiza, comprising 1105 lines of code which contains the assignment model and the related functionalities. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound which can be grouped into smaller, more manageable classes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
*The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores;&lt;br /&gt;
*Moreover, the querying module is database dependent which should be made database independent;&lt;br /&gt;
*There are many function names and code lines which does not follow the ruby guidelines. They should be changed to more ruby like coding style; &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate module scorable.rb===&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://guides.rubyonrails.org/active_record_basics.html ActiveRecord]&amp;lt;/ref&amp;gt;ActiveRecord concern is a pattern introduced in Rails 4.1 to separate the heavy loading done by models. It is recommended that models should be fat and should contain the business logic. This is leads to models getting too coupled. ActiveRecord Concerns solves this problem. Methods which can be logically put together are added in a &amp;lt;ref&amp;gt;[http://rubylearning.com/satishtalim/modules_mixins.html Module/Mixins]&amp;lt;/ref&amp;gt; module/mixin. This mixin is then included in the main model. The mixin can be reused by any other model if required. This makes the code align with Rails philosophy of DRY. In this case all methods related to 'scores' were collaborated together and put inside the mixin scorable.  &lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
*get_scores;&lt;br /&gt;
*get_max_score_possible;&lt;br /&gt;
*compute_reviews_hash;&lt;br /&gt;
*get_average_score;&lt;br /&gt;
&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments reduced significantly. &lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Ruby idiomatic==&lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding was not like ruby like. The ruby community believes in small, well readable code. The code was refactored to be more readable. Changes such as removing the return statements, writing .each instead of &amp;quot;for loop&amp;quot; and naming conventions were improved. Few of the examples are given below:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac.JPG|center]]&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Addition of ActiveRecord like Query==&lt;br /&gt;
ActiveRecord provides a layer on top database. Hence if no MYSQL specific query is used in the code it very simple to change the database without changing the code. Using Ruby hash for query rather than raw SQL also helps in keeping the code clean.&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 4: Ruby style guide ==&lt;br /&gt;
&amp;lt;ref&amp;gt;[https://github.com/bbatsov/rubocop Rubocop]&amp;lt;/ref&amp;gt;`Rubocop` was used to check the ruby style guide violations. Most of the Ruby style guide violations in assignment.rb class were fixed.&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac1.JPG|center]]&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 5 : Changing &amp;lt;ref&amp;gt;[http://bundler.io/gemfile.html Gemfile]&amp;lt;/ref&amp;gt;Gemfile==&lt;br /&gt;
&lt;br /&gt;
*Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.;&lt;br /&gt;
*One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of the asset request. This is very helpful during  development.;&lt;br /&gt;
&lt;br /&gt;
* Clean up tests: Few of the controller tests were not in the correct order.  &lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
* Feature change was not in the scope of the project. The changes are checking bad code smells and fixing them. The way to verify the changes is to make sure that it works as it was previously.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/expertiza/expertiza/pull/510 Expertiza Pull request]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95866</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95866"/>
		<updated>2015-03-24T00:15:25Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;&amp;lt;b&amp;gt;Refactoring&amp;lt;/b&amp;gt; is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are difficult to read;&lt;br /&gt;
* Programs that does not follow the language specific guidelines;&lt;br /&gt;
* Programs that has high coupling;&lt;br /&gt;
&lt;br /&gt;
''' Introduction to Expertiza '''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt;Expertiza is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned and modified from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews.&lt;br /&gt;
&lt;br /&gt;
Assignment.rb is the largest class in Expertiza, comprising 1105 lines of code which contains the assignment model and the related functionalities. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound which can be grouped into smaller, more manageable classes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
*The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores;&lt;br /&gt;
*Moreover, the querying module is database dependent which should be made database independent;&lt;br /&gt;
*There are many function names and code lines which does not follow the ruby guidelines. They should be changed to more ruby like coding style; &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate module scorable.rb===&lt;br /&gt;
AvtiveRecord Concern is pattern introduced in Rails 4.1 to seperate the heavy loading done by models. It is recommended that models should be fat and should contain the business logic. This is leads to models getting too coupled. ActiveRecord Concerns solves this problem. Methods which can be logically put together are added in a module/mixin. This mixin is then included in the main model. The mixin can be reused by any other model if required. This makes the code align with Rails philosophy of DRY. In this case all methods related to 'scores' were collaborated together and put inside the mixin scorable.  &lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
*get_scores;&lt;br /&gt;
*get_max_score_possible;&lt;br /&gt;
*compute_reviews_hash;&lt;br /&gt;
*get_average_score;&lt;br /&gt;
&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments reduced significantly. &lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Ruby idiomatic==&lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding was not like ruby like. The ruby community believes in small, well readable code. The code was refactored to be more readable. Changes such as removing the return statements, writing .each instead of &amp;quot;for loop&amp;quot; and naming conventions were improved. Few of the examples are given below:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac.JPG|center]]&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Addition of ActiveRecord like Query==&lt;br /&gt;
ActiveRecord provides a layer on top database. Hence if no MYSQL specific query is used in the code it very simple to change the database without changing the code. Using Ruby hash for query rather than raw SQL also helps in keeping the code clean.&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 4: Ruby style guide ==&lt;br /&gt;
&amp;lt;ref&amp;gt;[https://github.com/bbatsov/rubocop Rubocop]&amp;lt;/ref&amp;gt;`Rubocop` was used to check the ruby style guide violations. Most of the Ruby style guide violations in assignment.rb class were fixed.&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac1.JPG|center]]&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 5 : Changing &amp;lt;ref&amp;gt;[http://bundler.io/gemfile.html Gemfile]&amp;lt;/ref&amp;gt;Gemfile==&lt;br /&gt;
&lt;br /&gt;
*Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.;&lt;br /&gt;
*One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of the asset request. This is very helpful during  development.;&lt;br /&gt;
&lt;br /&gt;
* Clean up tests: Few of the controller tests were not in the correct order.  &lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
* Feature change was not in the scope of the project. The changes are checking bad code smells and fixing them. The way to verify the changes is to make sure that it works as it was previously.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/expertiza/expertiza/pull/510 Expertiza Pull request]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95862</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95862"/>
		<updated>2015-03-24T00:08:25Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;&amp;lt;b&amp;gt;Refactoring&amp;lt;/b&amp;gt; is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are difficult to read;&lt;br /&gt;
* Programs that does not follow the language specific guidelines;&lt;br /&gt;
* Programs that has high coupling;&lt;br /&gt;
&lt;br /&gt;
''' Introduction to Expertiza '''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt;Expertiza is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned and modified from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews.&lt;br /&gt;
&lt;br /&gt;
Assignment.rb is the largest class in Expertiza, comprising 1105 lines of code which contains the assignment model and the related functionalities. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound which can be grouped into smaller, more manageable classes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
*The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores;&lt;br /&gt;
*Moreover, the querying module is database dependent which should be made database independent;&lt;br /&gt;
*There are many function names and code lines which does not follow the ruby guidelines. They should be changed to more ruby like coding style; &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate module scorable.rb===&lt;br /&gt;
AvtiveRecord Concern is pattern introduced in Rails 4.1 to seperate the heavy loading done by models. It is recommended that models should be fat and should contain the business logic. This is leads to models getting too coupled. ActiveRecord Concerns solves this problem. Methods which can be logically put together are added in a module/mixin. This mixin is then included in the main model. The mixin can be reused by any other model if required. This makes the code align with Rails philosophy of DRY. In this case all methods related to 'scores' were collaborated together and put inside the mixin scorable.  &lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
*get_scores;&lt;br /&gt;
*get_max_score_possible;&lt;br /&gt;
*compute_reviews_hash;&lt;br /&gt;
*get_average_score;&lt;br /&gt;
&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Ruby idiomatic==&lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding was not like ruby like. The ruby community believes in small, well readable code. The code was refactored to be more readable. Changes such as removing the return statements, writing .each instead of for loop and improving naming conventions were implemented. Few of the examples are given below:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac.JPG|center]]&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Addition of ActiveRecord like Query==&lt;br /&gt;
ActiveRecord provides a layer on top database. Hence if no Mysql specific query is used in the code it very simple to change the database without changing the code. Using Ruby hash for query rather than raw sql also helps in keeping the code clean&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 4: Ruby style guide ==&lt;br /&gt;
We used `rubocop` to check the ruby style guide violations. We fixed most of the Ruby style guide violations in that class.&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac1.JPG|center]]&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 5 : Changing &amp;lt;ref&amp;gt;[http://bundler.io/gemfile.html Gemfile]&amp;lt;/ref&amp;gt;Gemfile==&lt;br /&gt;
&lt;br /&gt;
*Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.; The older version was not compatible with ruby 2.2.0&lt;br /&gt;
&lt;br /&gt;
*One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of the asset request. This is very helpful during  development.;&lt;br /&gt;
&lt;br /&gt;
* Clean up tests: few of the controller tests were not in the correct order.  &lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
* We have not made any changes in the features of Expertiza. The changes are checking bad code smells and fixing them. The way to verify the changes is to make sure that it works as it was previously.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/expertiza/expertiza/pull/510 Expertiza Pull request]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95855</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95855"/>
		<updated>2015-03-24T00:02:56Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;Refactoring is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are difficult to read;&lt;br /&gt;
* Programs that does not follow the language specific guidelines;&lt;br /&gt;
* Programs that has high coupling;&lt;br /&gt;
&lt;br /&gt;
''' Introduction to Expertiza '''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt;Expertiza is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned and modified from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews.&lt;br /&gt;
&lt;br /&gt;
Assignment.rb is the largest class in Expertiza, comprising 1105 lines of code which contains the assignment model and the related functionalities. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound which can be grouped into smaller, more manageable classes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
*The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores;&lt;br /&gt;
*Moreover, the querying module is database dependent which should be made database independent;&lt;br /&gt;
*There are many function names and code lines which does not follow the ruby guidelines. They should be changed to more ruby like coding style; &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate module scorable.rb===&lt;br /&gt;
AvtiveRecord Concern is pattern introduced in Rails 4.1 to seperate the heavy loading done by models. It is recommended that models should be fat and should contain the business logic. This is leads to models getting too coupled. ActiveRecord Concerns solves this problem. Methods which can be logically put together are added in a module/mixin. This mixin is then included in the main model. The mixin can be reused by any other model if required. This makes the code align with Rails philosophy of DRY. In this case all methods related to 'scores' were collaborated together and put inside the mixin scorable.  &lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
*get_scores;&lt;br /&gt;
*get_max_score_possible;&lt;br /&gt;
*compute_reviews_hash;&lt;br /&gt;
*get_average_score;&lt;br /&gt;
&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Ruby idiomatic==&lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding was not like ruby like. The ruby community believes in small, well readable code. The code was refactored to be more readable. Changes such as removing the return statements, writing .each instead of for loop and improving naming conventions were implemented. Few of the examples are given below:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac.JPG|center]]&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Addition of ActiveRecord like Query==&lt;br /&gt;
ActiveRecord provides a layer on top database. Hence if no Mysql specific query is used in the code it very simple to change the database without changing the code. Using Ruby hash for query rather than raw sql also helps in keeping the code clean&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 4: Ruby style guide ==&lt;br /&gt;
We used `rubocop` to check the ruby style guide violations. We fixed most of the Ruby style guide violations in that class.&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac1.JPG|center]]&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 5 : Changing &amp;lt;ref&amp;gt;[http://bundler.io/gemfile.html Gemfile]&amp;lt;/ref&amp;gt;Gemfile==&lt;br /&gt;
&lt;br /&gt;
*Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.; The older version was not compatible with ruby 2.2.0&lt;br /&gt;
&lt;br /&gt;
*One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of the asset request. This is very helpful during  development.;&lt;br /&gt;
&lt;br /&gt;
* Clean up tests: few of the controller tests were not in the correct order.  &lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
* We have not made any changes in the features of Expertiza. The changes are checking bad code smells and fixing them. The way to verify the changes is to make sure that it works as it was previously.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95840</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95840"/>
		<updated>2015-03-23T23:47:03Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;Refactoring is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are difficult to read;&lt;br /&gt;
* Programs that does not follow the language specific guidelines;&lt;br /&gt;
* Programs that has high coupling;&lt;br /&gt;
&lt;br /&gt;
''' Introduction to Expertiza '''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt;Expertiza is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned and modified from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews.&lt;br /&gt;
&lt;br /&gt;
Assignment.rb is the largest class in Expertiza, comprising 1105 lines of code which contains the assignment model and the related functionalities. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound which can be grouped into smaller, more manageable classes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
*The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores;&lt;br /&gt;
*Moreover, the querying module is database dependent which should be made database independent;&lt;br /&gt;
*There are many function names and code lines which does not follow the ruby guidelines. They should be changed to more ruby like coding style; &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate module scorable.rb===&lt;br /&gt;
AvtiveRecord Concern is pattern introduced in Rails 4.1 to seperate the heavy loading done by models. It is recommended that models should be fat and should contain the business logic. This is leads to models getting too coupled. ActiveRecord Concerns solves this problem. Methods which can be logically put together are added in a module/mixin. This mixin is then included in the main model. The mixin can be reused by any other model if required. This makes the code align with Rails philosophy of DRY. In this case all methods related to 'scores' were collaborated together and put inside the mixin scorable.  &lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
*get_scores;&lt;br /&gt;
*get_max_score_possible;&lt;br /&gt;
*compute_reviews_hash;&lt;br /&gt;
*get_average_score;&lt;br /&gt;
&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Ruby idiomatic==&lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding was not like ruby like. The ruby community believes in small, well readable code. The code was refactored to be more readable. Changes such as removing the return statements, writing .each instead of for loop and improving naming conventions were implemented. Few of the examples are given below:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac.JPG|center]]&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Addition of ActiveRecord like Query==&lt;br /&gt;
ActiveRecord provides a layer on top database. Hence if no Mysql specific query is used in the code it very simple to change the database without changing the code. Using Ruby hash for query rather than raw sql also helps in keeping the code clean&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 4: Ruby style guide ==&lt;br /&gt;
We used `rubocop` to check the ruby style guide violations. We fixed most of the Ruby style guide violations in that class.&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac1.JPG|center]]&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 5 : Changing &amp;lt;ref&amp;gt;[http://bundler.io/gemfile.html Gemfile]&amp;lt;/ref&amp;gt;Gemfile==&lt;br /&gt;
&lt;br /&gt;
*Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.; The older version was not compatible with ruby 2.2.0&lt;br /&gt;
&lt;br /&gt;
*One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of the asset request. This is very helpful during  development.;&lt;br /&gt;
&lt;br /&gt;
* Clean up tests: few of the controller tests were not in the correct order.  &lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
* We have not made any changes in the features of Expertiza. The changes are checking bad code smells and fixing them. The way to verify the changes is to make sure that it works as it was previously.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Refac1.JPG&amp;diff=95839</id>
		<title>File:Refac1.JPG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Refac1.JPG&amp;diff=95839"/>
		<updated>2015-03-23T23:46:26Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95838</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95838"/>
		<updated>2015-03-23T23:44:05Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;Refactoring is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are difficult to read;&lt;br /&gt;
* Programs that does not follow the language specific guidelines;&lt;br /&gt;
* Programs that has high coupling;&lt;br /&gt;
&lt;br /&gt;
''' Introduction to Expertiza '''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt;Expertiza is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned and modified from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews.&lt;br /&gt;
&lt;br /&gt;
Assignment.rb is the largest class in Expertiza, comprising 1105 lines of code which contains the assignment model and the related functionalities. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound which can be grouped into smaller, more manageable classes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
*The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores;&lt;br /&gt;
*Moreover, the querying module is database dependent which should be made database independent;&lt;br /&gt;
*There are many function names and code lines which does not follow the ruby guidelines. They should be changed to more ruby like coding style; &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate module scorable.rb===&lt;br /&gt;
AvtiveRecord Concern is pattern introduced in Rails 4.1 to seperate the heavy loading done by models. It is recommended that models should be fat and should contain the business logic. This is leads to models getting too coupled. ActiveRecord Concerns solves this problem. Methods which can be logically put together are added in a module/mixin. This mixin is then included in the main model. The mixin can be reused by any other model if required. This makes the code align with Rails philosophy of DRY. In this case all methods related to 'scores' were collaborated together and put inside the mixin scorable.  &lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
*get_scores;&lt;br /&gt;
*get_max_score_possible;&lt;br /&gt;
*compute_reviews_hash;&lt;br /&gt;
*get_average_score;&lt;br /&gt;
&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Ruby idiomatic==&lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding was not like ruby like. The ruby community believes in small, well readable code. The code was refactored to be more readable. Changes such as removing the return statements, writing .each instead of for loop and improving naming conventions were implemented. Few of the examples are given below:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac.JPG|center]]&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Addition of ActiveRecord like Query==&lt;br /&gt;
ActiveRecord provides a layer on top database. Hence if no Mysql specific query is used in the code it very simple to change the database without changing the code. Using Ruby hash for query rather than raw sql also helps in keeping the code clean&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 4: Ruby style guide ==&lt;br /&gt;
We used `rubocop` to check the ruby style guide violations. We fixed most of the Ruby style guide violations in that class.&lt;br /&gt;
&lt;br /&gt;
== Instance 5 : Changing &amp;lt;ref&amp;gt;[http://bundler.io/gemfile.html Gemfile]&amp;lt;/ref&amp;gt;Gemfile==&lt;br /&gt;
&lt;br /&gt;
*Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.; The older version was not compatible with ruby 2.2.0&lt;br /&gt;
&lt;br /&gt;
*One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of the asset request. This is very helpful during  development.;&lt;br /&gt;
&lt;br /&gt;
* Clean up tests: few of the controller tests were not in the correct order.  &lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
* We have not made any changes in the features of Expertiza. The changes are checking bad code smells and fixing them. The way to verify the changes is to make sure that it works as it was previously.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95837</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95837"/>
		<updated>2015-03-23T23:40:50Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;Refactoring is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are difficult to read;&lt;br /&gt;
* Programs that does not follow the language specific guidelines;&lt;br /&gt;
* Programs that has high coupling;&lt;br /&gt;
&lt;br /&gt;
''' Introduction to Expertiza '''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt;Expertiza is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned and modified from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews.&lt;br /&gt;
&lt;br /&gt;
Assignment.rb is the largest class in Expertiza, comprising 1105 lines of code which contains the assignment model and the related functionalities. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound which can be grouped into smaller, more manageable classes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
*The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores;&lt;br /&gt;
*Moreover, the querying module is database dependent which should be made database independent;&lt;br /&gt;
*There are many function names and code lines which does not follow the ruby guidelines. They should be changed to more ruby like coding style; &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate module scorable.rb===&lt;br /&gt;
AvtiveRecord Concern is pattern introduced in Rails 4.1 to seperate the heavy loading done by models. It is recommended that models should be fat and should contain the business logic. This is leads to models getting too coupled. ActiveRecord Concerns solves this problem. Methods which can be logically put together are added in a module/mixin. This mixin is then included in the main model. The mixin can be reused by any other model if required. This makes the code align with Rails philosophy of DRY. In this case all methods related to 'scores' were collaborated together and put inside the mixin scorable.  &lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
*get_scores;&lt;br /&gt;
*get_max_score_possible;&lt;br /&gt;
*compute_reviews_hash;&lt;br /&gt;
*get_average_score;&lt;br /&gt;
&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Ruby idiomatic==&lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding was not like ruby like. The ruby community believes in small, well readable code. The code was refactored to be more readable. Changes such as removing the return statements, writing .each instead of for loop and improving naming conventions were implemented. Few of the examples are given below:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac.JPG]]&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Addition of ActiveRecord like Query==&lt;br /&gt;
ActiveRecord provides a layer on top database. Hence if no Mysql specific query is used in the code it very simple to change the database without changing the code. Using Ruby hash for query rather than raw sql also helps in keeping the code clean&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 4: Ruby style guide ==&lt;br /&gt;
We used `rubocop` to check the ruby style guide violations. We fixed most of the Ruby style guide violations in that class.&lt;br /&gt;
&lt;br /&gt;
== Instance 5 : Changing &amp;lt;ref&amp;gt;[http://bundler.io/gemfile.html Gemfile]&amp;lt;/ref&amp;gt;Gemfile==&lt;br /&gt;
&lt;br /&gt;
*Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.; The older version was not compatible with ruby 2.2.0&lt;br /&gt;
&lt;br /&gt;
*One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of the asset request. This is very helpful during  development.;&lt;br /&gt;
&lt;br /&gt;
* Clean up tests: few of the controller tests were not in the correct order.  &lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
* We have not made any changes in the features of Expertiza. The changes are checking bad code smells and fixing them. The way to verify the changes is to make sure that it works as it was previously.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95836</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95836"/>
		<updated>2015-03-23T23:40:26Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;Refactoring is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are difficult to read;&lt;br /&gt;
* Programs that does not follow the language specific guidelines;&lt;br /&gt;
* Programs that has high coupling;&lt;br /&gt;
&lt;br /&gt;
''' Introduction to Expertiza '''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt;Expertiza is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned and modified from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews.&lt;br /&gt;
&lt;br /&gt;
Assignment.rb is the largest class in Expertiza, comprising 1105 lines of code which contains the assignment model and the related functionalities. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound which can be grouped into smaller, more manageable classes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
*The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores;&lt;br /&gt;
*Moreover, the querying module is database dependent which should be made database independent;&lt;br /&gt;
*There are many function names and code lines which does not follow the ruby guidelines. They should be changed to more ruby like coding style; &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate module scorable.rb===&lt;br /&gt;
AvtiveRecord Concern is pattern introduced in Rails 4.1 to seperate the heavy loading done by models. It is recommended that models should be fat and should contain the business logic. This is leads to models getting too coupled. ActiveRecord Concerns solves this problem. Methods which can be logically put together are added in a module/mixin. This mixin is then included in the main model. The mixin can be reused by any other model if required. This makes the code align with Rails philosophy of DRY. In this case all methods related to 'scores' were collaborated together and put inside the mixin scorable.  &lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
*get_scores;&lt;br /&gt;
*get_max_score_possible;&lt;br /&gt;
*compute_reviews_hash;&lt;br /&gt;
*get_average_score;&lt;br /&gt;
&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Ruby idiomatic==&lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding was not like ruby like. The ruby community believes in small, well readable code. The code was refactored to be more readable. Changes such as removing the return statements, writing .each instead of for loop and improving naming conventions were implemented. Few of the examples are given below:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac.JPG]]&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Addition of ActiveRecord like Query==&lt;br /&gt;
ActiveRecord provides a layer on top database. Hence if no Mysql specific query is used in the code it very simple to change the database without changing the code. Using Ruby hash for query rather than raw sql also helps in keeping the code clean&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 4: Ruby style guide ==&lt;br /&gt;
We used `rubocop` to check the ruby style guide violations. We fixed most of the Ruby style guide violations in that class.&lt;br /&gt;
&lt;br /&gt;
== Instance 5 : Changing &amp;lt;ref&amp;gt;[http://bundler.io/gemfile.html Gemfile]&amp;lt;/ref&amp;gt;Gemfile==&lt;br /&gt;
&lt;br /&gt;
*Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.; The older version was not compatible with ruby 2.2.0&lt;br /&gt;
&lt;br /&gt;
*One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of the asset request. This is very helpful during  development.;&lt;br /&gt;
&lt;br /&gt;
* Clean up tests: few of the controller tests were not in the correct order.  &lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
* We have not made any changes in the features of Expertiza. The changes are checking bad code smells and fixing them. The way to verify the changes is to make sure that it works as it was previously.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95835</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95835"/>
		<updated>2015-03-23T23:39:57Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;Refactoring is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are difficult to read;&lt;br /&gt;
* Programs that does not follow the language specific guidelines;&lt;br /&gt;
* Programs that has high coupling;&lt;br /&gt;
&lt;br /&gt;
''' Introduction to Expertiza '''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt;Expertiza is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned and modified from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews.&lt;br /&gt;
&lt;br /&gt;
Assignment.rb is the largest class in Expertiza, comprising 1105 lines of code which contains the assignment model and the related functionalities. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound which can be grouped into smaller, more manageable classes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
*The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores;&lt;br /&gt;
*Moreover, the querying module is database dependent which should be made database independent;&lt;br /&gt;
*There are many function names and code lines which does not follow the ruby guidelines. They should be changed to more ruby like coding style; &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate module scorable.rb===&lt;br /&gt;
AvtiveRecord Concern is pattern introduced in Rails 4.1 to seperate the heavy loading done by models. It is recommended that models should be fat and should contain the business logic. This is leads to models getting too coupled. ActiveRecord Concerns solves this problem. Methods which can be logically put together are added in a module/mixin. This mixin is then included in the main model. The mixin can be reused by any other model if required. This makes the code align with Rails philosophy of DRY. In this case all methods related to 'scores' were collaborated together and put inside the mixin scorable.  &lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
*get_scores;&lt;br /&gt;
*get_max_score_possible;&lt;br /&gt;
*compute_reviews_hash;&lt;br /&gt;
*get_average_score;&lt;br /&gt;
&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Ruby idiomatic==&lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding was not like ruby like. The ruby community believes in small, well readable code. The code was refactored to be more readable. Changes such as removing the return statements, writing .each instead of for loop and improving naming conventions were implemented. Few of the examples are given below:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
[[File:Refac.JPG]]&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Addition of ActiveRecord like Query==&lt;br /&gt;
ActiveRecord provides a layer on top database. Hence if no Mysql specific query is used in the code it very simple to change the database without changing the code. Using Ruby hash for query rather than raw sql also helps in keeping the code clean&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 4: Ruby style guide ==&lt;br /&gt;
We used `rubocop` to check the ruby style guide violations. We fixed most of the Ruby style guide violations in that class.&lt;br /&gt;
&lt;br /&gt;
== Instance 5 : Changing &amp;lt;ref&amp;gt;[http://bundler.io/gemfile.html Gemfile]&amp;lt;/ref&amp;gt;Gemfile==&lt;br /&gt;
&lt;br /&gt;
*Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.; The older version was not compatible with ruby 2.2.0&lt;br /&gt;
&lt;br /&gt;
*One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of the asset request. This is very helpful during  development.;&lt;br /&gt;
&lt;br /&gt;
* Clean up tests: few of the controller tests were not in the correct order.  &lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
* We have not made any changes in the features of Expertiza. The changes are checking bad code smells and fixing them. The way to verify the changes is to make sure that it works as it was previously.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95834</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95834"/>
		<updated>2015-03-23T23:39:05Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;Refactoring is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are difficult to read;&lt;br /&gt;
* Programs that does not follow the language specific guidelines;&lt;br /&gt;
* Programs that has high coupling;&lt;br /&gt;
&lt;br /&gt;
''' Introduction to Expertiza '''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt;Expertiza is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned and modified from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews.&lt;br /&gt;
&lt;br /&gt;
Assignment.rb is the largest class in Expertiza, comprising 1105 lines of code which contains the assignment model and the related functionalities. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound which can be grouped into smaller, more manageable classes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
*The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores;&lt;br /&gt;
*Moreover, the querying module is database dependent which should be made database independent;&lt;br /&gt;
*There are many function names and code lines which does not follow the ruby guidelines. They should be changed to more ruby like coding style; &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate module scorable.rb===&lt;br /&gt;
AvtiveRecord Concern is pattern introduced in Rails 4.1 to seperate the heavy loading done by models. It is recommended that models should be fat and should contain the business logic. This is leads to models getting too coupled. ActiveRecord Concerns solves this problem. Methods which can be logically put together are added in a module/mixin. This mixin is then included in the main model. The mixin can be reused by any other model if required. This makes the code align with Rails philosophy of DRY. In this case all methods related to 'scores' were collaborated together and put inside the mixin scorable.  &lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
*get_scores;&lt;br /&gt;
*get_max_score_possible;&lt;br /&gt;
*compute_reviews_hash;&lt;br /&gt;
*get_average_score;&lt;br /&gt;
&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Ruby idiomatic==&lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding was not like ruby like. The ruby community believes in small, well readable code. The code was refactored to be more readable. Changes such as removing the return statements, writing .each instead of for loop and improving naming conventions were implemented. Few of the examples are given below:&lt;br /&gt;
[[File:Refac.JPG]]&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Addition of ActiveRecord like Query==&lt;br /&gt;
ActiveRecord provides a layer on top database. Hence if no Mysql specific query is used in the code it very simple to change the database without changing the code. Using Ruby hash for query rather than raw sql also helps in keeping the code clean&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 4: Ruby style guide ==&lt;br /&gt;
We used `rubocop` to check the ruby style guide violations. We fixed most of the Ruby style guide violations in that class.&lt;br /&gt;
&lt;br /&gt;
== Instance 5 : Changing &amp;lt;ref&amp;gt;[http://bundler.io/gemfile.html Gemfile]&amp;lt;/ref&amp;gt;Gemfile==&lt;br /&gt;
&lt;br /&gt;
*Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.; The older version was not compatible with ruby 2.2.0&lt;br /&gt;
&lt;br /&gt;
*One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of the asset request. This is very helpful during  development.;&lt;br /&gt;
&lt;br /&gt;
* Clean up tests: few of the controller tests were not in the correct order.  &lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
* We have not made any changes in the features of Expertiza. The changes are checking bad code smells and fixing them. The way to verify the changes is to make sure that it works as it was previously.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95833</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95833"/>
		<updated>2015-03-23T23:37:29Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;Refactoring is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are difficult to read;&lt;br /&gt;
* Programs that does not follow the language specific guidelines;&lt;br /&gt;
* Programs that has high coupling;&lt;br /&gt;
&lt;br /&gt;
''' Introduction to Expertiza '''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt;Expertiza is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned and modified from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews.&lt;br /&gt;
&lt;br /&gt;
Assignment.rb is the largest class in Expertiza, comprising 1105 lines of code which contains the assignment model and the related functionalities. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound which can be grouped into smaller, more manageable classes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
*The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores;&lt;br /&gt;
*Moreover, the querying module is database dependent which should be made database independent;&lt;br /&gt;
*There are many function names and code lines which does not follow the ruby guidelines. They should be changed to more ruby like coding style; &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate module scorable.rb===&lt;br /&gt;
AvtiveRecord Concern is pattern introduced in Rails 4.1 to seperate the heavy loading done by models. It is recommended that models should be fat and should contain the business logic. This is leads to models getting too coupled. ActiveRecord Concerns solves this problem. Methods which can be logically put together are added in a module/mixin. This mixin is then included in the main model. The mixin can be reused by any other model if required. This makes the code align with Rails philosophy of DRY. In this case all methods related to 'scores' were collaborated together and put inside the mixin scorable.  &lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
*get_scores;&lt;br /&gt;
*get_max_score_possible;&lt;br /&gt;
*compute_reviews_hash;&lt;br /&gt;
*get_average_score;&lt;br /&gt;
&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Ruby idiomatic==&lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding was not like ruby like. The ruby community believes in small, well readable code. The code was refactored to be more readable. Changes such as removing the return statements, writing .each instead of for loop and improving naming conventions were implemented. Few of the examples are given below:&lt;br /&gt;
[[File:refac.jpg]]&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Addition of ActiveRecord like Query==&lt;br /&gt;
ActiveRecord provides a layer on top database. Hence if no Mysql specific query is used in the code it very simple to change the database without changing the code. Using Ruby hash for query rather than raw sql also helps in keeping the code clean&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 4: Ruby style guide ==&lt;br /&gt;
We used `rubocop` to check the ruby style guide violations. We fixed most of the Ruby style guide violations in that class.&lt;br /&gt;
&lt;br /&gt;
== Instance 5 : Changing &amp;lt;ref&amp;gt;[http://bundler.io/gemfile.html Gemfile]&amp;lt;/ref&amp;gt;Gemfile==&lt;br /&gt;
&lt;br /&gt;
*Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.; The older version was not compatible with ruby 2.2.0&lt;br /&gt;
&lt;br /&gt;
*One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of the asset request. This is very helpful during  development.;&lt;br /&gt;
&lt;br /&gt;
* Clean up tests: few of the controller tests were not in the correct order.  &lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
* We have not made any changes in the features of Expertiza. The changes are checking bad code smells and fixing them. The way to verify the changes is to make sure that it works as it was previously.&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Refac.JPG&amp;diff=95832</id>
		<title>File:Refac.JPG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Refac.JPG&amp;diff=95832"/>
		<updated>2015-03-23T23:35:46Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: Refactoring of assignment.rb in expertiza OSS.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Refactoring of assignment.rb in expertiza OSS.&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95761</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95761"/>
		<updated>2015-03-23T19:17:42Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;Refactoring is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are difficult to read;&lt;br /&gt;
* Programs that does not follow the language specific guidelines;&lt;br /&gt;
* Programs that has high coupling;&lt;br /&gt;
&lt;br /&gt;
''' Introduction to Expertiza '''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt;Expertiza is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned and modified from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews.&lt;br /&gt;
&lt;br /&gt;
Assignment.rb is the largest class in Expertiza, comprising 1105 lines of code which contains the assignment model and the related functionalities. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound which can be grouped into smaller, more manageable classes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
*The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores;&lt;br /&gt;
*Moreover, the querying module is database dependent which should be made database independent;&lt;br /&gt;
*There are many function names and code lines which does not follow the ruby guidelines. They should be changed to more ruby like coding style; &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate model scorable.rb===&lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
*get_scores;&lt;br /&gt;
*get_max_score_possible;&lt;br /&gt;
*compute_reviews_hash;&lt;br /&gt;
*get_average_score;&lt;br /&gt;
&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding style was not according to ruby guidelines. The code was refactored to be more ruby like. Changes such as removing the return statements, writing .each instead of for loop and improving naming conventions were implemented. Some of the changes are described below:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Addition of ActiveRecord like Query==&lt;br /&gt;
&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Changing &amp;lt;ref&amp;gt;[http://bundler.io/gemfile.html Gemfile]&amp;lt;/ref&amp;gt;Gemfile==&lt;br /&gt;
&lt;br /&gt;
*Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.;&lt;br /&gt;
&lt;br /&gt;
*One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of background functions.;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95759</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95759"/>
		<updated>2015-03-23T19:15:59Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;Refactoring is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are difficult to read;&lt;br /&gt;
* Programs that does not follow the language specific guidelines;&lt;br /&gt;
* Programs that has high coupling;&lt;br /&gt;
&lt;br /&gt;
''' Introduction to Expertiza '''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt;Expertiza is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned and modified from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews.&lt;br /&gt;
&lt;br /&gt;
Assignment.rb is the largest class in Expertiza, comprising 1105 lines of code which contains the assignment model and the related functionalities. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound which can be grouped into smaller, more manageable classes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
*The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores;&lt;br /&gt;
*Moreover, the querying module is database dependent which should be made database independent;&lt;br /&gt;
*There are many function names and code lines which does not follow the ruby guidelines. They should be changed to more ruby like coding style; &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate model scorable.rb===&lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
*get_scores;&lt;br /&gt;
*get_max_score_possible;&lt;br /&gt;
*compute_reviews_hash;&lt;br /&gt;
*get_average_score;&lt;br /&gt;
&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding style was not according to ruby guidelines. The code was refactored to be more ruby like. Changes such as removing the return statements, writing .each instead of for loop and improving naming conventions were implemented. Some of the changes are described below:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Addition of ActiveRecord like Query==&lt;br /&gt;
&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Changing Gemfile==&lt;br /&gt;
&lt;br /&gt;
*Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.;&lt;br /&gt;
&lt;br /&gt;
*One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of background functions.;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95758</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95758"/>
		<updated>2015-03-23T19:15:46Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;Refactoring is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are difficult to read;&lt;br /&gt;
* Programs that does not follow the language specific guidelines;&lt;br /&gt;
* Programs that has high coupling;&lt;br /&gt;
&lt;br /&gt;
''' Introduction to Expertiza '''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt; is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned and modified from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews.&lt;br /&gt;
&lt;br /&gt;
Assignment.rb is the largest class in Expertiza, comprising 1105 lines of code which contains the assignment model and the related functionalities. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound which can be grouped into smaller, more manageable classes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
*The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores;&lt;br /&gt;
*Moreover, the querying module is database dependent which should be made database independent;&lt;br /&gt;
*There are many function names and code lines which does not follow the ruby guidelines. They should be changed to more ruby like coding style; &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate model scorable.rb===&lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
*get_scores;&lt;br /&gt;
*get_max_score_possible;&lt;br /&gt;
*compute_reviews_hash;&lt;br /&gt;
*get_average_score;&lt;br /&gt;
&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding style was not according to ruby guidelines. The code was refactored to be more ruby like. Changes such as removing the return statements, writing .each instead of for loop and improving naming conventions were implemented. Some of the changes are described below:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Addition of ActiveRecord like Query==&lt;br /&gt;
&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Changing Gemfile==&lt;br /&gt;
&lt;br /&gt;
*Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.;&lt;br /&gt;
&lt;br /&gt;
*One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of background functions.;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95756</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95756"/>
		<updated>2015-03-23T19:14:44Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;Refactoring is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are difficult to read;&lt;br /&gt;
* Programs that does not follow the language specific guidelines;&lt;br /&gt;
* Programs that has high coupling;&lt;br /&gt;
&lt;br /&gt;
''' Introduction to Expertiza '''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned and modified from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews.&lt;br /&gt;
&lt;br /&gt;
Assignment.rb is the largest class in Expertiza, comprising 1105 lines of code which contains the assignment model and the related functionalities. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound which can be grouped into smaller, more manageable classes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
*The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores;&lt;br /&gt;
*Moreover, the querying module is database dependent which should be made database independent;&lt;br /&gt;
*There are many function names and code lines which does not follow the ruby guidelines. They should be changed to more ruby like coding style; &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate model scorable.rb===&lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
*get_scores;&lt;br /&gt;
*get_max_score_possible;&lt;br /&gt;
*compute_reviews_hash;&lt;br /&gt;
*get_average_score;&lt;br /&gt;
&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding style was not according to ruby guidelines. The code was refactored to be more ruby like. Changes such as removing the return statements, writing .each instead of for loop and improving naming conventions were implemented. Some of the changes are described below:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Addition of ActiveRecord like Query==&lt;br /&gt;
&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Changing Gemfile==&lt;br /&gt;
&lt;br /&gt;
*Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.;&lt;br /&gt;
&lt;br /&gt;
*One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of background functions.;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_refactoring Code Refactoring]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_smell Code smell]&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95755</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95755"/>
		<updated>2015-03-23T19:13:38Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;Refactoring is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are difficult to read;&lt;br /&gt;
* Programs that does not follow the language specific guidelines;&lt;br /&gt;
* Programs that has high coupling;&lt;br /&gt;
&lt;br /&gt;
''' Introduction to Expertiza '''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned and modified from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews.&lt;br /&gt;
&lt;br /&gt;
Assignment.rb is the largest class in Expertiza, comprising 1105 lines of code which contains the assignment model and the related functionalities. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound which can be grouped into smaller, more manageable classes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
*The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores;&lt;br /&gt;
*Moreover, the querying module is database dependent which should be made database independent;&lt;br /&gt;
*There are many function names and code lines which does not follow the ruby guidelines. They should be changed to more ruby like coding style; &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate model scorable.rb===&lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
*get_scores;&lt;br /&gt;
*get_max_score_possible;&lt;br /&gt;
*compute_reviews_hash;&lt;br /&gt;
*get_average_score;&lt;br /&gt;
&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding style was not according to ruby guidelines. The code was refactored to be more ruby like. Changes such as removing the return statements, writing .each instead of for loop and improving naming conventions were implemented. Some of the changes are described below:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Addition of ActiveRecord like Query==&lt;br /&gt;
&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Changing Gemfile==&lt;br /&gt;
&lt;br /&gt;
*Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.;&lt;br /&gt;
&lt;br /&gt;
*One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of background functions.;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_refactoring Code Refactoring]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_smell Code smell]&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95754</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95754"/>
		<updated>2015-03-23T19:12:54Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;Refactoring is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are difficult to read;&lt;br /&gt;
* Programs that does not follow the language specific guidelines;&lt;br /&gt;
* Programs that has high coupling;&lt;br /&gt;
&lt;br /&gt;
''' Introduction to Expertiza '''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned and modified from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews.&lt;br /&gt;
&lt;br /&gt;
Assignment.rb is the largest class in Expertiza, comprising 1105 lines of code which contains the assignment model and the related functionalities. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound which can be grouped into smaller, more manageable classes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
*The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores;&lt;br /&gt;
*Moreover, the querying module is database dependent which should be made database independent;&lt;br /&gt;
*There are many function names and code lines which does not follow the ruby guidelines. They should be changed to more ruby like coding style; &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate model scorable.rb===&lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
&amp;lt;p&amp;gt;*get_scores;&lt;br /&gt;
*get_max_score_possible;&lt;br /&gt;
*compute_reviews_hash;&lt;br /&gt;
*get_average_score;&lt;br /&gt;
&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding style was not according to ruby guidelines. The code was refactored to be more ruby like. Changes such as removing the return statements, writing .each instead of for loop and improving naming conventions were implemented. Some of the changes are described below:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Addition of ActiveRecord like Query==&lt;br /&gt;
&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Changing Gemfile==&lt;br /&gt;
&lt;br /&gt;
Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.&lt;br /&gt;
&lt;br /&gt;
One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of background functions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_refactoring Code Refactoring]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_smell Code smell]&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95753</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95753"/>
		<updated>2015-03-23T19:11:08Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;Refactoring is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are difficult to read;&lt;br /&gt;
* Programs that does not follow the language specific guidelines;&lt;br /&gt;
* Programs that has high coupling;&lt;br /&gt;
&lt;br /&gt;
''' Introduction to Expertiza '''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned and modified from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews.&lt;br /&gt;
&lt;br /&gt;
Assignment.rb is the largest class in Expertiza, comprising 1105 lines of code which contains the assignment model and the related functionalities. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound which can be grouped into smaller, more manageable classes.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
*The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores;&lt;br /&gt;
*Moreover, the querying module is database dependent which should be made database independent;&lt;br /&gt;
*There are many function names and code lines which does not follow the ruby guidelines. They should be changed to more ruby like coding style; &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate model scorable.rb===&lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
&amp;lt;p&amp;gt;1.get_scores&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;2.get_max_score_possible&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;3.compute_reviews_hash&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;4.get_average_score&amp;lt;/p&amp;gt;&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding style was not according to ruby guidelines. The code was refactored to be more ruby like. Changes such as removing the return statements, writing .each instead of for loop and improving naming conventions were implemented. Some of the changes are described below:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Addition of ActiveRecord like Query==&lt;br /&gt;
&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Changing Gemfile==&lt;br /&gt;
&lt;br /&gt;
Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.&lt;br /&gt;
&lt;br /&gt;
One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of background functions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_refactoring Code Refactoring]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_smell Code smell]&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95752</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95752"/>
		<updated>2015-03-23T19:09:28Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;Refactoring is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are difficult to read;&lt;br /&gt;
* Programs that does not follow the language specific guidelines;&lt;br /&gt;
* Programs that has high coupling;&lt;br /&gt;
&lt;br /&gt;
''' Introduction to Expertiza '''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned and modified from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews.&lt;br /&gt;
&lt;br /&gt;
Assignment.rb is the largest class in Expertiza, comprising 1105 lines of code which contains the assignment model and the related functionalities. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; &lt;br /&gt;
*The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores;&lt;br /&gt;
*Moreover, the querying module is database dependent which should be made database independent;&lt;br /&gt;
*There are many function names and code lines which does not follow the ruby guidelines. They should be changed to more ruby like coding style; &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate model scorable.rb===&lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
&amp;lt;p&amp;gt;1.get_scores&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;2.get_max_score_possible&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;3.compute_reviews_hash&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;4.get_average_score&amp;lt;/p&amp;gt;&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding style was not according to ruby guidelines. The code was refactored to be more ruby like. Changes such as removing the return statements, writing .each instead of for loop and improving naming conventions were implemented. Some of the changes are described below:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Addition of ActiveRecord like Query==&lt;br /&gt;
&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Changing Gemfile==&lt;br /&gt;
&lt;br /&gt;
Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.&lt;br /&gt;
&lt;br /&gt;
One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of background functions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_refactoring Code Refactoring]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_smell Code smell]&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95749</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95749"/>
		<updated>2015-03-23T19:04:57Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;Refactoring is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are difficult to read;&lt;br /&gt;
* Programs that does not follow the language specific guidelines;&lt;br /&gt;
* Programs that has high coupling;&lt;br /&gt;
&lt;br /&gt;
''' Introduction to Expertiza '''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned and modified from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews.&lt;br /&gt;
&lt;br /&gt;
Assignment.rb is a file which contains the assignment model and the related functionalities. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores. Moreover, the querying module was database dependent which was made database independent. There are many function names and code lines which does not follow the ruby guidelines. They were changed to more ruby like coding style. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate model scorable.rb===&lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
&amp;lt;p&amp;gt;1.get_scores&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;2.get_max_score_possible&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;3.compute_reviews_hash&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;4.get_average_score&amp;lt;/p&amp;gt;&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding style was not according to ruby guidelines. The code was refactored to be more ruby like. Changes such as removing the return statements, writing .each instead of for loop and improving naming conventions were implemented. Some of the changes are described below:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Addition of ActiveRecord like Query==&lt;br /&gt;
&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Changing Gemfile==&lt;br /&gt;
&lt;br /&gt;
Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.&lt;br /&gt;
&lt;br /&gt;
One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of background functions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_refactoring Code Refactoring]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_smell Code smell]&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95743</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95743"/>
		<updated>2015-03-23T19:02:20Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;Refactoring is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are hard to read are hard to modify;&lt;br /&gt;
* Programs that have duplicate logic are hard to modify;&lt;br /&gt;
* Programs that require additional behavior that requires you to change running code are hard to modify;&lt;br /&gt;
* Programs with complex conditional logic are hard to modify.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Introduction to Expertiza '''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews, which makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Assignment.rb is a file which contains the assignment model and the related functionality. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores. Moreover, the querying module was database dependent which was made database independent. There are many function names and code lines which does not follow the ruby guidelines. They were changed to more ruby like coding style. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate model scorable.rb===&lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
&amp;lt;p&amp;gt;1.get_scores&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;2.get_max_score_possible&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;3.compute_reviews_hash&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;4.get_average_score&amp;lt;/p&amp;gt;&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding style was not according to ruby guidelines. The code was refactored to be more ruby like. Changes such as removing the return statements, writing .each instead of for loop and improving naming conventions were implemented. Some of the changes are described below:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Addition of ActiveRecord like Query==&lt;br /&gt;
&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Changing Gemfile==&lt;br /&gt;
&lt;br /&gt;
Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.&lt;br /&gt;
&lt;br /&gt;
One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of background functions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_refactoring Code Refactoring]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_smell Code smell]&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95741</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95741"/>
		<updated>2015-03-23T19:02:01Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;Refactoring is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are hard to read are hard to modify;&lt;br /&gt;
* Programs that have duplicate logic are hard to modify;&lt;br /&gt;
* Programs that require additional behavior that requires you to change running code are hard to modify;&lt;br /&gt;
* Programs with complex conditional logic are hard to modify.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'' Introduction to Expertiza ''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews, which makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Assignment.rb is a file which contains the assignment model and the related functionality. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores. Moreover, the querying module was database dependent which was made database independent. There are many function names and code lines which does not follow the ruby guidelines. They were changed to more ruby like coding style. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate model scorable.rb===&lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
&amp;lt;p&amp;gt;1.get_scores&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;2.get_max_score_possible&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;3.compute_reviews_hash&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;4.get_average_score&amp;lt;/p&amp;gt;&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding style was not according to ruby guidelines. The code was refactored to be more ruby like. Changes such as removing the return statements, writing .each instead of for loop and improving naming conventions were implemented. Some of the changes are described below:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Addition of ActiveRecord like Query==&lt;br /&gt;
&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Changing Gemfile==&lt;br /&gt;
&lt;br /&gt;
Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.&lt;br /&gt;
&lt;br /&gt;
One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of background functions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_refactoring Code Refactoring]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_smell Code smell]&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95740</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95740"/>
		<updated>2015-03-23T19:01:41Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;Refactoring is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are hard to read are hard to modify;&lt;br /&gt;
* Programs that have duplicate logic are hard to modify;&lt;br /&gt;
* Programs that require additional behavior that requires you to change running code are hard to modify;&lt;br /&gt;
* Programs with complex conditional logic are hard to modify.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Introduction to Expertiza ==&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews, which makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Assignment.rb is a file which contains the assignment model and the related functionality. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores. Moreover, the querying module was database dependent which was made database independent. There are many function names and code lines which does not follow the ruby guidelines. They were changed to more ruby like coding style. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate model scorable.rb===&lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
&amp;lt;p&amp;gt;1.get_scores&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;2.get_max_score_possible&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;3.compute_reviews_hash&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;4.get_average_score&amp;lt;/p&amp;gt;&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding style was not according to ruby guidelines. The code was refactored to be more ruby like. Changes such as removing the return statements, writing .each instead of for loop and improving naming conventions were implemented. Some of the changes are described below:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Addition of ActiveRecord like Query==&lt;br /&gt;
&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Changing Gemfile==&lt;br /&gt;
&lt;br /&gt;
Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.&lt;br /&gt;
&lt;br /&gt;
One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of background functions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_refactoring Code Refactoring]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_smell Code smell]&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95738</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95738"/>
		<updated>2015-03-23T19:01:15Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;Refactoring is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
It is used for:&lt;br /&gt;
&lt;br /&gt;
* Programs that are hard to read are hard to modify;&lt;br /&gt;
* Programs that have duplicate logic are hard to modify;&lt;br /&gt;
* Programs that require additional behavior that requires you to change running code are hard to modify;&lt;br /&gt;
* Programs with complex conditional logic are hard to modify.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Introduction to Expertiza==&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews, which makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Assignment.rb is a file which contains the assignment model and the related functionality. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores. Moreover, the querying module was database dependent which was made database independent. There are many function names and code lines which does not follow the ruby guidelines. They were changed to more ruby like coding style. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate model scorable.rb===&lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
&amp;lt;p&amp;gt;1.get_scores&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;2.get_max_score_possible&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;3.compute_reviews_hash&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;4.get_average_score&amp;lt;/p&amp;gt;&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding style was not according to ruby guidelines. The code was refactored to be more ruby like. Changes such as removing the return statements, writing .each instead of for loop and improving naming conventions were implemented. Some of the changes are described below:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Addition of ActiveRecord like Query==&lt;br /&gt;
&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Changing Gemfile==&lt;br /&gt;
&lt;br /&gt;
Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.&lt;br /&gt;
&lt;br /&gt;
One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of background functions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_refactoring Code Refactoring]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_smell Code smell]&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95736</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95736"/>
		<updated>2015-03-23T18:59:08Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt; is a technique to alter the internal structure of the code without affecting the external behaviour.&lt;br /&gt;
Refactoring adds to the value of any program that has at least one of the following shortcomings&amp;lt;ref&amp;gt;[http://jexp.de/papers/refactoring/refactoring/node9.html#SECTION00330000000000000000 Benefits of Code Refactoring Michael Hunger. Oct. 25, 2000]&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* Programs that are hard to read are hard to modify;&lt;br /&gt;
* Programs that have duplicate logic are hard to modify;&lt;br /&gt;
* Programs that require additional behavior that requires you to change running code are hard to modify;&lt;br /&gt;
* Programs with complex conditional logic are hard to modify.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Introduction to Expertiza==&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews, which makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Assignment.rb is a file which contains the assignment model and the related functionality. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores. Moreover, the querying module was database dependent which was made database independent. There are many function names and code lines which does not follow the ruby guidelines. They were changed to more ruby like coding style. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate model scorable.rb===&lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
&amp;lt;p&amp;gt;1.get_scores&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;2.get_max_score_possible&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;3.compute_reviews_hash&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;4.get_average_score&amp;lt;/p&amp;gt;&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding style was not according to ruby guidelines. The code was refactored to be more ruby like. Changes such as removing the return statements, writing .each instead of for loop and improving naming conventions were implemented. Some of the changes are described below:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Addition of ActiveRecord like Query==&lt;br /&gt;
&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Changing Gemfile==&lt;br /&gt;
&lt;br /&gt;
Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.&lt;br /&gt;
&lt;br /&gt;
One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of background functions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_refactoring Code Refactoring]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_smell Code smell]&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95734</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95734"/>
		<updated>2015-03-23T18:57:19Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1501: Refactoring Assignments.rb=&lt;br /&gt;
&lt;br /&gt;
Refactoring is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;.&lt;br /&gt;
Refactoring adds to the value of any program that has at least one of the following shortcomings&amp;lt;ref&amp;gt;[http://jexp.de/papers/refactoring/refactoring/node9.html#SECTION00330000000000000000 Benefits of Code Refactoring Michael Hunger. Oct. 25, 2000]&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* Programs that are hard to read are hard to modify;&lt;br /&gt;
* Programs that have duplicate logic are hard to modify;&lt;br /&gt;
* Programs that require additional behavior that requires you to change running code are hard to modify;&lt;br /&gt;
* Programs with complex conditional logic are hard to modify.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Introduction to Expertiza'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews, which makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Assignment.rb is a file which contains the assignment model and the related functionality. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores. Moreover, the querying module was database dependent which was made database independent. There are many function names and code lines which does not follow the ruby guidelines. They were changed to more ruby like coding style. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate model scorable.rb===&lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
&amp;lt;p&amp;gt;1.get_scores&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;2.get_max_score_possible&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;3.compute_reviews_hash&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;4.get_average_score&amp;lt;/p&amp;gt;&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding style was not according to ruby guidelines. The code was refactored to be more ruby like. Changes such as removing the return statements, writing .each instead of for loop and improving naming conventions were implemented. Some of the changes are described below:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Addition of ActiveRecord like Query==&lt;br /&gt;
&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Changing Gemfile==&lt;br /&gt;
&lt;br /&gt;
Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.&lt;br /&gt;
&lt;br /&gt;
One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of background functions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_refactoring Code Refactoring]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_smell Code smell]&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95726</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95726"/>
		<updated>2015-03-23T18:52:21Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1501: Refactoring Assignments.rb'''&lt;br /&gt;
&lt;br /&gt;
This page provides information about a project which aims to refactor Assignment.rb file present in Expertiza OSS.&lt;br /&gt;
&lt;br /&gt;
'''Introduction to Expertiza'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews, which makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Assignment.rb is a file which contains the assignment model and the related functionality. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains methods which calculates the student scores. The assignment and scoring modules are very tightly bound.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; The assignment model needs refactoring as it contains some modules which are responsible for generating assignment scores. Moreover, the querying module was database dependent which was made database independent. There are many function names and code lines which does not follow the ruby guidelines. They were changed to more ruby like coding style. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate model scorable.rb===&lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
&amp;lt;p&amp;gt;1.get_scores&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;2.get_max_score_possible&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;3.compute_reviews_hash&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;4.get_average_score&amp;lt;/p&amp;gt;&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding style was not according to ruby guidelines. The code was refactored to be more ruby like. Changes such as removing the return statements, writing .each instead of for loop and improving naming conventions were implemented. Some of the changes are described below:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Addition of ActiveRecord like Query==&lt;br /&gt;
&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Changing Gemfile==&lt;br /&gt;
&lt;br /&gt;
Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.&lt;br /&gt;
&lt;br /&gt;
One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of background functions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_refactoring Code Refactoring]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_smell Code smell]&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95723</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95723"/>
		<updated>2015-03-23T18:48:41Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1501: Refactoring Assignments.rb'''&lt;br /&gt;
&lt;br /&gt;
This page provides information about a project which aims to refactor Assignment.rb file present in Expertiza OSS.&lt;br /&gt;
&lt;br /&gt;
'''Introduction to Expertiza'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews, which makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Assignment.rb is a file which contains the assignment model and the related functionality. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains the functions responsible for grading.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; The assignment model needed a refactoring as it contains some modules which were responsible for generating assignment scores. Moreover, the querying module was database dependent which was made database independent. There were many function names and code lines which were not following the ruby guidelines. They were changed to more ruby like coding style. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate model scorable.rb===&lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
&amp;lt;p&amp;gt;1.get_scores&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;2.get_max_score_possible&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;3.compute_reviews_hash&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;4.get_average_score&amp;lt;/p&amp;gt;&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding style was not according to ruby guidelines. The code was refactored to be more ruby like. Changes such as removing the return statements, writing .each instead of for loop and improving naming conventions were implemented. Some of the changes are described below:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Addition of ActiveRecord like Query==&lt;br /&gt;
&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Changing Gemfile==&lt;br /&gt;
&lt;br /&gt;
Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.&lt;br /&gt;
&lt;br /&gt;
One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of background functions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_refactoring Code Refactoring]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_smell Code smell]&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95720</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95720"/>
		<updated>2015-03-23T18:45:22Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1501: Refactoring Assignments.rb'''&lt;br /&gt;
&lt;br /&gt;
This page provides information about a project which aims to refactor Assignment.rb file present in Expertiza OSS.&lt;br /&gt;
&lt;br /&gt;
'''Introduction to Expertiza'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews, which makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Assignment.rb is a file which contains the assignment model and the related functionality. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains the functions responsible for grading.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; The assignment model needed a refactoring as it contains some modules which were responsible for generating assignment scores. Moreover, the querying module was database dependent which was made database independent. There were many function names and code lines which were not following the ruby guidelines. They were changed to more ruby like coding style. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate model scorable.rb===&lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
&amp;lt;p&amp;gt;1.get_scores&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;2.get_max_score_possible&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;3.compute_reviews_hash&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;4.get_average_score&amp;lt;/p&amp;gt;&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding style was not according to ruby guidelines. The code was refactored to be more ruby like. Changes such as removing the return type, writing .each instead of for loop and improved naming conventions were implemented. Some of the changes are described below:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Addition of ActiveRecord like Query==&lt;br /&gt;
&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 3 : Changing Gemfile==&lt;br /&gt;
&lt;br /&gt;
Version of gem &amp;quot;EventMachine&amp;quot; was updated as earlier version was incompatible with ruby version 2.2.0. The version was changed from 1.0.3 to 1.0.7.&lt;br /&gt;
&lt;br /&gt;
One more gem &amp;quot;quite_assets&amp;quot; was added to avoid unnecessary log creation of background functions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Refactoring view code into relevant views ===&lt;br /&gt;
There were no edit/delete links to edit/delete a topic in the instructor view. These had to be conditionally added based on the role of the currently logged in user. This was to prevent students from editing/deleting topics and to keep instructors from signing up for a topic. This was implemented as follows.&lt;br /&gt;
&lt;br /&gt;
===Adding Edit/Delete functionality to topics tab===&lt;br /&gt;
&lt;br /&gt;
The current expertiza project had two views to display the Actions column in the topics table. These were _reserve_topics.html.erb and _actions.html. The first one was displaying the signup button for the student and the latter was displaying the bookmarks and rendering the _reserve_topics.html.erb after the bookmarks. On top of this we had to add the edit/delete links for the instructor. A refactor was called for. We decided to create a _all_actions.html.erb partial which had the responsibility to display the relevant actions depending upon the role of the currently logged in user. This helped us remove the separate partial to render actions pertaining to a student, namely _reserve_topics.html.erb . Also the _actions.html.erb only took care of displaying the bookmark links rather than dealing with both bookmarks and actions. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;partial_view:_all_actions,html.erb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if ['Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator'].include? current_user_role?.name %&amp;gt;&lt;br /&gt;
    &amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;%= link_to image_tag('edit_icon.png', :border =&amp;gt; 0, :title =&amp;gt; 'Edit Topic', :align =&amp;gt; 'middle'), :controller=&amp;gt;'sign_up_sheet', :action=&amp;gt; 'edit', :id =&amp;gt; topic.id %&amp;gt;&lt;br /&gt;
      &amp;lt;%= link_to image_tag('delete_icon.png', :border =&amp;gt; 0, :title =&amp;gt; 'Delete Topic', :align =&amp;gt; 'middle'), sign_up_sheet_path(topic.id), method: :delete, data: {confirm: 'Are you sure?'} %&amp;gt;&lt;br /&gt;
&amp;lt;%elsif @show_actions %&amp;gt; &lt;br /&gt;
    ... &lt;br /&gt;
    #Render signup button for student here. The @show_actions will be true if this partial is navigated from the SignupSheetController which is accessible only to students.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Cleaning up unused code ==&lt;br /&gt;
The Refactors mentioned above enable us to delete unused partials namely:&lt;br /&gt;
&lt;br /&gt;
*assignments controller partials :&lt;br /&gt;
**_add_signup_topics.html.erb&lt;br /&gt;
**_reserve_topic.html.erb&lt;br /&gt;
&lt;br /&gt;
*signup_sheet_controller partials :&lt;br /&gt;
**_reserve_topic.html.erb&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://152.46.18.5:3000/ VCL link] - This might not be available after Nov. 2014&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
#[https://docs.google.com/document/d/1FZCL9KWSdVNsX9BowuZ3gxbCOJoiWX-GVLctSZei3No The OSS project requirements doc (Fall 2014 - Expertiza)]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_refactoring Code Refactoring]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_smell Code smell]&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95716</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95716"/>
		<updated>2015-03-23T18:35:44Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1501: Refactoring Assignments.rb'''&lt;br /&gt;
&lt;br /&gt;
This page provides information about a project which aims to refactor Assignment.rb file present in Expertiza OSS.&lt;br /&gt;
&lt;br /&gt;
'''Introduction to Expertiza'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews, which makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Assignment.rb is a file which contains the assignment model and the related functionality. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains the functions responsible for grading.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; The assignment model needed a refactoring as it contains some modules which were responsible for generating assignment scores. Moreover, the querying module was database dependent which was made database independent. There were many function names and code lines which were not following the ruby guidelines. They were changed to more ruby like coding style. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate model scorable.rb===&lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
&amp;lt;p&amp;gt;1.get_scores&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;2.get_max_score_possible&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;3.compute_reviews_hash&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;4.get_average_score&amp;lt;/p&amp;gt;&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding style was not according to ruby guidelines. The code was refactored to be more ruby like. Changes such as removing the return type, writing .each instead of for loop and improved naming conventions were implemented. Some of the changes are described below:&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Addition of ActiveRecord like Query==&lt;br /&gt;
&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactoring view code into relevant views ===&lt;br /&gt;
There were no edit/delete links to edit/delete a topic in the instructor view. These had to be conditionally added based on the role of the currently logged in user. This was to prevent students from editing/deleting topics and to keep instructors from signing up for a topic. This was implemented as follows.&lt;br /&gt;
&lt;br /&gt;
===Adding Edit/Delete functionality to topics tab===&lt;br /&gt;
&lt;br /&gt;
The current expertiza project had two views to display the Actions column in the topics table. These were _reserve_topics.html.erb and _actions.html. The first one was displaying the signup button for the student and the latter was displaying the bookmarks and rendering the _reserve_topics.html.erb after the bookmarks. On top of this we had to add the edit/delete links for the instructor. A refactor was called for. We decided to create a _all_actions.html.erb partial which had the responsibility to display the relevant actions depending upon the role of the currently logged in user. This helped us remove the separate partial to render actions pertaining to a student, namely _reserve_topics.html.erb . Also the _actions.html.erb only took care of displaying the bookmark links rather than dealing with both bookmarks and actions. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;partial_view:_all_actions,html.erb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if ['Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator'].include? current_user_role?.name %&amp;gt;&lt;br /&gt;
    &amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;%= link_to image_tag('edit_icon.png', :border =&amp;gt; 0, :title =&amp;gt; 'Edit Topic', :align =&amp;gt; 'middle'), :controller=&amp;gt;'sign_up_sheet', :action=&amp;gt; 'edit', :id =&amp;gt; topic.id %&amp;gt;&lt;br /&gt;
      &amp;lt;%= link_to image_tag('delete_icon.png', :border =&amp;gt; 0, :title =&amp;gt; 'Delete Topic', :align =&amp;gt; 'middle'), sign_up_sheet_path(topic.id), method: :delete, data: {confirm: 'Are you sure?'} %&amp;gt;&lt;br /&gt;
&amp;lt;%elsif @show_actions %&amp;gt; &lt;br /&gt;
    ... &lt;br /&gt;
    #Render signup button for student here. The @show_actions will be true if this partial is navigated from the SignupSheetController which is accessible only to students.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Cleaning up unused code ==&lt;br /&gt;
The Refactors mentioned above enable us to delete unused partials namely:&lt;br /&gt;
&lt;br /&gt;
*assignments controller partials :&lt;br /&gt;
**_add_signup_topics.html.erb&lt;br /&gt;
**_reserve_topic.html.erb&lt;br /&gt;
&lt;br /&gt;
*signup_sheet_controller partials :&lt;br /&gt;
**_reserve_topic.html.erb&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://152.46.18.5:3000/ VCL link] - This might not be available after Nov. 2014&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
#[https://docs.google.com/document/d/1FZCL9KWSdVNsX9BowuZ3gxbCOJoiWX-GVLctSZei3No The OSS project requirements doc (Fall 2014 - Expertiza)]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_refactoring Code Refactoring]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_smell Code smell]&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95715</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95715"/>
		<updated>2015-03-23T18:34:46Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1501: Refactoring Assignments.rb'''&lt;br /&gt;
&lt;br /&gt;
This page provides information about a project which aims to refactor Assignment.rb file present in Expertiza OSS.&lt;br /&gt;
&lt;br /&gt;
'''Introduction to Expertiza'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews, which makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Assignment.rb is a file which contains the assignment model and the related functionality. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains the functions responsible for grading.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; The assignment model needed a refactoring as it contains some modules which were responsible for generating assignment scores. Moreover, the querying module was database dependent which was made database independent. There were many function names and code lines which were not following the ruby guidelines. They were changed to more ruby like coding style. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate model scorable.rb===&lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
&amp;lt;p&amp;gt;1.get_scores&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;2.get_max_score_possible&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;3.compute_reviews_hash&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;4.get_average_score&amp;lt;/p&amp;gt;&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding style was not according to ruby guidelines. The code was refactored to be more ruby like. Changes such as removing the return type, writing .each instead of for loop and improved naming conventions were implemented. Some of the changes are described below:&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Addition of ActiveRecord like Query==&lt;br /&gt;
&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
'''Before Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Change'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactoring view code into relevant views ===&lt;br /&gt;
There were no edit/delete links to edit/delete a topic in the instructor view. These had to be conditionally added based on the role of the currently logged in user. This was to prevent students from editing/deleting topics and to keep instructors from signing up for a topic. This was implemented as follows.&lt;br /&gt;
&lt;br /&gt;
===Adding Edit/Delete functionality to topics tab===&lt;br /&gt;
&lt;br /&gt;
The current expertiza project had two views to display the Actions column in the topics table. These were _reserve_topics.html.erb and _actions.html. The first one was displaying the signup button for the student and the latter was displaying the bookmarks and rendering the _reserve_topics.html.erb after the bookmarks. On top of this we had to add the edit/delete links for the instructor. A refactor was called for. We decided to create a _all_actions.html.erb partial which had the responsibility to display the relevant actions depending upon the role of the currently logged in user. This helped us remove the separate partial to render actions pertaining to a student, namely _reserve_topics.html.erb . Also the _actions.html.erb only took care of displaying the bookmark links rather than dealing with both bookmarks and actions. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;partial_view:_all_actions,html.erb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if ['Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator'].include? current_user_role?.name %&amp;gt;&lt;br /&gt;
    &amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;%= link_to image_tag('edit_icon.png', :border =&amp;gt; 0, :title =&amp;gt; 'Edit Topic', :align =&amp;gt; 'middle'), :controller=&amp;gt;'sign_up_sheet', :action=&amp;gt; 'edit', :id =&amp;gt; topic.id %&amp;gt;&lt;br /&gt;
      &amp;lt;%= link_to image_tag('delete_icon.png', :border =&amp;gt; 0, :title =&amp;gt; 'Delete Topic', :align =&amp;gt; 'middle'), sign_up_sheet_path(topic.id), method: :delete, data: {confirm: 'Are you sure?'} %&amp;gt;&lt;br /&gt;
&amp;lt;%elsif @show_actions %&amp;gt; &lt;br /&gt;
    ... &lt;br /&gt;
    #Render signup button for student here. The @show_actions will be true if this partial is navigated from the SignupSheetController which is accessible only to students.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Cleaning up unused code ==&lt;br /&gt;
The Refactors mentioned above enable us to delete unused partials namely:&lt;br /&gt;
&lt;br /&gt;
*assignments controller partials :&lt;br /&gt;
**_add_signup_topics.html.erb&lt;br /&gt;
**_reserve_topic.html.erb&lt;br /&gt;
&lt;br /&gt;
*signup_sheet_controller partials :&lt;br /&gt;
**_reserve_topic.html.erb&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://152.46.18.5:3000/ VCL link] - This might not be available after Nov. 2014&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
#[https://docs.google.com/document/d/1FZCL9KWSdVNsX9BowuZ3gxbCOJoiWX-GVLctSZei3No The OSS project requirements doc (Fall 2014 - Expertiza)]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_refactoring Code Refactoring]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_smell Code smell]&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95714</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95714"/>
		<updated>2015-03-23T18:33:31Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1501: Refactoring Assignments.rb'''&lt;br /&gt;
&lt;br /&gt;
This page provides information about a project which aims to refactor Assignment.rb file present in Expertiza OSS.&lt;br /&gt;
&lt;br /&gt;
'''Introduction to Expertiza'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews, which makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Assignment.rb is a file which contains the assignment model and the related functionality. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains the functions responsible for grading.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; The assignment model needed a refactoring as it contains some modules which were responsible for generating assignment scores. Moreover, the querying module was database dependent which was made database independent. There were many function names and code lines which were not following the ruby guidelines. They were changed to more ruby like coding style. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate model scorable.rb===&lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
&amp;lt;p&amp;gt;1.get_scores&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;2.get_max_score_possible&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;3.compute_reviews_hash&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;4.get_average_score&amp;lt;/p&amp;gt;&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
There were many instances where the coding style was not according to ruby guidelines. The code was refactored to be more ruby like. Changes such as removing the return type, writing .each instead of for loop and improved naming conventions were implemented. Some of the changes are described below:&lt;br /&gt;
===Before Change===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_response_mappings.each do |qmapping|&lt;br /&gt;
   if qmapping.response&lt;br /&gt;
     quiz_responses &amp;lt;&amp;lt; qmapping.response&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===After Change===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 quiz_responses = quiz_response_mappings.select{ |qmapping| qmapping.response }.map(&amp;amp;:response)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Before Change===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 total = 0&lt;br /&gt;
 self.questionnaires.each { |questionnaire| total += questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
 total&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===After Change===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 self.questionnaires.inject(0) { |total, questionnaire| total + questionnaire.get_weighted_score(self, scores) }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Instance 2 : Addition of ActiveRecord like Query==&lt;br /&gt;
&lt;br /&gt;
The queries where changed to function more like active record query. This made the queries database independent and more user friendly.&lt;br /&gt;
&lt;br /&gt;
===Before Change===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where( ['assignment_id = ? and deadline_type_id &amp;gt;= ?', self.id, 7]).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===After Change===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  DueDate.where(assignment_id: self.id, deadline_type_id: 7).due_at&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactoring view code into relevant views ===&lt;br /&gt;
There were no edit/delete links to edit/delete a topic in the instructor view. These had to be conditionally added based on the role of the currently logged in user. This was to prevent students from editing/deleting topics and to keep instructors from signing up for a topic. This was implemented as follows.&lt;br /&gt;
&lt;br /&gt;
===Adding Edit/Delete functionality to topics tab===&lt;br /&gt;
&lt;br /&gt;
The current expertiza project had two views to display the Actions column in the topics table. These were _reserve_topics.html.erb and _actions.html. The first one was displaying the signup button for the student and the latter was displaying the bookmarks and rendering the _reserve_topics.html.erb after the bookmarks. On top of this we had to add the edit/delete links for the instructor. A refactor was called for. We decided to create a _all_actions.html.erb partial which had the responsibility to display the relevant actions depending upon the role of the currently logged in user. This helped us remove the separate partial to render actions pertaining to a student, namely _reserve_topics.html.erb . Also the _actions.html.erb only took care of displaying the bookmark links rather than dealing with both bookmarks and actions. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;partial_view:_all_actions,html.erb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if ['Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator'].include? current_user_role?.name %&amp;gt;&lt;br /&gt;
    &amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;%= link_to image_tag('edit_icon.png', :border =&amp;gt; 0, :title =&amp;gt; 'Edit Topic', :align =&amp;gt; 'middle'), :controller=&amp;gt;'sign_up_sheet', :action=&amp;gt; 'edit', :id =&amp;gt; topic.id %&amp;gt;&lt;br /&gt;
      &amp;lt;%= link_to image_tag('delete_icon.png', :border =&amp;gt; 0, :title =&amp;gt; 'Delete Topic', :align =&amp;gt; 'middle'), sign_up_sheet_path(topic.id), method: :delete, data: {confirm: 'Are you sure?'} %&amp;gt;&lt;br /&gt;
&amp;lt;%elsif @show_actions %&amp;gt; &lt;br /&gt;
    ... &lt;br /&gt;
    #Render signup button for student here. The @show_actions will be true if this partial is navigated from the SignupSheetController which is accessible only to students.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Cleaning up unused code ==&lt;br /&gt;
The Refactors mentioned above enable us to delete unused partials namely:&lt;br /&gt;
&lt;br /&gt;
*assignments controller partials :&lt;br /&gt;
**_add_signup_topics.html.erb&lt;br /&gt;
**_reserve_topic.html.erb&lt;br /&gt;
&lt;br /&gt;
*signup_sheet_controller partials :&lt;br /&gt;
**_reserve_topic.html.erb&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://152.46.18.5:3000/ VCL link] - This might not be available after Nov. 2014&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
#[https://docs.google.com/document/d/1FZCL9KWSdVNsX9BowuZ3gxbCOJoiWX-GVLctSZei3No The OSS project requirements doc (Fall 2014 - Expertiza)]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_refactoring Code Refactoring]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_smell Code smell]&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95713</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95713"/>
		<updated>2015-03-23T18:21:24Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1501: Refactoring Assignments.rb'''&lt;br /&gt;
&lt;br /&gt;
This page provides information about a project which aims to refactor Assignment.rb file present in Expertiza OSS.&lt;br /&gt;
&lt;br /&gt;
'''Introduction to Expertiza'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews, which makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Assignment.rb is a file which contains the assignment model and the related functionality. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains the functions responsible for grading.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; The assignment model needed a refactoring as it contains some modules which were responsible for generating assignment scores. Moreover, the querying module was database dependent which was made database independent. There were many function names and code lines which were not following the ruby guidelines. They were changed to more ruby like coding style. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate model scorable.rb===&lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
&amp;lt;p&amp;gt;1.get_scores&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;2.get_max_score_possible&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;3.compute_reviews_hash&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;4.get_average_score&amp;lt;/p&amp;gt;&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&lt;br /&gt;
===Make assignment.rb more Ruby like===&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
This view contains all the tabs to display like general,rubrics,review_strategy, topics which are related to the selected assignment. tabs-5 is the topics tab which we are interested in.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-3&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/review_strategy' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-4&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/due_dates' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-5&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/add_signup_topics' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;pre&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-3&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/review_strategy' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-4&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/due_dates' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-5&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render '/sign_up_sheet/add_signup_topcis.html' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactoring view code into relevant views ===&lt;br /&gt;
There were no edit/delete links to edit/delete a topic in the instructor view. These had to be conditionally added based on the role of the currently logged in user. This was to prevent students from editing/deleting topics and to keep instructors from signing up for a topic. This was implemented as follows.&lt;br /&gt;
&lt;br /&gt;
===Adding Edit/Delete functionality to topics tab===&lt;br /&gt;
&lt;br /&gt;
The current expertiza project had two views to display the Actions column in the topics table. These were _reserve_topics.html.erb and _actions.html. The first one was displaying the signup button for the student and the latter was displaying the bookmarks and rendering the _reserve_topics.html.erb after the bookmarks. On top of this we had to add the edit/delete links for the instructor. A refactor was called for. We decided to create a _all_actions.html.erb partial which had the responsibility to display the relevant actions depending upon the role of the currently logged in user. This helped us remove the separate partial to render actions pertaining to a student, namely _reserve_topics.html.erb . Also the _actions.html.erb only took care of displaying the bookmark links rather than dealing with both bookmarks and actions. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;partial_view:_all_actions,html.erb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if ['Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator'].include? current_user_role?.name %&amp;gt;&lt;br /&gt;
    &amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;%= link_to image_tag('edit_icon.png', :border =&amp;gt; 0, :title =&amp;gt; 'Edit Topic', :align =&amp;gt; 'middle'), :controller=&amp;gt;'sign_up_sheet', :action=&amp;gt; 'edit', :id =&amp;gt; topic.id %&amp;gt;&lt;br /&gt;
      &amp;lt;%= link_to image_tag('delete_icon.png', :border =&amp;gt; 0, :title =&amp;gt; 'Delete Topic', :align =&amp;gt; 'middle'), sign_up_sheet_path(topic.id), method: :delete, data: {confirm: 'Are you sure?'} %&amp;gt;&lt;br /&gt;
&amp;lt;%elsif @show_actions %&amp;gt; &lt;br /&gt;
    ... &lt;br /&gt;
    #Render signup button for student here. The @show_actions will be true if this partial is navigated from the SignupSheetController which is accessible only to students.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Cleaning up unused code ==&lt;br /&gt;
The Refactors mentioned above enable us to delete unused partials namely:&lt;br /&gt;
&lt;br /&gt;
*assignments controller partials :&lt;br /&gt;
**_add_signup_topics.html.erb&lt;br /&gt;
**_reserve_topic.html.erb&lt;br /&gt;
&lt;br /&gt;
*signup_sheet_controller partials :&lt;br /&gt;
**_reserve_topic.html.erb&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://152.46.18.5:3000/ VCL link] - This might not be available after Nov. 2014&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
#[https://docs.google.com/document/d/1FZCL9KWSdVNsX9BowuZ3gxbCOJoiWX-GVLctSZei3No The OSS project requirements doc (Fall 2014 - Expertiza)]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_refactoring Code Refactoring]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_smell Code smell]&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95708</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95708"/>
		<updated>2015-03-23T18:18:54Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1501: Refactoring Assignments.rb'''&lt;br /&gt;
&lt;br /&gt;
This page provides information about a project which aims to refactor Assignment.rb file present in Expertiza OSS.&lt;br /&gt;
&lt;br /&gt;
'''Introduction to Expertiza'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews, which makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Assignment.rb is a file which contains the assignment model and the related functionality. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains the functions responsible for grading.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; The assignment model needed a refactoring as it contains some modules which were responsible for generating assignment scores. Moreover, the querying module was database dependent which was made database independent. There were many function names and code lines which were not following the ruby guidelines. They were changed to more ruby like coding style. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Re-factored Instances =&lt;br /&gt;
&lt;br /&gt;
== Instance 1 : Refactoring the Assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
===Creation of separate model scorable.rb===&lt;br /&gt;
There are many methods which are not directly related to assignments. These methods are responsible for generating the scores and related functions. These methods are:&lt;br /&gt;
&amp;lt;p&amp;gt;1.get_scores&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;2.get_max_score_possible&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;3.compute_reviews_hash&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;4.get_average_score&amp;lt;/p&amp;gt;&lt;br /&gt;
All these methods are taken out of assignment.rb and pushed into a new file &amp;quot;scorable.rb&amp;quot;. This made score generation a separate module and the dependency of scores on assignments have been reduced significantly. &lt;br /&gt;
&amp;lt;b&amp;gt;view:assignments/edit.html.erb&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This view contains all the tabs to display like general,rubrics,review_strategy, topics which are related to the selected assignment. tabs-5 is the topics tab which we are interested in.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-3&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/review_strategy' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-4&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/due_dates' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-5&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/add_signup_topics' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;pre&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-3&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/review_strategy' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-4&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/due_dates' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-5&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render '/sign_up_sheet/add_signup_topcis.html' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactoring view code into relevant views ===&lt;br /&gt;
There were no edit/delete links to edit/delete a topic in the instructor view. These had to be conditionally added based on the role of the currently logged in user. This was to prevent students from editing/deleting topics and to keep instructors from signing up for a topic. This was implemented as follows.&lt;br /&gt;
&lt;br /&gt;
===Adding Edit/Delete functionality to topics tab===&lt;br /&gt;
&lt;br /&gt;
The current expertiza project had two views to display the Actions column in the topics table. These were _reserve_topics.html.erb and _actions.html. The first one was displaying the signup button for the student and the latter was displaying the bookmarks and rendering the _reserve_topics.html.erb after the bookmarks. On top of this we had to add the edit/delete links for the instructor. A refactor was called for. We decided to create a _all_actions.html.erb partial which had the responsibility to display the relevant actions depending upon the role of the currently logged in user. This helped us remove the separate partial to render actions pertaining to a student, namely _reserve_topics.html.erb . Also the _actions.html.erb only took care of displaying the bookmark links rather than dealing with both bookmarks and actions. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;partial_view:_all_actions,html.erb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if ['Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator'].include? current_user_role?.name %&amp;gt;&lt;br /&gt;
    &amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;%= link_to image_tag('edit_icon.png', :border =&amp;gt; 0, :title =&amp;gt; 'Edit Topic', :align =&amp;gt; 'middle'), :controller=&amp;gt;'sign_up_sheet', :action=&amp;gt; 'edit', :id =&amp;gt; topic.id %&amp;gt;&lt;br /&gt;
      &amp;lt;%= link_to image_tag('delete_icon.png', :border =&amp;gt; 0, :title =&amp;gt; 'Delete Topic', :align =&amp;gt; 'middle'), sign_up_sheet_path(topic.id), method: :delete, data: {confirm: 'Are you sure?'} %&amp;gt;&lt;br /&gt;
&amp;lt;%elsif @show_actions %&amp;gt; &lt;br /&gt;
    ... &lt;br /&gt;
    #Render signup button for student here. The @show_actions will be true if this partial is navigated from the SignupSheetController which is accessible only to students.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Cleaning up unused code ==&lt;br /&gt;
The Refactors mentioned above enable us to delete unused partials namely:&lt;br /&gt;
&lt;br /&gt;
*assignments controller partials :&lt;br /&gt;
**_add_signup_topics.html.erb&lt;br /&gt;
**_reserve_topic.html.erb&lt;br /&gt;
&lt;br /&gt;
*signup_sheet_controller partials :&lt;br /&gt;
**_reserve_topic.html.erb&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://152.46.18.5:3000/ VCL link] - This might not be available after Nov. 2014&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
#[https://docs.google.com/document/d/1FZCL9KWSdVNsX9BowuZ3gxbCOJoiWX-GVLctSZei3No The OSS project requirements doc (Fall 2014 - Expertiza)]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_refactoring Code Refactoring]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_smell Code smell]&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95696</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95696"/>
		<updated>2015-03-23T18:02:03Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1501: Refactoring Assignments.rb'''&lt;br /&gt;
&lt;br /&gt;
This page provides information about a project which aims to refactor Assignment.rb file present in Expertiza OSS.&lt;br /&gt;
&lt;br /&gt;
'''Introduction to Expertiza'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews, which makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Assignment.rb is a file which contains the assignment model and the related functionality. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains the functions responsible for grading.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt; The assignment model needed a refactoring as it contains some modules which were responsible for generating assignment scores. Moreover, the querying module was database dependent which was made database independent. There were many function names and code lines which were not following the ruby guidelines. They were changed to more ruby like coding style. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Changes Made=&lt;br /&gt;
&lt;br /&gt;
==SignupSheet Controller==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|Method Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Changes Made &lt;br /&gt;
! style=&amp;quot;width:43%;&amp;quot;|Reason For Change&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| create&lt;br /&gt;
| Fixed redirection after topic creation to Topics tab&lt;br /&gt;
| On successful creation of a topic, the action was merely redirecting to the assignments/edit view&lt;br /&gt;
|-&lt;br /&gt;
| update&lt;br /&gt;
| Fixed redirection after topic updation to Topics tab&lt;br /&gt;
| Once a topic was successfully edited, the view rendered was just a list of topics&lt;br /&gt;
|-&lt;br /&gt;
| edit&lt;br /&gt;
| Initialized @assignment_id variable&lt;br /&gt;
| The variable is used in the edit view&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; valign=&amp;quot;middle&amp;quot; |&lt;br /&gt;
destroy&lt;br /&gt;
| Renamed the 'delete' method to 'destroy'&lt;br /&gt;
| This was done for better Rails 4 routing compatibility&lt;br /&gt;
|-&lt;br /&gt;
| Initialized the assignment_id parameter&lt;br /&gt;
| This is used further on and is not passed from the link URL&lt;br /&gt;
|-&lt;br /&gt;
| Fixed redirection after topic deletion to Topics tab&lt;br /&gt;
| Once a topic was successfully deleted, the view rendered was just a list of topics&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Views==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:18%;&amp;quot;|View Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Changes Made &lt;br /&gt;
! style=&amp;quot;width:43%;&amp;quot;|Reason For Change&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| rowspan=&amp;quot;5&amp;quot; valign=&amp;quot;middle&amp;quot; |&lt;br /&gt;
sign_up_sheet/_add_signup_topcis&lt;br /&gt;
| Fixed title&lt;br /&gt;
| The page title displayed for an instructor was &amp;quot;Sign-up sheet for ... &amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Commented out View/Manage bookmark links&lt;br /&gt;
| These links were broken, and according to existing code were not meant for the instructor view.&lt;br /&gt;
|-&lt;br /&gt;
| Added variable initialization for @sign_up_topics&lt;br /&gt;
| The variable was referenced further on in the view, which was causing an 'nil value' error&lt;br /&gt;
|-&lt;br /&gt;
| Fixed flash message rendering for new topic creation&lt;br /&gt;
| The flash message was rendering incorrectly with HTML tags visible on the web page&lt;br /&gt;
|-&lt;br /&gt;
| Added full path names to partial names&lt;br /&gt;
| The shared partials were also being used by views in the Assignments controller, so full paths were needed&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/_add_topics&lt;br /&gt;
| Added separation between the Import Topics and Manage Bookmarks links&lt;br /&gt;
| The two links were clumped together and it was difficult to distinguish between them&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/_actions&lt;br /&gt;
| Replaced rendering of the reserve_topic partial with the _all_actions partial&lt;br /&gt;
| The reserve_topic partial is no longer being used and is replaced by the newly created _all_actions partial&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/_all_actions&lt;br /&gt;
| Created this new partial&lt;br /&gt;
| We created the _all_actions partial to conditionally render the &amp;quot;Actions&amp;quot; table field for both instructors and students. This now also includes working links through which instructors or administrators can edit or delete topics.&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/_table_line&lt;br /&gt;
| Gave edit/delete rights to Super Admin&lt;br /&gt;
| The Super-Administrator user wasn't included in the list of users with these permissions&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/edit&lt;br /&gt;
| Modified title and included @assignment_id variable to be passed as a parameter variable to the update action&lt;br /&gt;
| The view was initially trying to access the params[:assignment_id] variable which was not getting initialized&lt;br /&gt;
|-&lt;br /&gt;
| assignments/edit&lt;br /&gt;
| Changed the partial rendered to /sign_up_sheet/add_signup_topcis.html&lt;br /&gt;
| The assignments/edit/add_signup_topics partial (with duplicated code) was otherwise being rendered&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring the AssignmentsController and SignupSheetController ==&lt;br /&gt;
&lt;br /&gt;
===Removing duplicate _add_signup_topics partials===&lt;br /&gt;
The AssignmentsController displayed topics to the instructor while he was editing an assignment. It used _add_signup_topics.html.erb partial to render topics under the topics tab. The SignupSheetController displayed topics to a student who wanted to view signup topics under an assignment. It was found that it had its own copy namely _add_signup_topcis.html.erb to display topics to the student. We wanted to have these two controllers use the same views to render the same thing which was list of topics under an assignment. We made the AssignmentsController reuse the _add_signup_topcis.html.erb partial under the SignupSheetController.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;view:assignments/edit.html.erb&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This view contains all the tabs to display like general,rubrics,review_strategy, topics which are related to the selected assignment. tabs-5 is the topics tab which we are interested in.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-3&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/review_strategy' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-4&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/due_dates' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-5&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/add_signup_topics' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;pre&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-3&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/review_strategy' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-4&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/due_dates' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-5&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render '/sign_up_sheet/add_signup_topcis.html' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactoring view code into relevant views ===&lt;br /&gt;
There were no edit/delete links to edit/delete a topic in the instructor view. These had to be conditionally added based on the role of the currently logged in user. This was to prevent students from editing/deleting topics and to keep instructors from signing up for a topic. This was implemented as follows.&lt;br /&gt;
&lt;br /&gt;
===Adding Edit/Delete functionality to topics tab===&lt;br /&gt;
&lt;br /&gt;
The current expertiza project had two views to display the Actions column in the topics table. These were _reserve_topics.html.erb and _actions.html. The first one was displaying the signup button for the student and the latter was displaying the bookmarks and rendering the _reserve_topics.html.erb after the bookmarks. On top of this we had to add the edit/delete links for the instructor. A refactor was called for. We decided to create a _all_actions.html.erb partial which had the responsibility to display the relevant actions depending upon the role of the currently logged in user. This helped us remove the separate partial to render actions pertaining to a student, namely _reserve_topics.html.erb . Also the _actions.html.erb only took care of displaying the bookmark links rather than dealing with both bookmarks and actions. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;partial_view:_all_actions,html.erb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if ['Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator'].include? current_user_role?.name %&amp;gt;&lt;br /&gt;
    &amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;%= link_to image_tag('edit_icon.png', :border =&amp;gt; 0, :title =&amp;gt; 'Edit Topic', :align =&amp;gt; 'middle'), :controller=&amp;gt;'sign_up_sheet', :action=&amp;gt; 'edit', :id =&amp;gt; topic.id %&amp;gt;&lt;br /&gt;
      &amp;lt;%= link_to image_tag('delete_icon.png', :border =&amp;gt; 0, :title =&amp;gt; 'Delete Topic', :align =&amp;gt; 'middle'), sign_up_sheet_path(topic.id), method: :delete, data: {confirm: 'Are you sure?'} %&amp;gt;&lt;br /&gt;
&amp;lt;%elsif @show_actions %&amp;gt; &lt;br /&gt;
    ... &lt;br /&gt;
    #Render signup button for student here. The @show_actions will be true if this partial is navigated from the SignupSheetController which is accessible only to students.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Cleaning up unused code ==&lt;br /&gt;
The Refactors mentioned above enable us to delete unused partials namely:&lt;br /&gt;
&lt;br /&gt;
*assignments controller partials :&lt;br /&gt;
**_add_signup_topics.html.erb&lt;br /&gt;
**_reserve_topic.html.erb&lt;br /&gt;
&lt;br /&gt;
*signup_sheet_controller partials :&lt;br /&gt;
**_reserve_topic.html.erb&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://152.46.18.5:3000/ VCL link] - This might not be available after Nov. 2014&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
#[https://docs.google.com/document/d/1FZCL9KWSdVNsX9BowuZ3gxbCOJoiWX-GVLctSZei3No The OSS project requirements doc (Fall 2014 - Expertiza)]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_refactoring Code Refactoring]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_smell Code smell]&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95609</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95609"/>
		<updated>2015-03-23T05:42:57Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1501: Refactoring Assignments.rb'''&lt;br /&gt;
&lt;br /&gt;
This page provides information about a project which aims to refactor Assignment.rb file present in Expertiza OSS.&lt;br /&gt;
&lt;br /&gt;
'''Introduction to Expertiza'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews, which makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Assignment.rb is a file which contains the assignment model and the related functionality. It also contains the score module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains the functions responsible for grading.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt;The &amp;lt;b&amp;gt;Topics&amp;lt;/b&amp;gt; tab in the &amp;lt;b&amp;gt;Assignments --&amp;gt; Edit&amp;lt;/b&amp;gt; view is not usable right now by an instructor when he/she is editing an assignment.  The functionality that displays topics also needs to be usable by the student view, since students also have to view the list of topics (when they sign up for a topic).  Instructor and student functionality is a little different: instructors can add topics and change the number of slots, but they can’t sign up for topics. The Topics tab needs to be fixed, edit/delete topic functionality is to be added for instructors and common/duplicate code needs to be refactored.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The functionality to display the topics under an assignment is duplicated between the AssignmentController views and the SignupSheetController views. Both the instructor and the student can view the topics by selecting an assignment and we were required to remove this duplication in the views. Consequently, most of our work dealt with modifying the SignupSheetController and its corresponding views.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Changes Made=&lt;br /&gt;
&lt;br /&gt;
==SignupSheet Controller==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|Method Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Changes Made &lt;br /&gt;
! style=&amp;quot;width:43%;&amp;quot;|Reason For Change&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| create&lt;br /&gt;
| Fixed redirection after topic creation to Topics tab&lt;br /&gt;
| On successful creation of a topic, the action was merely redirecting to the assignments/edit view&lt;br /&gt;
|-&lt;br /&gt;
| update&lt;br /&gt;
| Fixed redirection after topic updation to Topics tab&lt;br /&gt;
| Once a topic was successfully edited, the view rendered was just a list of topics&lt;br /&gt;
|-&lt;br /&gt;
| edit&lt;br /&gt;
| Initialized @assignment_id variable&lt;br /&gt;
| The variable is used in the edit view&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; valign=&amp;quot;middle&amp;quot; |&lt;br /&gt;
destroy&lt;br /&gt;
| Renamed the 'delete' method to 'destroy'&lt;br /&gt;
| This was done for better Rails 4 routing compatibility&lt;br /&gt;
|-&lt;br /&gt;
| Initialized the assignment_id parameter&lt;br /&gt;
| This is used further on and is not passed from the link URL&lt;br /&gt;
|-&lt;br /&gt;
| Fixed redirection after topic deletion to Topics tab&lt;br /&gt;
| Once a topic was successfully deleted, the view rendered was just a list of topics&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Views==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:18%;&amp;quot;|View Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Changes Made &lt;br /&gt;
! style=&amp;quot;width:43%;&amp;quot;|Reason For Change&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| rowspan=&amp;quot;5&amp;quot; valign=&amp;quot;middle&amp;quot; |&lt;br /&gt;
sign_up_sheet/_add_signup_topcis&lt;br /&gt;
| Fixed title&lt;br /&gt;
| The page title displayed for an instructor was &amp;quot;Sign-up sheet for ... &amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Commented out View/Manage bookmark links&lt;br /&gt;
| These links were broken, and according to existing code were not meant for the instructor view.&lt;br /&gt;
|-&lt;br /&gt;
| Added variable initialization for @sign_up_topics&lt;br /&gt;
| The variable was referenced further on in the view, which was causing an 'nil value' error&lt;br /&gt;
|-&lt;br /&gt;
| Fixed flash message rendering for new topic creation&lt;br /&gt;
| The flash message was rendering incorrectly with HTML tags visible on the web page&lt;br /&gt;
|-&lt;br /&gt;
| Added full path names to partial names&lt;br /&gt;
| The shared partials were also being used by views in the Assignments controller, so full paths were needed&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/_add_topics&lt;br /&gt;
| Added separation between the Import Topics and Manage Bookmarks links&lt;br /&gt;
| The two links were clumped together and it was difficult to distinguish between them&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/_actions&lt;br /&gt;
| Replaced rendering of the reserve_topic partial with the _all_actions partial&lt;br /&gt;
| The reserve_topic partial is no longer being used and is replaced by the newly created _all_actions partial&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/_all_actions&lt;br /&gt;
| Created this new partial&lt;br /&gt;
| We created the _all_actions partial to conditionally render the &amp;quot;Actions&amp;quot; table field for both instructors and students. This now also includes working links through which instructors or administrators can edit or delete topics.&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/_table_line&lt;br /&gt;
| Gave edit/delete rights to Super Admin&lt;br /&gt;
| The Super-Administrator user wasn't included in the list of users with these permissions&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/edit&lt;br /&gt;
| Modified title and included @assignment_id variable to be passed as a parameter variable to the update action&lt;br /&gt;
| The view was initially trying to access the params[:assignment_id] variable which was not getting initialized&lt;br /&gt;
|-&lt;br /&gt;
| assignments/edit&lt;br /&gt;
| Changed the partial rendered to /sign_up_sheet/add_signup_topcis.html&lt;br /&gt;
| The assignments/edit/add_signup_topics partial (with duplicated code) was otherwise being rendered&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring the AssignmentsController and SignupSheetController ==&lt;br /&gt;
&lt;br /&gt;
===Removing duplicate _add_signup_topics partials===&lt;br /&gt;
The AssignmentsController displayed topics to the instructor while he was editing an assignment. It used _add_signup_topics.html.erb partial to render topics under the topics tab. The SignupSheetController displayed topics to a student who wanted to view signup topics under an assignment. It was found that it had its own copy namely _add_signup_topcis.html.erb to display topics to the student. We wanted to have these two controllers use the same views to render the same thing which was list of topics under an assignment. We made the AssignmentsController reuse the _add_signup_topcis.html.erb partial under the SignupSheetController.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;view:assignments/edit.html.erb&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This view contains all the tabs to display like general,rubrics,review_strategy, topics which are related to the selected assignment. tabs-5 is the topics tab which we are interested in.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-3&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/review_strategy' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-4&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/due_dates' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-5&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/add_signup_topics' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;pre&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-3&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/review_strategy' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-4&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/due_dates' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-5&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render '/sign_up_sheet/add_signup_topcis.html' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactoring view code into relevant views ===&lt;br /&gt;
There were no edit/delete links to edit/delete a topic in the instructor view. These had to be conditionally added based on the role of the currently logged in user. This was to prevent students from editing/deleting topics and to keep instructors from signing up for a topic. This was implemented as follows.&lt;br /&gt;
&lt;br /&gt;
===Adding Edit/Delete functionality to topics tab===&lt;br /&gt;
&lt;br /&gt;
The current expertiza project had two views to display the Actions column in the topics table. These were _reserve_topics.html.erb and _actions.html. The first one was displaying the signup button for the student and the latter was displaying the bookmarks and rendering the _reserve_topics.html.erb after the bookmarks. On top of this we had to add the edit/delete links for the instructor. A refactor was called for. We decided to create a _all_actions.html.erb partial which had the responsibility to display the relevant actions depending upon the role of the currently logged in user. This helped us remove the separate partial to render actions pertaining to a student, namely _reserve_topics.html.erb . Also the _actions.html.erb only took care of displaying the bookmark links rather than dealing with both bookmarks and actions. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;partial_view:_all_actions,html.erb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if ['Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator'].include? current_user_role?.name %&amp;gt;&lt;br /&gt;
    &amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;%= link_to image_tag('edit_icon.png', :border =&amp;gt; 0, :title =&amp;gt; 'Edit Topic', :align =&amp;gt; 'middle'), :controller=&amp;gt;'sign_up_sheet', :action=&amp;gt; 'edit', :id =&amp;gt; topic.id %&amp;gt;&lt;br /&gt;
      &amp;lt;%= link_to image_tag('delete_icon.png', :border =&amp;gt; 0, :title =&amp;gt; 'Delete Topic', :align =&amp;gt; 'middle'), sign_up_sheet_path(topic.id), method: :delete, data: {confirm: 'Are you sure?'} %&amp;gt;&lt;br /&gt;
&amp;lt;%elsif @show_actions %&amp;gt; &lt;br /&gt;
    ... &lt;br /&gt;
    #Render signup button for student here. The @show_actions will be true if this partial is navigated from the SignupSheetController which is accessible only to students.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Cleaning up unused code ==&lt;br /&gt;
The Refactors mentioned above enable us to delete unused partials namely:&lt;br /&gt;
&lt;br /&gt;
*assignments controller partials :&lt;br /&gt;
**_add_signup_topics.html.erb&lt;br /&gt;
**_reserve_topic.html.erb&lt;br /&gt;
&lt;br /&gt;
*signup_sheet_controller partials :&lt;br /&gt;
**_reserve_topic.html.erb&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://152.46.18.5:3000/ VCL link] - This might not be available after Nov. 2014&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
#[https://docs.google.com/document/d/1FZCL9KWSdVNsX9BowuZ3gxbCOJoiWX-GVLctSZei3No The OSS project requirements doc (Fall 2014 - Expertiza)]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_refactoring Code Refactoring]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_smell Code smell]&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95608</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95608"/>
		<updated>2015-03-23T05:42:26Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1501: Refactoring Assignments.rb'''&lt;br /&gt;
&lt;br /&gt;
This page provides information about a project which aims to refactor Assignment.rb file present in Expertiza OSS.&lt;br /&gt;
&lt;br /&gt;
'''Introduction to Expertiza'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews, which makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Assignment.rb is a file which contains the assignment model and the related functionality. It also contains the grading module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 scorable.rb&lt;br /&gt;
 Gemfile&lt;br /&gt;
 schema.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains the functions responsible for grading.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt;The &amp;lt;b&amp;gt;Topics&amp;lt;/b&amp;gt; tab in the &amp;lt;b&amp;gt;Assignments --&amp;gt; Edit&amp;lt;/b&amp;gt; view is not usable right now by an instructor when he/she is editing an assignment.  The functionality that displays topics also needs to be usable by the student view, since students also have to view the list of topics (when they sign up for a topic).  Instructor and student functionality is a little different: instructors can add topics and change the number of slots, but they can’t sign up for topics. The Topics tab needs to be fixed, edit/delete topic functionality is to be added for instructors and common/duplicate code needs to be refactored.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The functionality to display the topics under an assignment is duplicated between the AssignmentController views and the SignupSheetController views. Both the instructor and the student can view the topics by selecting an assignment and we were required to remove this duplication in the views. Consequently, most of our work dealt with modifying the SignupSheetController and its corresponding views.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Changes Made=&lt;br /&gt;
&lt;br /&gt;
==SignupSheet Controller==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|Method Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Changes Made &lt;br /&gt;
! style=&amp;quot;width:43%;&amp;quot;|Reason For Change&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| create&lt;br /&gt;
| Fixed redirection after topic creation to Topics tab&lt;br /&gt;
| On successful creation of a topic, the action was merely redirecting to the assignments/edit view&lt;br /&gt;
|-&lt;br /&gt;
| update&lt;br /&gt;
| Fixed redirection after topic updation to Topics tab&lt;br /&gt;
| Once a topic was successfully edited, the view rendered was just a list of topics&lt;br /&gt;
|-&lt;br /&gt;
| edit&lt;br /&gt;
| Initialized @assignment_id variable&lt;br /&gt;
| The variable is used in the edit view&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; valign=&amp;quot;middle&amp;quot; |&lt;br /&gt;
destroy&lt;br /&gt;
| Renamed the 'delete' method to 'destroy'&lt;br /&gt;
| This was done for better Rails 4 routing compatibility&lt;br /&gt;
|-&lt;br /&gt;
| Initialized the assignment_id parameter&lt;br /&gt;
| This is used further on and is not passed from the link URL&lt;br /&gt;
|-&lt;br /&gt;
| Fixed redirection after topic deletion to Topics tab&lt;br /&gt;
| Once a topic was successfully deleted, the view rendered was just a list of topics&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Views==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:18%;&amp;quot;|View Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Changes Made &lt;br /&gt;
! style=&amp;quot;width:43%;&amp;quot;|Reason For Change&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| rowspan=&amp;quot;5&amp;quot; valign=&amp;quot;middle&amp;quot; |&lt;br /&gt;
sign_up_sheet/_add_signup_topcis&lt;br /&gt;
| Fixed title&lt;br /&gt;
| The page title displayed for an instructor was &amp;quot;Sign-up sheet for ... &amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Commented out View/Manage bookmark links&lt;br /&gt;
| These links were broken, and according to existing code were not meant for the instructor view.&lt;br /&gt;
|-&lt;br /&gt;
| Added variable initialization for @sign_up_topics&lt;br /&gt;
| The variable was referenced further on in the view, which was causing an 'nil value' error&lt;br /&gt;
|-&lt;br /&gt;
| Fixed flash message rendering for new topic creation&lt;br /&gt;
| The flash message was rendering incorrectly with HTML tags visible on the web page&lt;br /&gt;
|-&lt;br /&gt;
| Added full path names to partial names&lt;br /&gt;
| The shared partials were also being used by views in the Assignments controller, so full paths were needed&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/_add_topics&lt;br /&gt;
| Added separation between the Import Topics and Manage Bookmarks links&lt;br /&gt;
| The two links were clumped together and it was difficult to distinguish between them&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/_actions&lt;br /&gt;
| Replaced rendering of the reserve_topic partial with the _all_actions partial&lt;br /&gt;
| The reserve_topic partial is no longer being used and is replaced by the newly created _all_actions partial&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/_all_actions&lt;br /&gt;
| Created this new partial&lt;br /&gt;
| We created the _all_actions partial to conditionally render the &amp;quot;Actions&amp;quot; table field for both instructors and students. This now also includes working links through which instructors or administrators can edit or delete topics.&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/_table_line&lt;br /&gt;
| Gave edit/delete rights to Super Admin&lt;br /&gt;
| The Super-Administrator user wasn't included in the list of users with these permissions&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/edit&lt;br /&gt;
| Modified title and included @assignment_id variable to be passed as a parameter variable to the update action&lt;br /&gt;
| The view was initially trying to access the params[:assignment_id] variable which was not getting initialized&lt;br /&gt;
|-&lt;br /&gt;
| assignments/edit&lt;br /&gt;
| Changed the partial rendered to /sign_up_sheet/add_signup_topcis.html&lt;br /&gt;
| The assignments/edit/add_signup_topics partial (with duplicated code) was otherwise being rendered&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring the AssignmentsController and SignupSheetController ==&lt;br /&gt;
&lt;br /&gt;
===Removing duplicate _add_signup_topics partials===&lt;br /&gt;
The AssignmentsController displayed topics to the instructor while he was editing an assignment. It used _add_signup_topics.html.erb partial to render topics under the topics tab. The SignupSheetController displayed topics to a student who wanted to view signup topics under an assignment. It was found that it had its own copy namely _add_signup_topcis.html.erb to display topics to the student. We wanted to have these two controllers use the same views to render the same thing which was list of topics under an assignment. We made the AssignmentsController reuse the _add_signup_topcis.html.erb partial under the SignupSheetController.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;view:assignments/edit.html.erb&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This view contains all the tabs to display like general,rubrics,review_strategy, topics which are related to the selected assignment. tabs-5 is the topics tab which we are interested in.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-3&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/review_strategy' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-4&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/due_dates' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-5&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/add_signup_topics' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;pre&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-3&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/review_strategy' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-4&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/due_dates' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-5&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render '/sign_up_sheet/add_signup_topcis.html' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactoring view code into relevant views ===&lt;br /&gt;
There were no edit/delete links to edit/delete a topic in the instructor view. These had to be conditionally added based on the role of the currently logged in user. This was to prevent students from editing/deleting topics and to keep instructors from signing up for a topic. This was implemented as follows.&lt;br /&gt;
&lt;br /&gt;
===Adding Edit/Delete functionality to topics tab===&lt;br /&gt;
&lt;br /&gt;
The current expertiza project had two views to display the Actions column in the topics table. These were _reserve_topics.html.erb and _actions.html. The first one was displaying the signup button for the student and the latter was displaying the bookmarks and rendering the _reserve_topics.html.erb after the bookmarks. On top of this we had to add the edit/delete links for the instructor. A refactor was called for. We decided to create a _all_actions.html.erb partial which had the responsibility to display the relevant actions depending upon the role of the currently logged in user. This helped us remove the separate partial to render actions pertaining to a student, namely _reserve_topics.html.erb . Also the _actions.html.erb only took care of displaying the bookmark links rather than dealing with both bookmarks and actions. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;partial_view:_all_actions,html.erb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if ['Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator'].include? current_user_role?.name %&amp;gt;&lt;br /&gt;
    &amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;%= link_to image_tag('edit_icon.png', :border =&amp;gt; 0, :title =&amp;gt; 'Edit Topic', :align =&amp;gt; 'middle'), :controller=&amp;gt;'sign_up_sheet', :action=&amp;gt; 'edit', :id =&amp;gt; topic.id %&amp;gt;&lt;br /&gt;
      &amp;lt;%= link_to image_tag('delete_icon.png', :border =&amp;gt; 0, :title =&amp;gt; 'Delete Topic', :align =&amp;gt; 'middle'), sign_up_sheet_path(topic.id), method: :delete, data: {confirm: 'Are you sure?'} %&amp;gt;&lt;br /&gt;
&amp;lt;%elsif @show_actions %&amp;gt; &lt;br /&gt;
    ... &lt;br /&gt;
    #Render signup button for student here. The @show_actions will be true if this partial is navigated from the SignupSheetController which is accessible only to students.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Cleaning up unused code ==&lt;br /&gt;
The Refactors mentioned above enable us to delete unused partials namely:&lt;br /&gt;
&lt;br /&gt;
*assignments controller partials :&lt;br /&gt;
**_add_signup_topics.html.erb&lt;br /&gt;
**_reserve_topic.html.erb&lt;br /&gt;
&lt;br /&gt;
*signup_sheet_controller partials :&lt;br /&gt;
**_reserve_topic.html.erb&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://152.46.18.5:3000/ VCL link] - This might not be available after Nov. 2014&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
#[https://docs.google.com/document/d/1FZCL9KWSdVNsX9BowuZ3gxbCOJoiWX-GVLctSZei3No The OSS project requirements doc (Fall 2014 - Expertiza)]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_refactoring Code Refactoring]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_smell Code smell]&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95602</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95602"/>
		<updated>2015-03-23T05:14:56Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1501: Refactoring Assignments.rb'''&lt;br /&gt;
&lt;br /&gt;
This page provides information about a project which aims to refactor Assignment.rb file present in Expertiza OSS.&lt;br /&gt;
&lt;br /&gt;
'''Introduction to Expertiza'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews, which makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Assignment.rb is a file which contains the assignment model and the related functionality. It also contains the grading module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
&amp;lt;p&amp;gt;Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains the functions responsible for grading.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&amp;lt;p&amp;gt;The &amp;lt;b&amp;gt;Topics&amp;lt;/b&amp;gt; tab in the &amp;lt;b&amp;gt;Assignments --&amp;gt; Edit&amp;lt;/b&amp;gt; view is not usable right now by an instructor when he/she is editing an assignment.  The functionality that displays topics also needs to be usable by the student view, since students also have to view the list of topics (when they sign up for a topic).  Instructor and student functionality is a little different: instructors can add topics and change the number of slots, but they can’t sign up for topics. The Topics tab needs to be fixed, edit/delete topic functionality is to be added for instructors and common/duplicate code needs to be refactored.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The functionality to display the topics under an assignment is duplicated between the AssignmentController views and the SignupSheetController views. Both the instructor and the student can view the topics by selecting an assignment and we were required to remove this duplication in the views. Consequently, most of our work dealt with modifying the SignupSheetController and its corresponding views.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Changes Made=&lt;br /&gt;
&lt;br /&gt;
==SignupSheet Controller==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|Method Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Changes Made &lt;br /&gt;
! style=&amp;quot;width:43%;&amp;quot;|Reason For Change&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| create&lt;br /&gt;
| Fixed redirection after topic creation to Topics tab&lt;br /&gt;
| On successful creation of a topic, the action was merely redirecting to the assignments/edit view&lt;br /&gt;
|-&lt;br /&gt;
| update&lt;br /&gt;
| Fixed redirection after topic updation to Topics tab&lt;br /&gt;
| Once a topic was successfully edited, the view rendered was just a list of topics&lt;br /&gt;
|-&lt;br /&gt;
| edit&lt;br /&gt;
| Initialized @assignment_id variable&lt;br /&gt;
| The variable is used in the edit view&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; valign=&amp;quot;middle&amp;quot; |&lt;br /&gt;
destroy&lt;br /&gt;
| Renamed the 'delete' method to 'destroy'&lt;br /&gt;
| This was done for better Rails 4 routing compatibility&lt;br /&gt;
|-&lt;br /&gt;
| Initialized the assignment_id parameter&lt;br /&gt;
| This is used further on and is not passed from the link URL&lt;br /&gt;
|-&lt;br /&gt;
| Fixed redirection after topic deletion to Topics tab&lt;br /&gt;
| Once a topic was successfully deleted, the view rendered was just a list of topics&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Views==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:18%;&amp;quot;|View Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Changes Made &lt;br /&gt;
! style=&amp;quot;width:43%;&amp;quot;|Reason For Change&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| rowspan=&amp;quot;5&amp;quot; valign=&amp;quot;middle&amp;quot; |&lt;br /&gt;
sign_up_sheet/_add_signup_topcis&lt;br /&gt;
| Fixed title&lt;br /&gt;
| The page title displayed for an instructor was &amp;quot;Sign-up sheet for ... &amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Commented out View/Manage bookmark links&lt;br /&gt;
| These links were broken, and according to existing code were not meant for the instructor view.&lt;br /&gt;
|-&lt;br /&gt;
| Added variable initialization for @sign_up_topics&lt;br /&gt;
| The variable was referenced further on in the view, which was causing an 'nil value' error&lt;br /&gt;
|-&lt;br /&gt;
| Fixed flash message rendering for new topic creation&lt;br /&gt;
| The flash message was rendering incorrectly with HTML tags visible on the web page&lt;br /&gt;
|-&lt;br /&gt;
| Added full path names to partial names&lt;br /&gt;
| The shared partials were also being used by views in the Assignments controller, so full paths were needed&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/_add_topics&lt;br /&gt;
| Added separation between the Import Topics and Manage Bookmarks links&lt;br /&gt;
| The two links were clumped together and it was difficult to distinguish between them&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/_actions&lt;br /&gt;
| Replaced rendering of the reserve_topic partial with the _all_actions partial&lt;br /&gt;
| The reserve_topic partial is no longer being used and is replaced by the newly created _all_actions partial&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/_all_actions&lt;br /&gt;
| Created this new partial&lt;br /&gt;
| We created the _all_actions partial to conditionally render the &amp;quot;Actions&amp;quot; table field for both instructors and students. This now also includes working links through which instructors or administrators can edit or delete topics.&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/_table_line&lt;br /&gt;
| Gave edit/delete rights to Super Admin&lt;br /&gt;
| The Super-Administrator user wasn't included in the list of users with these permissions&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/edit&lt;br /&gt;
| Modified title and included @assignment_id variable to be passed as a parameter variable to the update action&lt;br /&gt;
| The view was initially trying to access the params[:assignment_id] variable which was not getting initialized&lt;br /&gt;
|-&lt;br /&gt;
| assignments/edit&lt;br /&gt;
| Changed the partial rendered to /sign_up_sheet/add_signup_topcis.html&lt;br /&gt;
| The assignments/edit/add_signup_topics partial (with duplicated code) was otherwise being rendered&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring the AssignmentsController and SignupSheetController ==&lt;br /&gt;
&lt;br /&gt;
===Removing duplicate _add_signup_topics partials===&lt;br /&gt;
The AssignmentsController displayed topics to the instructor while he was editing an assignment. It used _add_signup_topics.html.erb partial to render topics under the topics tab. The SignupSheetController displayed topics to a student who wanted to view signup topics under an assignment. It was found that it had its own copy namely _add_signup_topcis.html.erb to display topics to the student. We wanted to have these two controllers use the same views to render the same thing which was list of topics under an assignment. We made the AssignmentsController reuse the _add_signup_topcis.html.erb partial under the SignupSheetController.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;view:assignments/edit.html.erb&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This view contains all the tabs to display like general,rubrics,review_strategy, topics which are related to the selected assignment. tabs-5 is the topics tab which we are interested in.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-3&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/review_strategy' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-4&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/due_dates' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-5&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/add_signup_topics' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;pre&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-3&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/review_strategy' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-4&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/due_dates' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-5&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render '/sign_up_sheet/add_signup_topcis.html' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactoring view code into relevant views ===&lt;br /&gt;
There were no edit/delete links to edit/delete a topic in the instructor view. These had to be conditionally added based on the role of the currently logged in user. This was to prevent students from editing/deleting topics and to keep instructors from signing up for a topic. This was implemented as follows.&lt;br /&gt;
&lt;br /&gt;
===Adding Edit/Delete functionality to topics tab===&lt;br /&gt;
&lt;br /&gt;
The current expertiza project had two views to display the Actions column in the topics table. These were _reserve_topics.html.erb and _actions.html. The first one was displaying the signup button for the student and the latter was displaying the bookmarks and rendering the _reserve_topics.html.erb after the bookmarks. On top of this we had to add the edit/delete links for the instructor. A refactor was called for. We decided to create a _all_actions.html.erb partial which had the responsibility to display the relevant actions depending upon the role of the currently logged in user. This helped us remove the separate partial to render actions pertaining to a student, namely _reserve_topics.html.erb . Also the _actions.html.erb only took care of displaying the bookmark links rather than dealing with both bookmarks and actions. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;partial_view:_all_actions,html.erb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if ['Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator'].include? current_user_role?.name %&amp;gt;&lt;br /&gt;
    &amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;%= link_to image_tag('edit_icon.png', :border =&amp;gt; 0, :title =&amp;gt; 'Edit Topic', :align =&amp;gt; 'middle'), :controller=&amp;gt;'sign_up_sheet', :action=&amp;gt; 'edit', :id =&amp;gt; topic.id %&amp;gt;&lt;br /&gt;
      &amp;lt;%= link_to image_tag('delete_icon.png', :border =&amp;gt; 0, :title =&amp;gt; 'Delete Topic', :align =&amp;gt; 'middle'), sign_up_sheet_path(topic.id), method: :delete, data: {confirm: 'Are you sure?'} %&amp;gt;&lt;br /&gt;
&amp;lt;%elsif @show_actions %&amp;gt; &lt;br /&gt;
    ... &lt;br /&gt;
    #Render signup button for student here. The @show_actions will be true if this partial is navigated from the SignupSheetController which is accessible only to students.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Cleaning up unused code ==&lt;br /&gt;
The Refactors mentioned above enable us to delete unused partials namely:&lt;br /&gt;
&lt;br /&gt;
*assignments controller partials :&lt;br /&gt;
**_add_signup_topics.html.erb&lt;br /&gt;
**_reserve_topic.html.erb&lt;br /&gt;
&lt;br /&gt;
*signup_sheet_controller partials :&lt;br /&gt;
**_reserve_topic.html.erb&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://152.46.18.5:3000/ VCL link] - This might not be available after Nov. 2014&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
#[https://docs.google.com/document/d/1FZCL9KWSdVNsX9BowuZ3gxbCOJoiWX-GVLctSZei3No The OSS project requirements doc (Fall 2014 - Expertiza)]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_refactoring Code Refactoring]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_smell Code smell]&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95601</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95601"/>
		<updated>2015-03-23T05:14:17Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1501: Refactoring Assignments.rb'''&lt;br /&gt;
&lt;br /&gt;
This page provides information about a project which aims to refactor Assignment.rb file present in Expertiza OSS.&lt;br /&gt;
&lt;br /&gt;
'''Introduction to Expertiza'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews, which makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Assignment.rb is a file which contains the assignment model and the related functionality. It also contains the grading module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
&lt;br /&gt;
'''What they do'''&lt;br /&gt;
Assignment.rb along with the controller file is responsible for creating and editing the assignments. The file also contains the functions responsible for grading.&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
The &amp;lt;b&amp;gt;Topics&amp;lt;/b&amp;gt; tab in the &amp;lt;b&amp;gt;Assignments --&amp;gt; Edit&amp;lt;/b&amp;gt; view is not usable right now by an instructor when he/she is editing an assignment.  The functionality that displays topics also needs to be usable by the student view, since students also have to view the list of topics (when they sign up for a topic).  Instructor and student functionality is a little different: instructors can add topics and change the number of slots, but they can’t sign up for topics. The Topics tab needs to be fixed, edit/delete topic functionality is to be added for instructors and common/duplicate code needs to be refactored.&lt;br /&gt;
&lt;br /&gt;
The functionality to display the topics under an assignment is duplicated between the AssignmentController views and the SignupSheetController views. Both the instructor and the student can view the topics by selecting an assignment and we were required to remove this duplication in the views. Consequently, most of our work dealt with modifying the SignupSheetController and its corresponding views.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Changes Made=&lt;br /&gt;
&lt;br /&gt;
==SignupSheet Controller==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|Method Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Changes Made &lt;br /&gt;
! style=&amp;quot;width:43%;&amp;quot;|Reason For Change&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| create&lt;br /&gt;
| Fixed redirection after topic creation to Topics tab&lt;br /&gt;
| On successful creation of a topic, the action was merely redirecting to the assignments/edit view&lt;br /&gt;
|-&lt;br /&gt;
| update&lt;br /&gt;
| Fixed redirection after topic updation to Topics tab&lt;br /&gt;
| Once a topic was successfully edited, the view rendered was just a list of topics&lt;br /&gt;
|-&lt;br /&gt;
| edit&lt;br /&gt;
| Initialized @assignment_id variable&lt;br /&gt;
| The variable is used in the edit view&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; valign=&amp;quot;middle&amp;quot; |&lt;br /&gt;
destroy&lt;br /&gt;
| Renamed the 'delete' method to 'destroy'&lt;br /&gt;
| This was done for better Rails 4 routing compatibility&lt;br /&gt;
|-&lt;br /&gt;
| Initialized the assignment_id parameter&lt;br /&gt;
| This is used further on and is not passed from the link URL&lt;br /&gt;
|-&lt;br /&gt;
| Fixed redirection after topic deletion to Topics tab&lt;br /&gt;
| Once a topic was successfully deleted, the view rendered was just a list of topics&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Views==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:18%;&amp;quot;|View Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Changes Made &lt;br /&gt;
! style=&amp;quot;width:43%;&amp;quot;|Reason For Change&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| rowspan=&amp;quot;5&amp;quot; valign=&amp;quot;middle&amp;quot; |&lt;br /&gt;
sign_up_sheet/_add_signup_topcis&lt;br /&gt;
| Fixed title&lt;br /&gt;
| The page title displayed for an instructor was &amp;quot;Sign-up sheet for ... &amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Commented out View/Manage bookmark links&lt;br /&gt;
| These links were broken, and according to existing code were not meant for the instructor view.&lt;br /&gt;
|-&lt;br /&gt;
| Added variable initialization for @sign_up_topics&lt;br /&gt;
| The variable was referenced further on in the view, which was causing an 'nil value' error&lt;br /&gt;
|-&lt;br /&gt;
| Fixed flash message rendering for new topic creation&lt;br /&gt;
| The flash message was rendering incorrectly with HTML tags visible on the web page&lt;br /&gt;
|-&lt;br /&gt;
| Added full path names to partial names&lt;br /&gt;
| The shared partials were also being used by views in the Assignments controller, so full paths were needed&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/_add_topics&lt;br /&gt;
| Added separation between the Import Topics and Manage Bookmarks links&lt;br /&gt;
| The two links were clumped together and it was difficult to distinguish between them&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/_actions&lt;br /&gt;
| Replaced rendering of the reserve_topic partial with the _all_actions partial&lt;br /&gt;
| The reserve_topic partial is no longer being used and is replaced by the newly created _all_actions partial&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/_all_actions&lt;br /&gt;
| Created this new partial&lt;br /&gt;
| We created the _all_actions partial to conditionally render the &amp;quot;Actions&amp;quot; table field for both instructors and students. This now also includes working links through which instructors or administrators can edit or delete topics.&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/_table_line&lt;br /&gt;
| Gave edit/delete rights to Super Admin&lt;br /&gt;
| The Super-Administrator user wasn't included in the list of users with these permissions&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/edit&lt;br /&gt;
| Modified title and included @assignment_id variable to be passed as a parameter variable to the update action&lt;br /&gt;
| The view was initially trying to access the params[:assignment_id] variable which was not getting initialized&lt;br /&gt;
|-&lt;br /&gt;
| assignments/edit&lt;br /&gt;
| Changed the partial rendered to /sign_up_sheet/add_signup_topcis.html&lt;br /&gt;
| The assignments/edit/add_signup_topics partial (with duplicated code) was otherwise being rendered&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring the AssignmentsController and SignupSheetController ==&lt;br /&gt;
&lt;br /&gt;
===Removing duplicate _add_signup_topics partials===&lt;br /&gt;
The AssignmentsController displayed topics to the instructor while he was editing an assignment. It used _add_signup_topics.html.erb partial to render topics under the topics tab. The SignupSheetController displayed topics to a student who wanted to view signup topics under an assignment. It was found that it had its own copy namely _add_signup_topcis.html.erb to display topics to the student. We wanted to have these two controllers use the same views to render the same thing which was list of topics under an assignment. We made the AssignmentsController reuse the _add_signup_topcis.html.erb partial under the SignupSheetController.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;view:assignments/edit.html.erb&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This view contains all the tabs to display like general,rubrics,review_strategy, topics which are related to the selected assignment. tabs-5 is the topics tab which we are interested in.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-3&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/review_strategy' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-4&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/due_dates' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-5&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/add_signup_topics' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;pre&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-3&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/review_strategy' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-4&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/due_dates' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-5&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render '/sign_up_sheet/add_signup_topcis.html' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactoring view code into relevant views ===&lt;br /&gt;
There were no edit/delete links to edit/delete a topic in the instructor view. These had to be conditionally added based on the role of the currently logged in user. This was to prevent students from editing/deleting topics and to keep instructors from signing up for a topic. This was implemented as follows.&lt;br /&gt;
&lt;br /&gt;
===Adding Edit/Delete functionality to topics tab===&lt;br /&gt;
&lt;br /&gt;
The current expertiza project had two views to display the Actions column in the topics table. These were _reserve_topics.html.erb and _actions.html. The first one was displaying the signup button for the student and the latter was displaying the bookmarks and rendering the _reserve_topics.html.erb after the bookmarks. On top of this we had to add the edit/delete links for the instructor. A refactor was called for. We decided to create a _all_actions.html.erb partial which had the responsibility to display the relevant actions depending upon the role of the currently logged in user. This helped us remove the separate partial to render actions pertaining to a student, namely _reserve_topics.html.erb . Also the _actions.html.erb only took care of displaying the bookmark links rather than dealing with both bookmarks and actions. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;partial_view:_all_actions,html.erb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if ['Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator'].include? current_user_role?.name %&amp;gt;&lt;br /&gt;
    &amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;%= link_to image_tag('edit_icon.png', :border =&amp;gt; 0, :title =&amp;gt; 'Edit Topic', :align =&amp;gt; 'middle'), :controller=&amp;gt;'sign_up_sheet', :action=&amp;gt; 'edit', :id =&amp;gt; topic.id %&amp;gt;&lt;br /&gt;
      &amp;lt;%= link_to image_tag('delete_icon.png', :border =&amp;gt; 0, :title =&amp;gt; 'Delete Topic', :align =&amp;gt; 'middle'), sign_up_sheet_path(topic.id), method: :delete, data: {confirm: 'Are you sure?'} %&amp;gt;&lt;br /&gt;
&amp;lt;%elsif @show_actions %&amp;gt; &lt;br /&gt;
    ... &lt;br /&gt;
    #Render signup button for student here. The @show_actions will be true if this partial is navigated from the SignupSheetController which is accessible only to students.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Cleaning up unused code ==&lt;br /&gt;
The Refactors mentioned above enable us to delete unused partials namely:&lt;br /&gt;
&lt;br /&gt;
*assignments controller partials :&lt;br /&gt;
**_add_signup_topics.html.erb&lt;br /&gt;
**_reserve_topic.html.erb&lt;br /&gt;
&lt;br /&gt;
*signup_sheet_controller partials :&lt;br /&gt;
**_reserve_topic.html.erb&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://152.46.18.5:3000/ VCL link] - This might not be available after Nov. 2014&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
#[https://docs.google.com/document/d/1FZCL9KWSdVNsX9BowuZ3gxbCOJoiWX-GVLctSZei3No The OSS project requirements doc (Fall 2014 - Expertiza)]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_refactoring Code Refactoring]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_smell Code smell]&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95600</id>
		<title>CSC/ECE 517 Spring 2015/oss E1501 YWS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2015/oss_E1501_YWS&amp;diff=95600"/>
		<updated>2015-03-23T05:11:33Z</updated>

		<summary type="html">&lt;p&gt;Sbhawsi: Created page with &amp;quot;'''E1501: Refactoring Assignments.rb'''  This page provides information about a project which aims to refactor Assignment.rb file present in Expertiza OSS.  '''Introduction to Ex...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1501: Refactoring Assignments.rb'''&lt;br /&gt;
&lt;br /&gt;
This page provides information about a project which aims to refactor Assignment.rb file present in Expertiza OSS.&lt;br /&gt;
&lt;br /&gt;
'''Introduction to Expertiza'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project developed using the [http://rubyonrails.org/ Ruby on Rails] platform. It provides features like team assignments, peer review, submission of projects, grading etc. The code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews, which makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Assignment.rb is a file which contains the assignment model which is used to create and edit assignments and the related functionality. It also contains the grading module which is refactored to make the file more clean and easy to read.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
'''Classes involved:'''&lt;br /&gt;
 assignment.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
The &amp;lt;b&amp;gt;Topics&amp;lt;/b&amp;gt; tab in the &amp;lt;b&amp;gt;Assignments --&amp;gt; Edit&amp;lt;/b&amp;gt; view is not usable right now by an instructor when he/she is editing an assignment.  The functionality that displays topics also needs to be usable by the student view, since students also have to view the list of topics (when they sign up for a topic).  Instructor and student functionality is a little different: instructors can add topics and change the number of slots, but they can’t sign up for topics. The Topics tab needs to be fixed, edit/delete topic functionality is to be added for instructors and common/duplicate code needs to be refactored.&lt;br /&gt;
&lt;br /&gt;
The functionality to display the topics under an assignment is duplicated between the AssignmentController views and the SignupSheetController views. Both the instructor and the student can view the topics by selecting an assignment and we were required to remove this duplication in the views. Consequently, most of our work dealt with modifying the SignupSheetController and its corresponding views.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Changes Made=&lt;br /&gt;
&lt;br /&gt;
==SignupSheet Controller==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|Method Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Changes Made &lt;br /&gt;
! style=&amp;quot;width:43%;&amp;quot;|Reason For Change&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| create&lt;br /&gt;
| Fixed redirection after topic creation to Topics tab&lt;br /&gt;
| On successful creation of a topic, the action was merely redirecting to the assignments/edit view&lt;br /&gt;
|-&lt;br /&gt;
| update&lt;br /&gt;
| Fixed redirection after topic updation to Topics tab&lt;br /&gt;
| Once a topic was successfully edited, the view rendered was just a list of topics&lt;br /&gt;
|-&lt;br /&gt;
| edit&lt;br /&gt;
| Initialized @assignment_id variable&lt;br /&gt;
| The variable is used in the edit view&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;3&amp;quot; valign=&amp;quot;middle&amp;quot; |&lt;br /&gt;
destroy&lt;br /&gt;
| Renamed the 'delete' method to 'destroy'&lt;br /&gt;
| This was done for better Rails 4 routing compatibility&lt;br /&gt;
|-&lt;br /&gt;
| Initialized the assignment_id parameter&lt;br /&gt;
| This is used further on and is not passed from the link URL&lt;br /&gt;
|-&lt;br /&gt;
| Fixed redirection after topic deletion to Topics tab&lt;br /&gt;
| Once a topic was successfully deleted, the view rendered was just a list of topics&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Views==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:18%;&amp;quot;|View Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Changes Made &lt;br /&gt;
! style=&amp;quot;width:43%;&amp;quot;|Reason For Change&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| rowspan=&amp;quot;5&amp;quot; valign=&amp;quot;middle&amp;quot; |&lt;br /&gt;
sign_up_sheet/_add_signup_topcis&lt;br /&gt;
| Fixed title&lt;br /&gt;
| The page title displayed for an instructor was &amp;quot;Sign-up sheet for ... &amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Commented out View/Manage bookmark links&lt;br /&gt;
| These links were broken, and according to existing code were not meant for the instructor view.&lt;br /&gt;
|-&lt;br /&gt;
| Added variable initialization for @sign_up_topics&lt;br /&gt;
| The variable was referenced further on in the view, which was causing an 'nil value' error&lt;br /&gt;
|-&lt;br /&gt;
| Fixed flash message rendering for new topic creation&lt;br /&gt;
| The flash message was rendering incorrectly with HTML tags visible on the web page&lt;br /&gt;
|-&lt;br /&gt;
| Added full path names to partial names&lt;br /&gt;
| The shared partials were also being used by views in the Assignments controller, so full paths were needed&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/_add_topics&lt;br /&gt;
| Added separation between the Import Topics and Manage Bookmarks links&lt;br /&gt;
| The two links were clumped together and it was difficult to distinguish between them&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/_actions&lt;br /&gt;
| Replaced rendering of the reserve_topic partial with the _all_actions partial&lt;br /&gt;
| The reserve_topic partial is no longer being used and is replaced by the newly created _all_actions partial&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/_all_actions&lt;br /&gt;
| Created this new partial&lt;br /&gt;
| We created the _all_actions partial to conditionally render the &amp;quot;Actions&amp;quot; table field for both instructors and students. This now also includes working links through which instructors or administrators can edit or delete topics.&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/_table_line&lt;br /&gt;
| Gave edit/delete rights to Super Admin&lt;br /&gt;
| The Super-Administrator user wasn't included in the list of users with these permissions&lt;br /&gt;
|-&lt;br /&gt;
| sign_up_sheet/edit&lt;br /&gt;
| Modified title and included @assignment_id variable to be passed as a parameter variable to the update action&lt;br /&gt;
| The view was initially trying to access the params[:assignment_id] variable which was not getting initialized&lt;br /&gt;
|-&lt;br /&gt;
| assignments/edit&lt;br /&gt;
| Changed the partial rendered to /sign_up_sheet/add_signup_topcis.html&lt;br /&gt;
| The assignments/edit/add_signup_topics partial (with duplicated code) was otherwise being rendered&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring the AssignmentsController and SignupSheetController ==&lt;br /&gt;
&lt;br /&gt;
===Removing duplicate _add_signup_topics partials===&lt;br /&gt;
The AssignmentsController displayed topics to the instructor while he was editing an assignment. It used _add_signup_topics.html.erb partial to render topics under the topics tab. The SignupSheetController displayed topics to a student who wanted to view signup topics under an assignment. It was found that it had its own copy namely _add_signup_topcis.html.erb to display topics to the student. We wanted to have these two controllers use the same views to render the same thing which was list of topics under an assignment. We made the AssignmentsController reuse the _add_signup_topcis.html.erb partial under the SignupSheetController.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;view:assignments/edit.html.erb&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This view contains all the tabs to display like general,rubrics,review_strategy, topics which are related to the selected assignment. tabs-5 is the topics tab which we are interested in.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-3&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/review_strategy' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-4&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/due_dates' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-5&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/add_signup_topics' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;pre&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-3&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/review_strategy' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-4&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render 'assignments/edit/due_dates' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;tabs-5&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;%= render '/sign_up_sheet/add_signup_topcis.html' %&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactoring view code into relevant views ===&lt;br /&gt;
There were no edit/delete links to edit/delete a topic in the instructor view. These had to be conditionally added based on the role of the currently logged in user. This was to prevent students from editing/deleting topics and to keep instructors from signing up for a topic. This was implemented as follows.&lt;br /&gt;
&lt;br /&gt;
===Adding Edit/Delete functionality to topics tab===&lt;br /&gt;
&lt;br /&gt;
The current expertiza project had two views to display the Actions column in the topics table. These were _reserve_topics.html.erb and _actions.html. The first one was displaying the signup button for the student and the latter was displaying the bookmarks and rendering the _reserve_topics.html.erb after the bookmarks. On top of this we had to add the edit/delete links for the instructor. A refactor was called for. We decided to create a _all_actions.html.erb partial which had the responsibility to display the relevant actions depending upon the role of the currently logged in user. This helped us remove the separate partial to render actions pertaining to a student, namely _reserve_topics.html.erb . Also the _actions.html.erb only took care of displaying the bookmark links rather than dealing with both bookmarks and actions. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;partial_view:_all_actions,html.erb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if ['Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator'].include? current_user_role?.name %&amp;gt;&lt;br /&gt;
    &amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;%= link_to image_tag('edit_icon.png', :border =&amp;gt; 0, :title =&amp;gt; 'Edit Topic', :align =&amp;gt; 'middle'), :controller=&amp;gt;'sign_up_sheet', :action=&amp;gt; 'edit', :id =&amp;gt; topic.id %&amp;gt;&lt;br /&gt;
      &amp;lt;%= link_to image_tag('delete_icon.png', :border =&amp;gt; 0, :title =&amp;gt; 'Delete Topic', :align =&amp;gt; 'middle'), sign_up_sheet_path(topic.id), method: :delete, data: {confirm: 'Are you sure?'} %&amp;gt;&lt;br /&gt;
&amp;lt;%elsif @show_actions %&amp;gt; &lt;br /&gt;
    ... &lt;br /&gt;
    #Render signup button for student here. The @show_actions will be true if this partial is navigated from the SignupSheetController which is accessible only to students.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Cleaning up unused code ==&lt;br /&gt;
The Refactors mentioned above enable us to delete unused partials namely:&lt;br /&gt;
&lt;br /&gt;
*assignments controller partials :&lt;br /&gt;
**_add_signup_topics.html.erb&lt;br /&gt;
**_reserve_topic.html.erb&lt;br /&gt;
&lt;br /&gt;
*signup_sheet_controller partials :&lt;br /&gt;
**_reserve_topic.html.erb&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/itsmylifesoham/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://152.46.18.5:3000/ VCL link] - This might not be available after Nov. 2014&lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
#[https://docs.google.com/document/d/1FZCL9KWSdVNsX9BowuZ3gxbCOJoiWX-GVLctSZei3No The OSS project requirements doc (Fall 2014 - Expertiza)]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_refactoring Code Refactoring]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://en.wikipedia.org/wiki/Code_smell Code smell]&lt;/div&gt;</summary>
		<author><name>Sbhawsi</name></author>
	</entry>
</feed>