<?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=Vravi2</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=Vravi2"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Vravi2"/>
	<updated>2026-05-22T18:51:35Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=98706</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=98706"/>
		<updated>2015-11-07T03:29:47Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* Tests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
'''About Expertiza'''&lt;br /&gt;
Expertiza is an open source project accomplished by NCState students. It was developed in Ruby on Rails. It has general features like forming teams, registering for topics in a project, uploading the final deliveries. After completing the project there is an option for submitting reviews as well and updating the reviews. There is an option for submitting new quizzes as well.&lt;br /&gt;
&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
'''What it does''':  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
&lt;br /&gt;
*To test the responsecontroller login as user:instructor6 with password:password&lt;br /&gt;
*Go to assignments tab and choose any assignment from the assignments listed.&lt;br /&gt;
*From there click on others work and choose any review among the reviews listed &lt;br /&gt;
*Click on view or begin to start reviewing.&lt;br /&gt;
*You can also test response controller in similar way by logging as student student2064 and password:password.&lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:Renamed &amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;set_all_responses&amp;lt;/code&amp;gt;.&lt;br /&gt;
==== Solution ====&lt;br /&gt;
Examining &amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; we were able to determine that it did the following two things:&lt;br /&gt;
# Set the &amp;lt;code&amp;gt;@prev&amp;lt;/code&amp;gt; variable to a relation of responses that correspond to the map id of the current response being created or edited.&lt;br /&gt;
# Set the &amp;lt;code&amp;gt;@review_scores&amp;lt;/code&amp;gt; variable to an Array version if the contents of &amp;lt;code&amp;gt;@prev&amp;lt;/code&amp;gt;.&lt;br /&gt;
Since the purpose of the code seemed to be to set variables, we renamed it to &amp;lt;code&amp;gt;set_all_responses&amp;lt;/code&amp;gt;.&lt;br /&gt;
We also simplified the method by using ActiveRecord::Relation's &amp;lt;code&amp;gt;to_a&amp;lt;/code&amp;gt; to convert the relation to an array.&lt;br /&gt;
There was some duplicate code in the &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt; function which we replaced with a call the &amp;lt;code&amp;gt;set_all_responses&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
'''Solution summary'''&lt;br /&gt;
: The method &amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; was renamed to &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
The ResponseController controller has an overall problem in that it knows too much about the subclasses of &amp;lt;code&amp;gt;ResponseMap&amp;lt;/code&amp;gt;. There is some major refactoring that needs to occur to clean up this controller's coupling with &amp;lt;code&amp;gt;ResponseMap&amp;lt;/code&amp;gt;'s subclasses. We made an attempt to do this, but it was just to large a change to accomplish in the time allotted.&lt;br /&gt;
&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
A review of the &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method showed that it's purpose was to '''set''' various variables for use by the response views. As such, we renamed this method &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt; to help clarify it's intent.&lt;br /&gt;
We also extracted methods for the more complicated variables into their own methods, making the &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt; method easy to understand at a glance.&lt;br /&gt;
&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 172&lt;br /&gt;
::Post Refactoring : 21&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
'''Original ResponseController'''&amp;lt;ref name=&amp;quot;originalresponsecontroller&amp;gt;''Original responseController'' https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
&lt;br /&gt;
'''Refactored Responsecontroller''' &amp;lt;ref name=&amp;quot;Refactoredresponsecontroller&amp;gt;''Refactored responseController'' https://github.com/viswaraavi/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Some functional tests are written for this class using Rspec. The test coverage has increased from 19% to 24.1% &lt;br /&gt;
;To check these tests.&lt;br /&gt;
*clone the github repository link provided above &lt;br /&gt;
*run the command rspec spec/controllers/response_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=98105</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=98105"/>
		<updated>2015-11-02T19:08:21Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* Tests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
'''About Expertiza'''&lt;br /&gt;
Expertiza is an open source project accomplished by NCState students. It was developed in Ruby on Rails. It has general features like forming teams, registering for topics in a project, uploading the final deliveries. After completing the project there is an option for submitting reviews as well and updating the reviews. There is an option for submitting new quizzes as well.&lt;br /&gt;
&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
'''What it does''':  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
&lt;br /&gt;
*To test the responsecontroller login as user:instructor6 with password:password&lt;br /&gt;
*Go to assignments tab and choose any assignment from the assignments listed.&lt;br /&gt;
*From there click on others work and choose any review among the reviews listed &lt;br /&gt;
*Click on view or begin to start reviewing.&lt;br /&gt;
*You can also test response controller in similar way by logging as student student2064 and password:password.&lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:Renamed &amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;set_all_responses&amp;lt;/code&amp;gt;.&lt;br /&gt;
==== Solution ====&lt;br /&gt;
Examining &amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; we were able to determine that it did the following two things:&lt;br /&gt;
# Set the &amp;lt;code&amp;gt;@prev&amp;lt;/code&amp;gt; variable to a relation of responses that correspond to the map id of the current response being created or edited.&lt;br /&gt;
# Set the &amp;lt;code&amp;gt;@review_scores&amp;lt;/code&amp;gt; variable to an Array version if the contents of &amp;lt;code&amp;gt;@prev&amp;lt;/code&amp;gt;.&lt;br /&gt;
Since the purpose of the code seemed to be to set variables, we renamed it to &amp;lt;code&amp;gt;set_all_responses&amp;lt;/code&amp;gt;.&lt;br /&gt;
We also simplified the method by using ActiveRecord::Relation's &amp;lt;code&amp;gt;to_a&amp;lt;/code&amp;gt; to convert the relation to an array.&lt;br /&gt;
There was some duplicate code in the &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt; function which we replaced with a call the &amp;lt;code&amp;gt;set_all_responses&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
'''Solution summary'''&lt;br /&gt;
: The method &amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; was renamed to &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
The ResponseController controller has an overall problem in that it knows too much about the subclasses of &amp;lt;code&amp;gt;ResponseMap&amp;lt;/code&amp;gt;. There is some major refactoring that needs to occur to clean up this controller's coupling with &amp;lt;code&amp;gt;ResponseMap&amp;lt;/code&amp;gt;'s subclasses. We made an attempt to do this, but it was just to large a change to accomplish in the time allotted.&lt;br /&gt;
&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
A review of the &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method showed that it's purpose was to '''set''' various variables for use by the response views. As such, we renamed this method &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt; to help clarify it's intent.&lt;br /&gt;
We also extracted methods for the more complicated variables into their own methods, making the &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt; method easy to understand at a glance.&lt;br /&gt;
&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 172&lt;br /&gt;
::Post Refactoring : 21&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
'''Original ResponseController'''&amp;lt;ref name=&amp;quot;originalresponsecontroller&amp;gt;''Original responseController'' https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
&lt;br /&gt;
'''Refactored Responsecontroller''' &amp;lt;ref name=&amp;quot;Refactoredresponsecontroller&amp;gt;''Refactored responseController'' https://github.com/viswaraavi/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Some functional tests are written for this class using Rspec &lt;br /&gt;
;To check these tests.&lt;br /&gt;
*clone the github repository link provided above &lt;br /&gt;
*run the command rspec spec/controllers/response_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=98104</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=98104"/>
		<updated>2015-11-02T19:07:57Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* ResponseController */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
'''About Expertiza'''&lt;br /&gt;
Expertiza is an open source project accomplished by NCState students. It was developed in Ruby on Rails. It has general features like forming teams, registering for topics in a project, uploading the final deliveries. After completing the project there is an option for submitting reviews as well and updating the reviews. There is an option for submitting new quizzes as well.&lt;br /&gt;
&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
'''What it does''':  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
&lt;br /&gt;
*To test the responsecontroller login as user:instructor6 with password:password&lt;br /&gt;
*Go to assignments tab and choose any assignment from the assignments listed.&lt;br /&gt;
*From there click on others work and choose any review among the reviews listed &lt;br /&gt;
*Click on view or begin to start reviewing.&lt;br /&gt;
*You can also test response controller in similar way by logging as student student2064 and password:password.&lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:Renamed &amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;set_all_responses&amp;lt;/code&amp;gt;.&lt;br /&gt;
==== Solution ====&lt;br /&gt;
Examining &amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; we were able to determine that it did the following two things:&lt;br /&gt;
# Set the &amp;lt;code&amp;gt;@prev&amp;lt;/code&amp;gt; variable to a relation of responses that correspond to the map id of the current response being created or edited.&lt;br /&gt;
# Set the &amp;lt;code&amp;gt;@review_scores&amp;lt;/code&amp;gt; variable to an Array version if the contents of &amp;lt;code&amp;gt;@prev&amp;lt;/code&amp;gt;.&lt;br /&gt;
Since the purpose of the code seemed to be to set variables, we renamed it to &amp;lt;code&amp;gt;set_all_responses&amp;lt;/code&amp;gt;.&lt;br /&gt;
We also simplified the method by using ActiveRecord::Relation's &amp;lt;code&amp;gt;to_a&amp;lt;/code&amp;gt; to convert the relation to an array.&lt;br /&gt;
There was some duplicate code in the &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt; function which we replaced with a call the &amp;lt;code&amp;gt;set_all_responses&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
'''Solution summary'''&lt;br /&gt;
: The method &amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; was renamed to &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
The ResponseController controller has an overall problem in that it knows too much about the subclasses of &amp;lt;code&amp;gt;ResponseMap&amp;lt;/code&amp;gt;. There is some major refactoring that needs to occur to clean up this controller's coupling with &amp;lt;code&amp;gt;ResponseMap&amp;lt;/code&amp;gt;'s subclasses. We made an attempt to do this, but it was just to large a change to accomplish in the time allotted.&lt;br /&gt;
&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
A review of the &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method showed that it's purpose was to '''set''' various variables for use by the response views. As such, we renamed this method &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt; to help clarify it's intent.&lt;br /&gt;
We also extracted methods for the more complicated variables into their own methods, making the &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt; method easy to understand at a glance.&lt;br /&gt;
&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 172&lt;br /&gt;
::Post Refactoring : 21&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
'''Original ResponseController'''&amp;lt;ref name=&amp;quot;originalresponsecontroller&amp;gt;''Original responseController'' https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
&lt;br /&gt;
'''Refactored Responsecontroller''' &amp;lt;ref name=&amp;quot;Refactoredresponsecontroller&amp;gt;''Refactored responseController'' https://github.com/viswaraavi/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Some functional tests are written for this class using Rspec and Factorygirls.&lt;br /&gt;
;To check these tests.&lt;br /&gt;
*clone the github repository link provided above &lt;br /&gt;
*run the command rspec spec/controllers/response_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=98103</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=98103"/>
		<updated>2015-11-02T19:05:47Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* ResponseController */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
'''About Expertiza'''&lt;br /&gt;
Expertiza is an open source project accomplished by NCState students. It was developed in Ruby on Rails. It has general features like forming teams, registering for topics in a project, uploading the final deliveries. After completing the project there is an option for submitting reviews as well and updating the reviews. There is an option for submitting new quizzes as well.&lt;br /&gt;
&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
'''What it does''':  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
&lt;br /&gt;
*To test the responsecontroller login as user:instructor6 with password:password&lt;br /&gt;
*Go to assignments tab and choose any assignment from the assignments listed.&lt;br /&gt;
*From there click on others work and choose any review among the reviews listed &lt;br /&gt;
*Click on view or begin to start reviewing.&lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:Renamed &amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;set_all_responses&amp;lt;/code&amp;gt;.&lt;br /&gt;
==== Solution ====&lt;br /&gt;
Examining &amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; we were able to determine that it did the following two things:&lt;br /&gt;
# Set the &amp;lt;code&amp;gt;@prev&amp;lt;/code&amp;gt; variable to a relation of responses that correspond to the map id of the current response being created or edited.&lt;br /&gt;
# Set the &amp;lt;code&amp;gt;@review_scores&amp;lt;/code&amp;gt; variable to an Array version if the contents of &amp;lt;code&amp;gt;@prev&amp;lt;/code&amp;gt;.&lt;br /&gt;
Since the purpose of the code seemed to be to set variables, we renamed it to &amp;lt;code&amp;gt;set_all_responses&amp;lt;/code&amp;gt;.&lt;br /&gt;
We also simplified the method by using ActiveRecord::Relation's &amp;lt;code&amp;gt;to_a&amp;lt;/code&amp;gt; to convert the relation to an array.&lt;br /&gt;
There was some duplicate code in the &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt; function which we replaced with a call the &amp;lt;code&amp;gt;set_all_responses&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
'''Solution summary'''&lt;br /&gt;
: The method &amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; was renamed to &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
The ResponseController controller has an overall problem in that it knows too much about the subclasses of &amp;lt;code&amp;gt;ResponseMap&amp;lt;/code&amp;gt;. There is some major refactoring that needs to occur to clean up this controller's coupling with &amp;lt;code&amp;gt;ResponseMap&amp;lt;/code&amp;gt;'s subclasses. We made an attempt to do this, but it was just to large a change to accomplish in the time allotted.&lt;br /&gt;
&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
A review of the &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method showed that it's purpose was to '''set''' various variables for use by the response views. As such, we renamed this method &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt; to help clarify it's intent.&lt;br /&gt;
We also extracted methods for the more complicated variables into their own methods, making the &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt; method easy to understand at a glance.&lt;br /&gt;
&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 172&lt;br /&gt;
::Post Refactoring : 21&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
'''Original ResponseController'''&amp;lt;ref name=&amp;quot;originalresponsecontroller&amp;gt;''Original responseController'' https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
&lt;br /&gt;
'''Refactored Responsecontroller''' &amp;lt;ref name=&amp;quot;Refactoredresponsecontroller&amp;gt;''Refactored responseController'' https://github.com/viswaraavi/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Some functional tests are written for this class using Rspec and Factorygirls.&lt;br /&gt;
;To check these tests.&lt;br /&gt;
*clone the github repository link provided above &lt;br /&gt;
*run the command rspec spec/controllers/response_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=98081</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=98081"/>
		<updated>2015-11-01T04:12:15Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* ResponseController */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
'''About Expertiza'''&lt;br /&gt;
Expertiza is an open source project accomplished by NCState students. It was developed in Ruby on Rails. It has general features like forming teams, registering for topics in a project, uploading the final deliveries. After completing the project there is an option for submitting reviews as well and updating the reviews. There is an option for submitting new quizzes as well.&lt;br /&gt;
&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
'''What it does''':  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
&lt;br /&gt;
To test the responsecontroller login as user:instructor6 with password:password&lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:Renamed &amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;set_all_responses&amp;lt;/code&amp;gt;.&lt;br /&gt;
==== Solution ====&lt;br /&gt;
Examining &amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; we were able to determine that it did the following two things:&lt;br /&gt;
# Set the &amp;lt;code&amp;gt;@prev&amp;lt;/code&amp;gt; variable to a relation of responses that correspond to the map id of the current response being created or edited.&lt;br /&gt;
# Set the &amp;lt;code&amp;gt;@review_scores&amp;lt;/code&amp;gt; variable to an Array version if the contents of &amp;lt;code&amp;gt;@prev&amp;lt;/code&amp;gt;.&lt;br /&gt;
Since the purpose of the code seemed to be to set variables, we renamed it to &amp;lt;code&amp;gt;set_all_responses&amp;lt;/code&amp;gt;.&lt;br /&gt;
We also simplified the method by using ActiveRecord::Relation's &amp;lt;code&amp;gt;to_a&amp;lt;/code&amp;gt; to convert the relation to an array.&lt;br /&gt;
There was some duplicate code in the &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt; function which we replaced with a call the &amp;lt;code&amp;gt;set_all_responses&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
'''Solution summary'''&lt;br /&gt;
: The method &amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; was renamed to &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
The ResponseController controller has an overall problem in that it knows too much about the subclasses of &amp;lt;code&amp;gt;ResponseMap&amp;lt;/code&amp;gt;. There is some major refactoring that needs to occur to clean up this controller's coupling with &amp;lt;code&amp;gt;ResponseMap&amp;lt;/code&amp;gt;'s subclasses. We made an attempt to do this, but it was just to large a change to accomplish in the time allotted.&lt;br /&gt;
&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
A review of the &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method showed that it's purpose was to '''set''' various variables for use by the response views. As such, we renamed this method &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt; to help clarify it's intent.&lt;br /&gt;
We also extracted methods for the more complicated variables into their own methods, making the &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt; method easy to understand at a glance.&lt;br /&gt;
&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 172&lt;br /&gt;
::Post Refactoring : 21&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
'''Original ResponseController'''&amp;lt;ref name=&amp;quot;originalresponsecontroller&amp;gt;''Original responseController'' https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
&lt;br /&gt;
'''Refactored Responsecontroller''' &amp;lt;ref name=&amp;quot;Refactoredresponsecontroller&amp;gt;''Refactored responseController'' https://github.com/viswaraavi/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Some functional tests are written for this class using Rspec and Factorygirls.&lt;br /&gt;
;To check these tests.&lt;br /&gt;
*clone the github repository link provided above &lt;br /&gt;
*run the command rspec spec/controllers/response_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=98068</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=98068"/>
		<updated>2015-11-01T03:59:50Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
'''About Expertiza'''&lt;br /&gt;
Expertiza is an open source project accomplished by NCState students. It was developed in Ruby on Rails. It has general features like forming teams, registering for topics in a project, uploading the final deliveries. After completing the project there is an option for submitting reviews as well and updating the reviews. There is an option for submitting new quizzes as well.&lt;br /&gt;
&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
'''What it does''':  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:Renamed &amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;set_all_responses&amp;lt;/code&amp;gt;.&lt;br /&gt;
==== Solution ====&lt;br /&gt;
Examining &amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; we were able to determine that it did the following two things:&lt;br /&gt;
# Set the &amp;lt;code&amp;gt;@prev&amp;lt;/code&amp;gt; variable to a relation of responses that correspond to the map id of the current response being created or edited.&lt;br /&gt;
# Set the &amp;lt;code&amp;gt;@review_scores&amp;lt;/code&amp;gt; variable to an Array version if the contents of &amp;lt;code&amp;gt;@prev&amp;lt;/code&amp;gt;.&lt;br /&gt;
Since the purpose of the code seemed to be to set variables, we renamed it to &amp;lt;code&amp;gt;set_all_responses&amp;lt;/code&amp;gt;.&lt;br /&gt;
We also simplified the method by using ActiveRecord::Relation's &amp;lt;code&amp;gt;to_a&amp;lt;/code&amp;gt; to convert the relation to an array.&lt;br /&gt;
There was some duplicate code in the &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt; function which we replaced with a call the &amp;lt;code&amp;gt;set_all_responses&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
'''Solution summary'''&lt;br /&gt;
: The method &amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; was renamed to &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 172&lt;br /&gt;
::Post Refactoring : 21&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
'''Original ResponseController'''&amp;lt;ref name=&amp;quot;originalresponsecontroller&amp;gt;''Original responseController'' https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
&lt;br /&gt;
'''Refactored Responsecontroller''' &amp;lt;ref name=&amp;quot;Refactoredresponsecontroller&amp;gt;''Refactored responseController'' https://github.com/viswaraavi/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Some functional tests are written for this class using Rspec and Factorygirls.&lt;br /&gt;
;To check these tests.&lt;br /&gt;
*clone the github repository link provided above &lt;br /&gt;
*run the command rspec spec/controllers/response_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=98066</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=98066"/>
		<updated>2015-11-01T03:59:35Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
'''About Expertiza'''&lt;br /&gt;
Expertiza is an open source project accomplished by NCState students. It was developed in Ruby on Rails. It has general features like forming teams, registering for topics in a project, uploading the final deliveries. After completing the project there is an option for submitting reviews as well and updating the reviews. There is an option for submitting new quizzes as well.&lt;br /&gt;
&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
'''What it does''':  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
;Solution&lt;br /&gt;
:&lt;br /&gt;
&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
'''Solution summary'''&lt;br /&gt;
: The method &amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; was renamed to &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 172&lt;br /&gt;
::Post Refactoring : 21&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
'''Original ResponseController'''&amp;lt;ref name=&amp;quot;originalresponsecontroller&amp;gt;''Original responseController'' https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
&lt;br /&gt;
'''Refactored Responsecontroller''' &amp;lt;ref name=&amp;quot;Refactoredresponsecontroller&amp;gt;''Refactored responseController'' https://github.com/viswaraavi/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Some functional tests are written for this class using Rspec and Factorygirls.&lt;br /&gt;
;To check these tests.&lt;br /&gt;
*clone the github repository link provided above &lt;br /&gt;
*run the command rspec spec/controllers/response_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=98041</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=98041"/>
		<updated>2015-11-01T03:24:02Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* Tests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
'''About Expertiza'''&lt;br /&gt;
&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
'''What it does''':  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
;Solution&lt;br /&gt;
:&lt;br /&gt;
&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
'''Solution summary'''&lt;br /&gt;
: The method &amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; was renamed to &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 172&lt;br /&gt;
::Post Refactoring : 21&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
'''Original ResponseController'''&amp;lt;ref name=&amp;quot;originalresponsecontroller&amp;gt;''Original responseController'' https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
&lt;br /&gt;
'''Refactored Responsecontroller''' &amp;lt;ref name=&amp;quot;Refactoredresponsecontroller&amp;gt;''Refactored responseController'' https://github.com/viswaraavi/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Some functional tests are written for this class using Rspec and Factorygirls.&lt;br /&gt;
;To check these tests.&lt;br /&gt;
*clone the github repository link provided above &lt;br /&gt;
*run the command rspec spec/controllers/response_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=98040</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=98040"/>
		<updated>2015-11-01T03:23:44Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* Tests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
'''About Expertiza'''&lt;br /&gt;
&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
'''What it does''':  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
;Solution&lt;br /&gt;
:&lt;br /&gt;
&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
'''Solution summary'''&lt;br /&gt;
: The method &amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; was renamed to &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 172&lt;br /&gt;
::Post Refactoring : 21&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
'''Original ResponseController'''&amp;lt;ref name=&amp;quot;originalresponsecontroller&amp;gt;''Original responseController'' https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
&lt;br /&gt;
'''Refactored Responsecontroller''' &amp;lt;ref name=&amp;quot;Refactoredresponsecontroller&amp;gt;''Refactored responseController'' https://github.com/viswaraavi/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Some functional tests are written for this class using Rspec and Factorygirls.&lt;br /&gt;
;To check these tests.&lt;br /&gt;
*clone the github repository link provided above &lt;br /&gt;
*run the command rspec spec/controllers/response_controller.rb&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=98039</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=98039"/>
		<updated>2015-11-01T03:23:19Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* Tests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
'''About Expertiza'''&lt;br /&gt;
&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
'''What it does''':  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
;Solution&lt;br /&gt;
:&lt;br /&gt;
&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
'''Solution summary'''&lt;br /&gt;
: The method &amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; was renamed to &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 172&lt;br /&gt;
::Post Refactoring : 21&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
'''Original ResponseController'''&amp;lt;ref name=&amp;quot;originalresponsecontroller&amp;gt;''Original responseController'' https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
&lt;br /&gt;
'''Refactored Responsecontroller''' &amp;lt;ref name=&amp;quot;Refactoredresponsecontroller&amp;gt;''Refactored responseController'' https://github.com/viswaraavi/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Some functional tests are written for this class using Rspec and Factorygirls.&lt;br /&gt;
;To check these tests.&lt;br /&gt;
*clone the git repository&lt;br /&gt;
*run the command rspec spec/controllers/response_controller.rb&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=98038</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=98038"/>
		<updated>2015-11-01T03:23:01Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* Tests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
'''About Expertiza'''&lt;br /&gt;
&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
'''What it does''':  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
;Solution&lt;br /&gt;
:&lt;br /&gt;
&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
'''Solution summary'''&lt;br /&gt;
: The method &amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; was renamed to &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 172&lt;br /&gt;
::Post Refactoring : 21&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
'''Original ResponseController'''&amp;lt;ref name=&amp;quot;originalresponsecontroller&amp;gt;''Original responseController'' https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
&lt;br /&gt;
'''Refactored Responsecontroller''' &amp;lt;ref name=&amp;quot;Refactoredresponsecontroller&amp;gt;''Refactored responseController'' https://github.com/viswaraavi/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Some functional tests are written for this class using Rspec and Factorygirls.&lt;br /&gt;
To check these tests.&lt;br /&gt;
*clone the git repository&lt;br /&gt;
*run the command rspec spec/controllers/response_controller.rb&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97699</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97699"/>
		<updated>2015-10-31T21:23:26Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* references */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
'''About Expertiza'''&lt;br /&gt;
&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
'''What it does''':  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
'''Solution summary'''&lt;br /&gt;
: The method &amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; was renamed to &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 172&lt;br /&gt;
::Post Refactoring : 21&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
'''Original ResponseController'''&amp;lt;ref name=&amp;quot;originalresponsecontroller&amp;gt;''Original responseController'' https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
&lt;br /&gt;
'''Refactored Responsecontroller''' &amp;lt;ref name=&amp;quot;Refactoredresponsecontroller&amp;gt;''Refactored responseController'' https://github.com/viswaraavi/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Some functional tests are written for this class.&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97698</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97698"/>
		<updated>2015-10-31T21:23:08Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
'''About Expertiza'''&lt;br /&gt;
&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
'''What it does''':  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
'''Solution summary'''&lt;br /&gt;
: The method &amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; was renamed to &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 172&lt;br /&gt;
::Post Refactoring : 21&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
'''Original ResponseController'''&amp;lt;ref name=&amp;quot;originalresponsecontroller&amp;gt;''Original responseController'' https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
&lt;br /&gt;
'''Refactored Responsecontroller''' &amp;lt;ref name=&amp;quot;Refactoredresponsecontroller&amp;gt;''Refactored responseController'' https://github.com/viswaraavi/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Some functional tests are written for this class.&lt;br /&gt;
==references==&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97697</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97697"/>
		<updated>2015-10-31T21:22:45Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
'''About Expertiza'''&lt;br /&gt;
&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
'''What it does''':  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
'''Solution summary'''&lt;br /&gt;
: The method &amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; was renamed to &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 172&lt;br /&gt;
::Post Refactoring : 21&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
'''Original ResponseController'''&amp;lt;ref name=&amp;quot;originalresponsecontroller&amp;gt;''Original responseController'' https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
&lt;br /&gt;
'''Refactored Responsecontroller''' &amp;lt;ref name=&amp;quot;Refactoredresponsecontroller&amp;gt;''Refactored responseController'' https://github.com/viswaraavi/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Some functional tests are written for this class.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97696</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97696"/>
		<updated>2015-10-31T21:22:26Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
'''About Expertiza'''&lt;br /&gt;
&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
'''What it does''':  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
'''Solution summary'''&lt;br /&gt;
: The method &amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; was renamed to &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 172&lt;br /&gt;
::Post Refactoring : 21&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
'''Original ResponseController'''&amp;lt;ref name=&amp;quot;originalresponsecontroller&amp;gt;''Original responseController'' https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
&lt;br /&gt;
'''Refactored Responsecontroller''' &amp;lt;ref name=&amp;quot;Refactoredresponsecontroller&amp;gt;''Refactored responseController'' https://github.com/viswaraavi/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Some functional tests are written for this class.&lt;br /&gt;
&lt;br /&gt;
==references==&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97694</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97694"/>
		<updated>2015-10-31T21:22:02Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* Tests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
'''About Expertiza'''&lt;br /&gt;
&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
'''What it does''':  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
'''Solution summary'''&lt;br /&gt;
: The method &amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; was renamed to &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 172&lt;br /&gt;
::Post Refactoring : 21&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
'''Original ResponseController'''&amp;lt;ref name=&amp;quot;originalresponsecontroller&amp;gt;''Original responseController'' https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
&lt;br /&gt;
'''Refactored Responsecontroller''' &amp;lt;ref name=&amp;quot;Refactoredresponsecontroller&amp;gt;''Refactored responseController'' https://github.com/viswaraavi/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Some functional tests are written for this class.&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97691</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97691"/>
		<updated>2015-10-31T21:20:37Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* Rename get_scores */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
'''About Expertiza'''&lt;br /&gt;
&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
'''What it does''':  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
'''Solution summary'''&lt;br /&gt;
: The method &amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; was renamed to &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 172&lt;br /&gt;
::Post Refactoring : 21&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
'''Original ResponseController'''&amp;lt;ref name=&amp;quot;originalresponsecontroller&amp;gt;''Original responseController'' https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
&lt;br /&gt;
'''Refactored Responsecontroller''' &amp;lt;ref name=&amp;quot;Refactoredresponsecontroller&amp;gt;''Refactored responseController'' https://github.com/viswaraavi/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Contact: Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
What it does:  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
What needs to be done:&lt;br /&gt;
&lt;br /&gt;
Please write some functional tests for this class.&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97690</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97690"/>
		<updated>2015-10-31T21:20:14Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* Rename get_scores */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
'''About Expertiza'''&lt;br /&gt;
&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
'''What it does''':  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
'''Solution summary'''&lt;br /&gt;
: The method &amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; was renamed to &amp;lt;code&amp;gt;score&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 172&lt;br /&gt;
::Post Refactoring : 21&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
'''Original ResponseController'''&amp;lt;ref name=&amp;quot;originalresponsecontroller&amp;gt;''Original responseController'' https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
&lt;br /&gt;
'''Refactored Responsecontroller''' &amp;lt;ref name=&amp;quot;Refactoredresponsecontroller&amp;gt;''Refactored responseController'' https://github.com/viswaraavi/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Contact: Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
What it does:  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
What needs to be done:&lt;br /&gt;
&lt;br /&gt;
Please write some functional tests for this class.&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97689</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97689"/>
		<updated>2015-10-31T21:20:03Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* Rename get_scores */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
'''About Expertiza'''&lt;br /&gt;
&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
'''What it does''':  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; was renamed to &amp;lt;code&amp;gt;score&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 172&lt;br /&gt;
::Post Refactoring : 21&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
'''Original ResponseController'''&amp;lt;ref name=&amp;quot;originalresponsecontroller&amp;gt;''Original responseController'' https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
&lt;br /&gt;
'''Refactored Responsecontroller''' &amp;lt;ref name=&amp;quot;Refactoredresponsecontroller&amp;gt;''Refactored responseController'' https://github.com/viswaraavi/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Contact: Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
What it does:  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
What needs to be done:&lt;br /&gt;
&lt;br /&gt;
Please write some functional tests for this class.&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97688</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97688"/>
		<updated>2015-10-31T21:17:17Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* Expertiza */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
'''About Expertiza'''&lt;br /&gt;
&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
'''What it does''':  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 172&lt;br /&gt;
::Post Refactoring : 21&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
'''Original ResponseController'''&amp;lt;ref name=&amp;quot;originalresponsecontroller&amp;gt;''Original responseController'' https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
&lt;br /&gt;
'''Refactored Responsecontroller''' &amp;lt;ref name=&amp;quot;Refactoredresponsecontroller&amp;gt;''Refactored responseController'' https://github.com/viswaraavi/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Contact: Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
What it does:  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
What needs to be done:&lt;br /&gt;
&lt;br /&gt;
Please write some functional tests for this class.&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97686</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97686"/>
		<updated>2015-10-31T21:16:46Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* Project Description */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
'''What it does''':  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 172&lt;br /&gt;
::Post Refactoring : 21&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
'''Original ResponseController'''&amp;lt;ref name=&amp;quot;originalresponsecontroller&amp;gt;''Original responseController'' https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
&lt;br /&gt;
'''Refactored Responsecontroller''' &amp;lt;ref name=&amp;quot;Refactoredresponsecontroller&amp;gt;''Refactored responseController'' https://github.com/viswaraavi/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Contact: Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
What it does:  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
What needs to be done:&lt;br /&gt;
&lt;br /&gt;
Please write some functional tests for this class.&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97685</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97685"/>
		<updated>2015-10-31T21:16:32Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* ResponseController */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
'''What it does''':  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
&lt;br /&gt;
== Project Description == &lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 172&lt;br /&gt;
::Post Refactoring : 21&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
'''Original ResponseController'''&amp;lt;ref name=&amp;quot;originalresponsecontroller&amp;gt;''Original responseController'' https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
&lt;br /&gt;
'''Refactored Responsecontroller''' &amp;lt;ref name=&amp;quot;Refactoredresponsecontroller&amp;gt;''Refactored responseController'' https://github.com/viswaraavi/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Contact: Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
What it does:  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
What needs to be done:&lt;br /&gt;
&lt;br /&gt;
Please write some functional tests for this class.&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97684</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97684"/>
		<updated>2015-10-31T21:16:14Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* ResponseController */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
'''What it does''':  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
What needs to be done:&lt;br /&gt;
&lt;br /&gt;
== Project Description == &lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 172&lt;br /&gt;
::Post Refactoring : 21&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
'''Original ResponseController'''&amp;lt;ref name=&amp;quot;originalresponsecontroller&amp;gt;''Original responseController'' https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
&lt;br /&gt;
'''Refactored Responsecontroller''' &amp;lt;ref name=&amp;quot;Refactoredresponsecontroller&amp;gt;''Refactored responseController'' https://github.com/viswaraavi/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Contact: Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
What it does:  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
What needs to be done:&lt;br /&gt;
&lt;br /&gt;
Please write some functional tests for this class.&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97682</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97682"/>
		<updated>2015-10-31T21:16:00Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* ResponseController */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
What it does:  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
What needs to be done:&lt;br /&gt;
&lt;br /&gt;
== Project Description == &lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 172&lt;br /&gt;
::Post Refactoring : 21&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
'''Original ResponseController'''&amp;lt;ref name=&amp;quot;originalresponsecontroller&amp;gt;''Original responseController'' https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
&lt;br /&gt;
'''Refactored Responsecontroller''' &amp;lt;ref name=&amp;quot;Refactoredresponsecontroller&amp;gt;''Refactored responseController'' https://github.com/viswaraavi/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Contact: Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
What it does:  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
What needs to be done:&lt;br /&gt;
&lt;br /&gt;
Please write some functional tests for this class.&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97665</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97665"/>
		<updated>2015-10-31T20:21:58Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* Comparison of Original and Refactored Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
The ResponseController manages Responses.&lt;br /&gt;
&lt;br /&gt;
== Project Description == &lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 172&lt;br /&gt;
::Post Refactoring : 21&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
'''Original ResponseController'''&amp;lt;ref name=&amp;quot;originalresponsecontroller&amp;gt;''Original responseController'' https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
&lt;br /&gt;
'''Refactored Responsecontroller''' &amp;lt;ref name=&amp;quot;Refactoredresponsecontroller&amp;gt;''Refactored responseController'' https://github.com/viswaraavi/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Contact: Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
What it does:  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
What needs to be done:&lt;br /&gt;
&lt;br /&gt;
Please write some functional tests for this class.&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97662</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97662"/>
		<updated>2015-10-31T20:17:53Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* Comparison of Original and Refactored Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
The ResponseController manages Responses.&lt;br /&gt;
&lt;br /&gt;
== Project Description == &lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 172&lt;br /&gt;
::Post Refactoring : 21&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
'''Original ResponseController'''&amp;lt;ref name=&amp;quot;originalresponsecontroller&amp;gt;''Original responseController'' https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
'''&lt;br /&gt;
Refactored Responsecontroller''' &amp;lt;ref name=&amp;quot;Refactoredresponsecontroller&amp;gt;''Refactored responseController'' https://github.com/viswaraavi/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Contact: Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
What it does:  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
What needs to be done:&lt;br /&gt;
&lt;br /&gt;
Please write some functional tests for this class.&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97661</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97661"/>
		<updated>2015-10-31T20:16:55Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* Comparison of Original and Refactored Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
The ResponseController manages Responses.&lt;br /&gt;
&lt;br /&gt;
== Project Description == &lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 172&lt;br /&gt;
::Post Refactoring : 21&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;quot;&amp;quot;Original ResponseController&amp;quot;&amp;quot;&amp;lt;ref name=&amp;quot;originalresponsecontroller&amp;gt;''Original responseController'' https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;quot;&amp;quot;Refactored Responsecontroller&amp;quot;&amp;quot; &amp;lt;ref name=&amp;quot;Refactoredresponsecontroller&amp;gt;''Refactored responseController'' https://github.com/viswaraavi/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Contact: Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
What it does:  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
What needs to be done:&lt;br /&gt;
&lt;br /&gt;
Please write some functional tests for this class.&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97660</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97660"/>
		<updated>2015-10-31T20:15:46Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* Comparison of Original and Refactored Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
The ResponseController manages Responses.&lt;br /&gt;
&lt;br /&gt;
== Project Description == &lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 172&lt;br /&gt;
::Post Refactoring : 21&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Original ResponseController&amp;lt;ref name=&amp;quot;originalresponsecontroller&amp;gt;''Original responseController'' https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
&lt;br /&gt;
Refactored Responsecontroller &amp;lt;ref name=&amp;quot;Refactoredresponsecontroller&amp;gt;''Refactored responseController'' https://github.com/viswaraavi/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Contact: Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
What it does:  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
What needs to be done:&lt;br /&gt;
&lt;br /&gt;
Please write some functional tests for this class.&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97658</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97658"/>
		<updated>2015-10-31T20:14:26Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* Comparison of Original and Refactored Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
The ResponseController manages Responses.&lt;br /&gt;
&lt;br /&gt;
== Project Description == &lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 248&lt;br /&gt;
::Post Refactoring : 224&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Original ResponseController&amp;lt;ref name=&amp;quot;originalresponsecontroller&amp;gt;''Original responseController'' https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
&lt;br /&gt;
Refactored Responsecontroller &amp;lt;ref name=&amp;quot;Refactoredresponsecontroller&amp;gt;''Refactored responseController'' https://github.com/viswaraavi/expertiza&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Contact: Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
What it does:  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
What needs to be done:&lt;br /&gt;
&lt;br /&gt;
Please write some functional tests for this class.&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97654</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97654"/>
		<updated>2015-10-31T20:10:49Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* Remove SQL queries */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
The ResponseController manages Responses.&lt;br /&gt;
&lt;br /&gt;
== Project Description == &lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 248&lt;br /&gt;
::Post Refactoring : 224&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_response.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:Code_climate_expertiza.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Contact: Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
What it does:  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
What needs to be done:&lt;br /&gt;
&lt;br /&gt;
Please write some functional tests for this class.&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97647</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97647"/>
		<updated>2015-10-31T20:07:10Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* Remove SQL queries */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
The ResponseController manages Responses.&lt;br /&gt;
&lt;br /&gt;
== Project Description == &lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 248&lt;br /&gt;
::Post Refactoring : 224&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
[[File:Code climate response.png|thumb|Image taken using codeclimate]]&lt;br /&gt;
&lt;br /&gt;
[[File:Code climate expertiza.png|thumb|image taken using codeclimate]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Contact: Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
What it does:  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
What needs to be done:&lt;br /&gt;
&lt;br /&gt;
Please write some functional tests for this class.&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Code_climate_expertiza.png&amp;diff=97643</id>
		<title>File:Code climate expertiza.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Code_climate_expertiza.png&amp;diff=97643"/>
		<updated>2015-10-31T20:05:04Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Code_climate_response.png&amp;diff=97641</id>
		<title>File:Code climate response.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Code_climate_response.png&amp;diff=97641"/>
		<updated>2015-10-31T20:04:34Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97640</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97640"/>
		<updated>2015-10-31T20:04:01Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* Comparison of Original and Refactored Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
The ResponseController manages Responses.&lt;br /&gt;
&lt;br /&gt;
== Project Description == &lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 248&lt;br /&gt;
::Post Refactoring : 224&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
[[File:Code climate response.png|thumb|Image taken using codeclimate]]&lt;br /&gt;
&lt;br /&gt;
[[File:Code climate expertiza.png|thumb|image taken using codeclimate]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Contact: Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
What it does:  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
What needs to be done:&lt;br /&gt;
&lt;br /&gt;
Please write some functional tests for this class.&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97629</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97629"/>
		<updated>2015-10-31T19:56:19Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* Comparison of Original and Refactored Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
The ResponseController manages Responses.&lt;br /&gt;
&lt;br /&gt;
== Project Description == &lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
::Original duplications : 248&lt;br /&gt;
::Post Refactoring : 224&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
[[File:Codeclimate 1.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:codeclimate 2.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Contact: Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
What it does:  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
What needs to be done:&lt;br /&gt;
&lt;br /&gt;
Please write some functional tests for this class.&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97628</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97628"/>
		<updated>2015-10-31T19:56:02Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* Comparison of Original and Refactored Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
The ResponseController manages Responses.&lt;br /&gt;
&lt;br /&gt;
== Project Description == &lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
&lt;br /&gt;
:Original duplications : 248&lt;br /&gt;
:Post Refactoring : 224&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
[[File:Codeclimate 1.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:codeclimate 2.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Contact: Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
What it does:  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
What needs to be done:&lt;br /&gt;
&lt;br /&gt;
Please write some functional tests for this class.&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97627</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97627"/>
		<updated>2015-10-31T19:55:42Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* Comparison of Original and Refactored Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
The ResponseController manages Responses.&lt;br /&gt;
&lt;br /&gt;
== Project Description == &lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
:Duplications in Code &lt;br /&gt;
&lt;br /&gt;
Original duplications : 248&lt;br /&gt;
Post Refactoring : 224&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
[[File:Codeclimate 1.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:codeclimate 2.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Contact: Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
What it does:  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
What needs to be done:&lt;br /&gt;
&lt;br /&gt;
Please write some functional tests for this class.&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97626</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97626"/>
		<updated>2015-10-31T19:55:17Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
The ResponseController manages Responses.&lt;br /&gt;
&lt;br /&gt;
== Project Description == &lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
==Comparison of Original and Refactored Code==&lt;br /&gt;
Major refactoring revolved around changing method names according to rails convention, using helper methods for avoiding duplication of code in controller methods.&lt;br /&gt;
&lt;br /&gt;
    Duplications in Code &lt;br /&gt;
&lt;br /&gt;
Original duplications : 248&lt;br /&gt;
Post Refactoring : 224&lt;br /&gt;
&lt;br /&gt;
Code Complexity (Compared on Code Climate) &lt;br /&gt;
&lt;br /&gt;
[[File:Codeclimate 1.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:codeclimate 2.png]]&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Contact: Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
What it does:  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
What needs to be done:&lt;br /&gt;
&lt;br /&gt;
Please write some functional tests for this class.&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97613</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97613"/>
		<updated>2015-10-31T19:39:44Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* Delete rereview method */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
The ResponseController manages Responses.&lt;br /&gt;
&lt;br /&gt;
== Project Description == &lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rereview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Contact: Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
What it does:  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
What needs to be done:&lt;br /&gt;
&lt;br /&gt;
Please write some functional tests for this class.&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97610</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97610"/>
		<updated>2015-10-31T19:38:41Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* Consistent authorization */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
The ResponseController manages Responses.&lt;br /&gt;
&lt;br /&gt;
== Project Description == &lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rearview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rearview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Contact: Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
What it does:  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
What needs to be done:&lt;br /&gt;
&lt;br /&gt;
Please write some functional tests for this class.&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97609</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97609"/>
		<updated>2015-10-31T19:37:50Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* Consistent authorization */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
The ResponseController manages Responses.&lt;br /&gt;
&lt;br /&gt;
== Project Description == &lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rearview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rearview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
:: Code before changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Contact: Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
What it does:  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
What needs to be done:&lt;br /&gt;
&lt;br /&gt;
Please write some functional tests for this class.&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97607</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97607"/>
		<updated>2015-10-31T19:36:55Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* Consistent authorization */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
The ResponseController manages Responses.&lt;br /&gt;
&lt;br /&gt;
== Project Description == &lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rearview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rearview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
:So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
: Code before changing&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Contact: Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
What it does:  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
What needs to be done:&lt;br /&gt;
&lt;br /&gt;
Please write some functional tests for this class.&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97606</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97606"/>
		<updated>2015-10-31T19:35:56Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* Consistent authorization */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
The ResponseController manages Responses.&lt;br /&gt;
&lt;br /&gt;
== Project Description == &lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rearview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rearview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file. &lt;br /&gt;
;Solution summary&lt;br /&gt;
So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
: Code before changing&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
def action_allowed?&lt;br /&gt;
    current_user&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
def redirect_when_disallowed(response)&lt;br /&gt;
    # For author feedback, participants need to be able to read feedback submitted by other teammates.&lt;br /&gt;
    # If response is anything but author feedback, only the person who wrote feedback should be able to see it.&lt;br /&gt;
    if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
      team = response.map.reviewer.team&lt;br /&gt;
      unless team.has_user session[:user]&lt;br /&gt;
        redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
      else&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      response.map.read_attribute(:type)&lt;br /&gt;
    end&lt;br /&gt;
    !current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
: Code after changing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'view','edit','delete','update'&lt;br /&gt;
      response = Response.find(params[:id])&lt;br /&gt;
       if response.map.read_attribute(:type) == 'FeedbackResponseMap' &amp;amp;&amp;amp; response.map.assignment.team_assignment?&lt;br /&gt;
        team = response.map.reviewer.team&lt;br /&gt;
        unless team.has_user session[:user]&lt;br /&gt;
          redirect_to '/denied?reason=You are not on the team that wrote this feedback'&lt;br /&gt;
        else&lt;br /&gt;
          return false&lt;br /&gt;
        end&lt;br /&gt;
        response.map.read_attribute(:type)&lt;br /&gt;
      end&lt;br /&gt;
      current_user_id?(response.map.reviewer.user_id)&lt;br /&gt;
    else&lt;br /&gt;
      current_user&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Contact: Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
What it does:  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
What needs to be done:&lt;br /&gt;
&lt;br /&gt;
Please write some functional tests for this class.&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97581</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97581"/>
		<updated>2015-10-31T19:00:12Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: /* Consistent authorization */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
The ResponseController manages Responses.&lt;br /&gt;
&lt;br /&gt;
== Project Description == &lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rearview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rearview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file.  So the functionality is moved from &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;. And also it is made sure  that no one other than the author of a review (or another team member, in the case of author feedback) can edit it and then removed the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:&lt;br /&gt;
&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Contact: Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
What it does:  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
What needs to be done:&lt;br /&gt;
&lt;br /&gt;
Please write some functional tests for this class.&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97569</id>
		<title>CSC/ECE 517 Fall 2015/oss E1551 RGS</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1551_RGS&amp;diff=97569"/>
		<updated>2015-10-31T18:52:46Z</updated>

		<summary type="html">&lt;p&gt;Vravi2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= E1551. Refactoring response_controller.rb =&lt;br /&gt;
== Expertiza ==&lt;br /&gt;
== ResponseController ==&lt;br /&gt;
The ResponseController manages Responses.&lt;br /&gt;
&lt;br /&gt;
== Project Description == &lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
=== Refactor latestResponseVersion method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;latestResponseVersion&amp;lt;/code&amp;gt; is misnamed.  It returns all versions of a response, and anyway, the method name should use underscores, not camelcase.&lt;br /&gt;
=== Rename get_scores ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_scores&amp;lt;/code&amp;gt; has a Java-like name.  It should just be &amp;lt;code&amp;gt;scores&amp;lt;/code&amp;gt;.&lt;br /&gt;
=== Delete rereview method ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:The 100+-line method &amp;lt;code&amp;gt;rearview&amp;lt;/code&amp;gt; does not seem to be used anymore.  The second-round review can be invoked in the same way as the first-round review.  Remove it.&lt;br /&gt;
;Solution summary&lt;br /&gt;
: The method &amp;lt;code&amp;gt;rearview&amp;lt;/code&amp;gt; was deleted.&lt;br /&gt;
=== DRY create and update ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;create&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; use completely different code.  Factor the common parts out into a partial, thereby simplifying the methods.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:There was not much actual overlap in these two methods. Minimal changes.&lt;br /&gt;
=== Consistent authorization ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:Authorization needs to be checked in the &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt; method instead of in &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; at the bottom of the file.  After you move the functionality, check to make sure that no one other than the author of a review (or another team member, in the case of author feedback) can edit it, then remove the &amp;lt;code&amp;gt;redirect_when_disallowed&amp;lt;/code&amp;gt; method.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:&lt;br /&gt;
=== Refactor get_content ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:&amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; is a complex method. It should be renamed to &amp;lt;code&amp;gt;content&amp;lt;/code&amp;gt; and simplified.  Comments should be added explaining what it does.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:The &amp;lt;code&amp;gt;get_content&amp;lt;/code&amp;gt; method was renamed &amp;lt;code&amp;gt;set_content&amp;lt;/code&amp;gt;, simplified, and documented with comments.&lt;br /&gt;
=== Remove SQL queries ===&lt;br /&gt;
;Problem definition&lt;br /&gt;
:This class contains SQL queries.  Please change them to Active Record commands.&lt;br /&gt;
;Solution summary&lt;br /&gt;
:No SQL queries were identified. No changes.&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
Contact: Ed Gehringer, efg@ncsu.edu&lt;br /&gt;
What it does:  response_controller.rb manages Responses.  A Response is what is generated any time a user fills out a rubric--any rubric.  This includes review rubrics, author-feedback rubrics, teammate-review rubrics, quizzes, and surveys.&lt;br /&gt;
Responses come in versions.  Any time an author revises work, and the reviewer comes back to review it, a new Response object is generated.  This Response object points to a particular ReponseMap, which tells who the reviewer is, which team is the reviewee, and what the reviewed entity is.&lt;br /&gt;
What needs to be done:&lt;br /&gt;
&lt;br /&gt;
Please write some functional tests for this class.&lt;/div&gt;</summary>
		<author><name>Vravi2</name></author>
	</entry>
</feed>