<?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=Hson</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=Hson"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Hson"/>
	<updated>2026-05-17T10:09:55Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145455</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145455"/>
		<updated>2022-04-26T20:47:41Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Problem 8: three small classes violates the Expert pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': The columns of the view that were displaying the score and average score were already using partials. This logic was adopted to change the &amp;quot;Team Reviewed&amp;quot; section to use a partial as well. This included moving the code from this section of &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; into a new file in order to render the partial: &amp;lt;code&amp;gt;_team_reviewed.html.erb&amp;lt;/code&amp;gt;. This new file was commented to note what it is doing, and the calling code was modified to pass necessary local variables. The code was also cleaned up to look nicer and align with how other calls in the same block of code were being done.&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;td align = 'left'&amp;gt;&lt;br /&gt;
      &amp;lt;% @response_maps.each_with_index do |reviewer_map, index| %&amp;gt;&lt;br /&gt;
        &amp;lt;% if Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0 %&amp;gt;&lt;br /&gt;
          &amp;lt;% @team = Team.find(reviewer_map.reviewee_id) %&amp;gt;&lt;br /&gt;
          &amp;lt;%= render partial: 'team_reviewed', locals: {bgcolor: @bgcolor, team_id: @team.id, reviewer_id: reviewer.id, reviewer_map: reviewer_map, index: index, reviewer: reviewer} %&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-10395a909ed1f2034b4a4c8f57c0e30382d9492e0b16bb6fe6fb91a424f6f034 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-d158325bd4fd49ca872c3468ac2193f04d7c9fbe32a0497f7181bbc74c21ed8f here]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
*''' Solution Implemented ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to end with &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; to follow standard naming conventions. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Respective calls to these methods in various views and tests have also been refactored to use the updated names&lt;br /&gt;
*''' Changes Made ''': File Changes: [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;, and rename it to &amp;lt;code&amp;gt;awarded_review_score?&amp;lt;/code&amp;gt;&lt;br /&gt;
*''' Solution Implemented ''': After investigation, it was found that &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; does not actually perform any score computation, and shares very similar functionality with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt;. Both methods set instance variables that are retrieved by &amp;lt;code&amp;gt;team_score_score_awarded.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_score.html.erb&amp;lt;/code&amp;gt; respectively. The &amp;lt;code&amp;gt;scoring.rb&amp;lt;/code&amp;gt; model and the models that include it were investigated to find code that could possibly substitute for &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;, but it was found that no comparable method exists. Ultimately, it was decided to keep &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; as-is, but rename it to &amp;lt;code&amp;gt;awarded_review_metrics?&amp;lt;/code&amp;gt;, both to standardize its naming with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt; and to better reflect the fact this method is not involved in score calculation.&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 link]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc&amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. This method should not be counting the number of review rounds, as that is calculated elsewhere in the system.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 here], [https://github.com/expertiza/expertiza/pull/2385/files#diff-6ed94fc2c563ffb24d16737ab83e290c7f9348e82209013580a0e822848947af here]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view (&amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;). Need clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Investigate the validity of the method. If useless, remove it; else, document it and refactor if necessary.&lt;br /&gt;
          &lt;br /&gt;
*''' Solution Implemented ''': Investigation yields the purpose of this method - it adds a link to the associated files that a reviewer uploaded in association with a review (as seen in below image). As such, this is a useful function, so it remains in place. Comments were added to the method header to explain what it is doing. Additionally, the file name was changed to &amp;lt;code&amp;gt;list_review_uploaded_files&amp;lt;/code&amp;gt; to better reflect its functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2239Problem6.png]]&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update. The function.&lt;br /&gt;
&lt;br /&gt;
*'''Changes Made''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove expert pattern violation, a model is newly added: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt; and it includes &amp;lt;code&amp;gt;student_review_strategy&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_review_strategy&amp;lt;/code&amp;gt; classes. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
*'''Changes Made''':[https://github.com/expertiza/expertiza/pull/2385/files#diff-1ffe08b34487becc1b3e011ae44988b88a2e7da38462753ebc16d6a828e42d6c here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-1f05f505eaa5edaf0790cdeb6e774cc499685cce4edf12b253ecd358ce710582 here]&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*&amp;lt;code&amp;gt;team_reviewed.html.erb&amp;lt;/code&amp;gt; has been added to render partials used by &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
1. Updated Rspec files according to refactoring project:&lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
2. Rspec Tested files: All rspec tests are passed &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_controller.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Our refactoring didn't change functionality. Functionality tests were not needed and included.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
* GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
* GitHub Pull Request [https://github.com/expertiza/expertiza/pull/2385/files here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145185</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145185"/>
		<updated>2022-04-25T20:28:22Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': The columns of the view that were displaying the score and average score were already using partials. This logic was adopted to change the &amp;quot;Team Reviewed&amp;quot; section to use a partial as well. This included moving the code from this section of &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; into a new file in order to render the partial: &amp;lt;code&amp;gt;_team_reviewed.html.erb&amp;lt;/code&amp;gt;. This new file was commented to note what it is doing, and the calling code was modified to pass necessary local variables. The code was also cleaned up to look nicer and align with how other calls in the same block of code were being done.&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;td align = 'left'&amp;gt;&lt;br /&gt;
      &amp;lt;% @response_maps.each_with_index do |reviewer_map, index| %&amp;gt;&lt;br /&gt;
        &amp;lt;% if Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0 %&amp;gt;&lt;br /&gt;
          &amp;lt;% @team = Team.find(reviewer_map.reviewee_id) %&amp;gt;&lt;br /&gt;
          &amp;lt;%= render partial: 'team_reviewed', locals: {bgcolor: @bgcolor, team_id: @team.id, reviewer_id: reviewer.id, reviewer_map: reviewer_map, index: index, reviewer: reviewer} %&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
*''' Solution Implemented ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to end with &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; to follow standard naming conventions. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Respective calls to these methods in various views and tests have also been refactored to use the updated names&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 Link to pull request]&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;, and rename it to &amp;lt;code&amp;gt;awarded_review_score?&amp;lt;/code&amp;gt;&lt;br /&gt;
*''' Solution Implemented ''': After investigation, it was found that &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; does not actually perform any score computation, and shares very similar functionality with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt;. Both methods set instance variables that are retrieved by &amp;lt;code&amp;gt;team_score_score_awarded.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_score.html.erb&amp;lt;/code&amp;gt; respectively. The &amp;lt;code&amp;gt;scoring.rb&amp;lt;/code&amp;gt; model and the models that include it were investigated to find code that could possibly substitute for &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;, but it was found that no comparable method exists. Ultimately, it was decided to keep &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; as-is, but rename it to &amp;lt;code&amp;gt;awarded_review_metrics?&amp;lt;/code&amp;gt;, both to standardize its naming with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt; and to better reflect the fact this method is not involved in score calculation.&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 link]&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc&amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. This method should not be counting the number of review rounds, as that is calculated elsewhere in the system.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 here], [https://github.com/expertiza/expertiza/pull/2385/files#diff-6ed94fc2c563ffb24d16737ab83e290c7f9348e82209013580a0e822848947af here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view (&amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;). Need clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Investigate the validity of the method. If useless, remove it; else, document it and refactor if necessary.&lt;br /&gt;
          &lt;br /&gt;
*''' Solution Implemented ''': Investigation yields the purpose of this method - it adds a link to the associated files that a reviewer uploaded in association with a review (as seen in below image). As such, this is a useful function, so it remains in place. Comments were added to the method header to explain what it is doing. Additionally, the file name was changed to &amp;lt;code&amp;gt;list_review_uploaded_files&amp;lt;/code&amp;gt; to better reflect its functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2239Problem6.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update. The function.&lt;br /&gt;
&lt;br /&gt;
*'''Changes Made''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
*'''Changes Made''':[https://github.com/expertiza/expertiza/pull/2385/files#diff-1ffe08b34487becc1b3e011ae44988b88a2e7da38462753ebc16d6a828e42d6c here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-1f05f505eaa5edaf0790cdeb6e774cc499685cce4edf12b253ecd358ce710582 here]&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*&amp;lt;code&amp;gt;team_reviewed.html.erb&amp;lt;/code&amp;gt; has been added to render partials used by &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
1. Updated Rspec files according to refactoring project:&lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
2. Rspec Tested files: All rspec tests are passed &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_controller.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Our refactoring didn't change functionality. Functionality tests were not needed and included.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
* GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
* GitHub Pull Request [https://github.com/expertiza/expertiza/pull/2385/files here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145184</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145184"/>
		<updated>2022-04-25T20:28:00Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': The columns of the view that were displaying the score and average score were already using partials. This logic was adopted to change the &amp;quot;Team Reviewed&amp;quot; section to use a partial as well. This included moving the code from this section of &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; into a new file in order to render the partial: &amp;lt;code&amp;gt;_team_reviewed.html.erb&amp;lt;/code&amp;gt;. This new file was commented to note what it is doing, and the calling code was modified to pass necessary local variables. The code was also cleaned up to look nicer and align with how other calls in the same block of code were being done.&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;td align = 'left'&amp;gt;&lt;br /&gt;
      &amp;lt;% @response_maps.each_with_index do |reviewer_map, index| %&amp;gt;&lt;br /&gt;
        &amp;lt;% if Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0 %&amp;gt;&lt;br /&gt;
          &amp;lt;% @team = Team.find(reviewer_map.reviewee_id) %&amp;gt;&lt;br /&gt;
          &amp;lt;%= render partial: 'team_reviewed', locals: {bgcolor: @bgcolor, team_id: @team.id, reviewer_id: reviewer.id, reviewer_map: reviewer_map, index: index, reviewer: reviewer} %&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
*''' Solution Implemented ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to end with &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; to follow standard naming conventions. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Respective calls to these methods in various views and tests have also been refactored to use the updated names&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 Link to pull request]&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;, and rename it to &amp;lt;code&amp;gt;awarded_review_score?&amp;lt;/code&amp;gt;&lt;br /&gt;
*''' Solution Implemented ''': After investigation, it was found that &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; does not actually perform any score computation, and shares very similar functionality with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt;. Both methods set instance variables that are retrieved by &amp;lt;code&amp;gt;team_score_score_awarded.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_score.html.erb&amp;lt;/code&amp;gt; respectively. The &amp;lt;code&amp;gt;scoring.rb&amp;lt;/code&amp;gt; model and the models that include it were investigated to find code that could possibly substitute for &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;, but it was found that no comparable method exists. Ultimately, it was decided to keep &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; as-is, but rename it to &amp;lt;code&amp;gt;awarded_review_metrics?&amp;lt;/code&amp;gt;, both to standardize its naming with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt; and to better reflect the fact this method is not involved in score calculation.&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 link]&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc&amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. This method should not be counting the number of review rounds, as that is calculated elsewhere in the system.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 here], [https://github.com/expertiza/expertiza/pull/2385/files#diff-6ed94fc2c563ffb24d16737ab83e290c7f9348e82209013580a0e822848947af here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view (&amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;). Need clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Investigate the validity of the method. If useless, remove it; else, document it and refactor if necessary.&lt;br /&gt;
          &lt;br /&gt;
*''' Solution Implemented ''': Investigation yields the purpose of this method - it adds a link to the associated files that a reviewer uploaded in association with a review (as seen in below image). As such, this is a useful function, so it remains in place. Comments were added to the method header to explain what it is doing. Additionally, the file name was changed to &amp;lt;code&amp;gt;list_review_uploaded_files&amp;lt;/code&amp;gt; to better reflect its functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2239Problem6.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update. The function.&lt;br /&gt;
&lt;br /&gt;
*'''Changes Made''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
*'''Changes Made''':[https://github.com/expertiza/expertiza/pull/2385/files#diff-1ffe08b34487becc1b3e011ae44988b88a2e7da38462753ebc16d6a828e42d6c here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-1f05f505eaa5edaf0790cdeb6e774cc499685cce4edf12b253ecd358ce710582 here]&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*&amp;lt;code&amp;gt;team_reviewed.html.erb&amp;lt;/code&amp;gt; has been added to render partials used by &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
1. Updated Rspec files according to refactoring project:&lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
2. Rspec Tested files: All rspec pass &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_controller.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Our refactoring didn't change functionality. Functionality tests were not needed and included.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
* GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
* GitHub Pull Request [https://github.com/expertiza/expertiza/pull/2385/files here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145183</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145183"/>
		<updated>2022-04-25T20:27:30Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': The columns of the view that were displaying the score and average score were already using partials. This logic was adopted to change the &amp;quot;Team Reviewed&amp;quot; section to use a partial as well. This included moving the code from this section of &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; into a new file in order to render the partial: &amp;lt;code&amp;gt;_team_reviewed.html.erb&amp;lt;/code&amp;gt;. This new file was commented to note what it is doing, and the calling code was modified to pass necessary local variables. The code was also cleaned up to look nicer and align with how other calls in the same block of code were being done.&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;td align = 'left'&amp;gt;&lt;br /&gt;
      &amp;lt;% @response_maps.each_with_index do |reviewer_map, index| %&amp;gt;&lt;br /&gt;
        &amp;lt;% if Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0 %&amp;gt;&lt;br /&gt;
          &amp;lt;% @team = Team.find(reviewer_map.reviewee_id) %&amp;gt;&lt;br /&gt;
          &amp;lt;%= render partial: 'team_reviewed', locals: {bgcolor: @bgcolor, team_id: @team.id, reviewer_id: reviewer.id, reviewer_map: reviewer_map, index: index, reviewer: reviewer} %&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
*''' Solution Implemented ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to end with &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; to follow standard naming conventions. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Respective calls to these methods in various views and tests have also been refactored to use the updated names&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 Link to pull request]&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;, and rename it to &amp;lt;code&amp;gt;awarded_review_score?&amp;lt;/code&amp;gt;&lt;br /&gt;
*''' Solution Implemented ''': After investigation, it was found that &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; does not actually perform any score computation, and shares very similar functionality with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt;. Both methods set instance variables that are retrieved by &amp;lt;code&amp;gt;team_score_score_awarded.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_score.html.erb&amp;lt;/code&amp;gt; respectively. The &amp;lt;code&amp;gt;scoring.rb&amp;lt;/code&amp;gt; model and the models that include it were investigated to find code that could possibly substitute for &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;, but it was found that no comparable method exists. Ultimately, it was decided to keep &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; as-is, but rename it to &amp;lt;code&amp;gt;awarded_review_metrics?&amp;lt;/code&amp;gt;, both to standardize its naming with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt; and to better reflect the fact this method is not involved in score calculation.&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 link]&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc&amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. This method should not be counting the number of review rounds, as that is calculated elsewhere in the system.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 here], [https://github.com/expertiza/expertiza/pull/2385/files#diff-6ed94fc2c563ffb24d16737ab83e290c7f9348e82209013580a0e822848947af here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view (&amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;). Need clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Investigate the validity of the method. If useless, remove it; else, document it and refactor if necessary.&lt;br /&gt;
          &lt;br /&gt;
*''' Solution Implemented ''': Investigation yields the purpose of this method - it adds a link to the associated files that a reviewer uploaded in association with a review (as seen in below image). As such, this is a useful function, so it remains in place. Comments were added to the method header to explain what it is doing. Additionally, the file name was changed to &amp;lt;code&amp;gt;list_review_uploaded_files&amp;lt;/code&amp;gt; to better reflect its functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2239Problem6.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update. The function.&lt;br /&gt;
&lt;br /&gt;
*'''Changes Made''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
*'''Changes Made''':[https://github.com/expertiza/expertiza/pull/2385/files#diff-1ffe08b34487becc1b3e011ae44988b88a2e7da38462753ebc16d6a828e42d6c here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-1f05f505eaa5edaf0790cdeb6e774cc499685cce4edf12b253ecd358ce710582 here]&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*&amp;lt;code&amp;gt;team_reviewed.html.erb&amp;lt;/code&amp;gt; has been added to render partials used by &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
1. Updated Rspec files according to refactoring project:&lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
2. Rspec Tested files: &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_controller.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Our refactoring didn't change functionality. Functionality tests were not needed and included.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
* GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
* GitHub Pull Request [https://github.com/expertiza/expertiza/pull/2385/files here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145182</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145182"/>
		<updated>2022-04-25T20:27:15Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Problem 8: three small classes violates the Expert pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': The columns of the view that were displaying the score and average score were already using partials. This logic was adopted to change the &amp;quot;Team Reviewed&amp;quot; section to use a partial as well. This included moving the code from this section of &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; into a new file in order to render the partial: &amp;lt;code&amp;gt;_team_reviewed.html.erb&amp;lt;/code&amp;gt;. This new file was commented to note what it is doing, and the calling code was modified to pass necessary local variables. The code was also cleaned up to look nicer and align with how other calls in the same block of code were being done.&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;td align = 'left'&amp;gt;&lt;br /&gt;
      &amp;lt;% @response_maps.each_with_index do |reviewer_map, index| %&amp;gt;&lt;br /&gt;
        &amp;lt;% if Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0 %&amp;gt;&lt;br /&gt;
          &amp;lt;% @team = Team.find(reviewer_map.reviewee_id) %&amp;gt;&lt;br /&gt;
          &amp;lt;%= render partial: 'team_reviewed', locals: {bgcolor: @bgcolor, team_id: @team.id, reviewer_id: reviewer.id, reviewer_map: reviewer_map, index: index, reviewer: reviewer} %&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
*''' Solution Implemented ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to end with &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; to follow standard naming conventions. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Respective calls to these methods in various views and tests have also been refactored to use the updated names&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 Link to pull request]&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;, and rename it to &amp;lt;code&amp;gt;awarded_review_score?&amp;lt;/code&amp;gt;&lt;br /&gt;
*''' Solution Implemented ''': After investigation, it was found that &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; does not actually perform any score computation, and shares very similar functionality with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt;. Both methods set instance variables that are retrieved by &amp;lt;code&amp;gt;team_score_score_awarded.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_score.html.erb&amp;lt;/code&amp;gt; respectively. The &amp;lt;code&amp;gt;scoring.rb&amp;lt;/code&amp;gt; model and the models that include it were investigated to find code that could possibly substitute for &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;, but it was found that no comparable method exists. Ultimately, it was decided to keep &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; as-is, but rename it to &amp;lt;code&amp;gt;awarded_review_metrics?&amp;lt;/code&amp;gt;, both to standardize its naming with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt; and to better reflect the fact this method is not involved in score calculation.&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 link]&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. This method should not be counting the number of review rounds, as that is calculated elsewhere in the system.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 here], [https://github.com/expertiza/expertiza/pull/2385/files#diff-6ed94fc2c563ffb24d16737ab83e290c7f9348e82209013580a0e822848947af here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view (&amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;). Need clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Investigate the validity of the method. If useless, remove it; else, document it and refactor if necessary.&lt;br /&gt;
          &lt;br /&gt;
*''' Solution Implemented ''': Investigation yields the purpose of this method - it adds a link to the associated files that a reviewer uploaded in association with a review (as seen in below image). As such, this is a useful function, so it remains in place. Comments were added to the method header to explain what it is doing. Additionally, the file name was changed to &amp;lt;code&amp;gt;list_review_uploaded_files&amp;lt;/code&amp;gt; to better reflect its functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2239Problem6.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update. The function.&lt;br /&gt;
&lt;br /&gt;
*'''Changes Made''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
*'''Changes Made''':[https://github.com/expertiza/expertiza/pull/2385/files#diff-1ffe08b34487becc1b3e011ae44988b88a2e7da38462753ebc16d6a828e42d6c here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-1f05f505eaa5edaf0790cdeb6e774cc499685cce4edf12b253ecd358ce710582 here]&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*&amp;lt;code&amp;gt;team_reviewed.html.erb&amp;lt;/code&amp;gt; has been added to render partials used by &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
1. Updated Rspec files according to refactoring project:&lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
2. Rspec Tested files: &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_controller.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Our refactoring didn't change functionality. Functionality tests were not needed and included.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
* GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
* GitHub Pull Request [https://github.com/expertiza/expertiza/pull/2385/files here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145181</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145181"/>
		<updated>2022-04-25T20:26:47Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': The columns of the view that were displaying the score and average score were already using partials. This logic was adopted to change the &amp;quot;Team Reviewed&amp;quot; section to use a partial as well. This included moving the code from this section of &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; into a new file in order to render the partial: &amp;lt;code&amp;gt;_team_reviewed.html.erb&amp;lt;/code&amp;gt;. This new file was commented to note what it is doing, and the calling code was modified to pass necessary local variables. The code was also cleaned up to look nicer and align with how other calls in the same block of code were being done.&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;td align = 'left'&amp;gt;&lt;br /&gt;
      &amp;lt;% @response_maps.each_with_index do |reviewer_map, index| %&amp;gt;&lt;br /&gt;
        &amp;lt;% if Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0 %&amp;gt;&lt;br /&gt;
          &amp;lt;% @team = Team.find(reviewer_map.reviewee_id) %&amp;gt;&lt;br /&gt;
          &amp;lt;%= render partial: 'team_reviewed', locals: {bgcolor: @bgcolor, team_id: @team.id, reviewer_id: reviewer.id, reviewer_map: reviewer_map, index: index, reviewer: reviewer} %&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
*''' Solution Implemented ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to end with &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; to follow standard naming conventions. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Respective calls to these methods in various views and tests have also been refactored to use the updated names&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 Link to pull request]&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;, and rename it to &amp;lt;code&amp;gt;awarded_review_score?&amp;lt;/code&amp;gt;&lt;br /&gt;
*''' Solution Implemented ''': After investigation, it was found that &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; does not actually perform any score computation, and shares very similar functionality with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt;. Both methods set instance variables that are retrieved by &amp;lt;code&amp;gt;team_score_score_awarded.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_score.html.erb&amp;lt;/code&amp;gt; respectively. The &amp;lt;code&amp;gt;scoring.rb&amp;lt;/code&amp;gt; model and the models that include it were investigated to find code that could possibly substitute for &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;, but it was found that no comparable method exists. Ultimately, it was decided to keep &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; as-is, but rename it to &amp;lt;code&amp;gt;awarded_review_metrics?&amp;lt;/code&amp;gt;, both to standardize its naming with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt; and to better reflect the fact this method is not involved in score calculation.&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 link]&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. This method should not be counting the number of review rounds, as that is calculated elsewhere in the system.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 here], [https://github.com/expertiza/expertiza/pull/2385/files#diff-6ed94fc2c563ffb24d16737ab83e290c7f9348e82209013580a0e822848947af here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view (&amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;). Need clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Investigate the validity of the method. If useless, remove it; else, document it and refactor if necessary.&lt;br /&gt;
          &lt;br /&gt;
*''' Solution Implemented ''': Investigation yields the purpose of this method - it adds a link to the associated files that a reviewer uploaded in association with a review (as seen in below image). As such, this is a useful function, so it remains in place. Comments were added to the method header to explain what it is doing. Additionally, the file name was changed to &amp;lt;code&amp;gt;list_review_uploaded_files&amp;lt;/code&amp;gt; to better reflect its functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2239Problem6.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update. The function.&lt;br /&gt;
&lt;br /&gt;
*'''Changes Made''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
*'''Changes Made''':[https://github.com/expertiza/expertiza/pull/2385/files#diff-1ffe08b34487becc1b3e011ae44988b88a2e7da38462753ebc16d6a828e42d6c here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-1f05f505eaa5edaf0790cdeb6e774cc499685cce4edf12b253ecd358ce710582 here]&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*&amp;lt;code&amp;gt;team_reviewed.html.erb&amp;lt;/code&amp;gt; has been added to render partials used by &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
1. Updated Rspec files according to refactoring project:&lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
2. Rspec Tested files: &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_controller.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Our refactoring didn't change functionality. Functionality tests were not needed and included.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
* GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
* GitHub Pull Request [https://github.com/expertiza/expertiza/pull/2385/files here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145180</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145180"/>
		<updated>2022-04-25T20:26:06Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': The columns of the view that were displaying the score and average score were already using partials. This logic was adopted to change the &amp;quot;Team Reviewed&amp;quot; section to use a partial as well. This included moving the code from this section of &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; into a new file in order to render the partial: &amp;lt;code&amp;gt;_team_reviewed.html.erb&amp;lt;/code&amp;gt;. This new file was commented to note what it is doing, and the calling code was modified to pass necessary local variables. The code was also cleaned up to look nicer and align with how other calls in the same block of code were being done.&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;td align = 'left'&amp;gt;&lt;br /&gt;
      &amp;lt;% @response_maps.each_with_index do |reviewer_map, index| %&amp;gt;&lt;br /&gt;
        &amp;lt;% if Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0 %&amp;gt;&lt;br /&gt;
          &amp;lt;% @team = Team.find(reviewer_map.reviewee_id) %&amp;gt;&lt;br /&gt;
          &amp;lt;%= render partial: 'team_reviewed', locals: {bgcolor: @bgcolor, team_id: @team.id, reviewer_id: reviewer.id, reviewer_map: reviewer_map, index: index, reviewer: reviewer} %&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
*''' Solution Implemented ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to end with &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; to follow standard naming conventions. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Respective calls to these methods in various views and tests have also been refactored to use the updated names&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 Link to pull request]&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;, and rename it to &amp;lt;code&amp;gt;awarded_review_score?&amp;lt;/code&amp;gt;&lt;br /&gt;
*''' Solution Implemented ''': After investigation, it was found that &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; does not actually perform any score computation, and shares very similar functionality with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt;. Both methods set instance variables that are retrieved by &amp;lt;code&amp;gt;team_score_score_awarded.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_score.html.erb&amp;lt;/code&amp;gt; respectively. The &amp;lt;code&amp;gt;scoring.rb&amp;lt;/code&amp;gt; model and the models that include it were investigated to find code that could possibly substitute for &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;, but it was found that no comparable method exists. Ultimately, it was decided to keep &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; as-is, but rename it to &amp;lt;code&amp;gt;awarded_review_metrics?&amp;lt;/code&amp;gt;, both to standardize its naming with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt; and to better reflect the fact this method is not involved in score calculation.&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 link]&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. This method should not be counting the number of review rounds, as that is calculated elsewhere in the system.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 here], [https://github.com/expertiza/expertiza/pull/2385/files#diff-6ed94fc2c563ffb24d16737ab83e290c7f9348e82209013580a0e822848947af here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view (&amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;). Need clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Investigate the validity of the method. If useless, remove it; else, document it and refactor if necessary.&lt;br /&gt;
          &lt;br /&gt;
*''' Solution Implemented ''': Investigation yields the purpose of this method - it adds a link to the associated files that a reviewer uploaded in association with a review (as seen in below image). As such, this is a useful function, so it remains in place. Comments were added to the method header to explain what it is doing. Additionally, the file name was changed to &amp;lt;code&amp;gt;list_review_uploaded_files&amp;lt;/code&amp;gt; to better reflect its functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2239Problem6.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update. The function.&lt;br /&gt;
&lt;br /&gt;
*'''Changes Made''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
*'''Changes Made''':[https://github.com/expertiza/expertiza/pull/2385/files#diff-1ffe08b34487becc1b3e011ae44988b88a2e7da38462753ebc16d6a828e42d6c here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-1f05f505eaa5edaf0790cdeb6e774cc499685cce4edf12b253ecd358ce710582 here]&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*&amp;lt;code&amp;gt;team_reviewed.html.erb&amp;lt;/code&amp;gt; has been added to render partials used by &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
1. Updated Rspec files according to refactoring project:&lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
2. Rspec Tested files: &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_controller.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Our refactoring method didn't change functionality.&lt;br /&gt;
No functionality test was needed.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
* GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
* GitHub Pull Request [https://github.com/expertiza/expertiza/pull/2385/files here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145179</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145179"/>
		<updated>2022-04-25T20:25:47Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': The columns of the view that were displaying the score and average score were already using partials. This logic was adopted to change the &amp;quot;Team Reviewed&amp;quot; section to use a partial as well. This included moving the code from this section of &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; into a new file in order to render the partial: &amp;lt;code&amp;gt;_team_reviewed.html.erb&amp;lt;/code&amp;gt;. This new file was commented to note what it is doing, and the calling code was modified to pass necessary local variables. The code was also cleaned up to look nicer and align with how other calls in the same block of code were being done.&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;td align = 'left'&amp;gt;&lt;br /&gt;
      &amp;lt;% @response_maps.each_with_index do |reviewer_map, index| %&amp;gt;&lt;br /&gt;
        &amp;lt;% if Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0 %&amp;gt;&lt;br /&gt;
          &amp;lt;% @team = Team.find(reviewer_map.reviewee_id) %&amp;gt;&lt;br /&gt;
          &amp;lt;%= render partial: 'team_reviewed', locals: {bgcolor: @bgcolor, team_id: @team.id, reviewer_id: reviewer.id, reviewer_map: reviewer_map, index: index, reviewer: reviewer} %&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
*''' Solution Implemented ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to end with &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; to follow standard naming conventions. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Respective calls to these methods in various views and tests have also been refactored to use the updated names&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 Link to pull request]&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;, and rename it to &amp;lt;code&amp;gt;awarded_review_score?&amp;lt;/code&amp;gt;&lt;br /&gt;
*''' Solution Implemented ''': After investigation, it was found that &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; does not actually perform any score computation, and shares very similar functionality with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt;. Both methods set instance variables that are retrieved by &amp;lt;code&amp;gt;team_score_score_awarded.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_score.html.erb&amp;lt;/code&amp;gt; respectively. The &amp;lt;code&amp;gt;scoring.rb&amp;lt;/code&amp;gt; model and the models that include it were investigated to find code that could possibly substitute for &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;, but it was found that no comparable method exists. Ultimately, it was decided to keep &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; as-is, but rename it to &amp;lt;code&amp;gt;awarded_review_metrics?&amp;lt;/code&amp;gt;, both to standardize its naming with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt; and to better reflect the fact this method is not involved in score calculation.&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 link]&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. This method should not be counting the number of review rounds, as that is calculated elsewhere in the system.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 here], [https://github.com/expertiza/expertiza/pull/2385/files#diff-6ed94fc2c563ffb24d16737ab83e290c7f9348e82209013580a0e822848947af here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view (&amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;). Need clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Investigate the validity of the method. If useless, remove it; else, document it and refactor if necessary.&lt;br /&gt;
          &lt;br /&gt;
*''' Solution Implemented ''': Investigation yields the purpose of this method - it adds a link to the associated files that a reviewer uploaded in association with a review (as seen in below image). As such, this is a useful function, so it remains in place. Comments were added to the method header to explain what it is doing. Additionally, the file name was changed to &amp;lt;code&amp;gt;list_review_uploaded_files&amp;lt;/code&amp;gt; to better reflect its functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2239Problem6.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update. The function.&lt;br /&gt;
&lt;br /&gt;
*'''Changes Made''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
*'''Changes Made''':[https://github.com/expertiza/expertiza/pull/2385/files#diff-1ffe08b34487becc1b3e011ae44988b88a2e7da38462753ebc16d6a828e42d6c here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-1f05f505eaa5edaf0790cdeb6e774cc499685cce4edf12b253ecd358ce710582 here]&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*&amp;lt;code&amp;gt;team_reviewed.html.erb&amp;lt;/code&amp;gt; has been added to render partials used by &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
1. Updated Rspec files according to refactoring project:&lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
  * &amp;lt;code/rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
2. Rspec Tested files: &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_controller.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Our refactoring method didn't change functionality.&lt;br /&gt;
No functionality test was needed.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
* GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
* GitHub Pull Request [https://github.com/expertiza/expertiza/pull/2385/files here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145178</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145178"/>
		<updated>2022-04-25T20:25:29Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': The columns of the view that were displaying the score and average score were already using partials. This logic was adopted to change the &amp;quot;Team Reviewed&amp;quot; section to use a partial as well. This included moving the code from this section of &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; into a new file in order to render the partial: &amp;lt;code&amp;gt;_team_reviewed.html.erb&amp;lt;/code&amp;gt;. This new file was commented to note what it is doing, and the calling code was modified to pass necessary local variables. The code was also cleaned up to look nicer and align with how other calls in the same block of code were being done.&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;td align = 'left'&amp;gt;&lt;br /&gt;
      &amp;lt;% @response_maps.each_with_index do |reviewer_map, index| %&amp;gt;&lt;br /&gt;
        &amp;lt;% if Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0 %&amp;gt;&lt;br /&gt;
          &amp;lt;% @team = Team.find(reviewer_map.reviewee_id) %&amp;gt;&lt;br /&gt;
          &amp;lt;%= render partial: 'team_reviewed', locals: {bgcolor: @bgcolor, team_id: @team.id, reviewer_id: reviewer.id, reviewer_map: reviewer_map, index: index, reviewer: reviewer} %&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
*''' Solution Implemented ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to end with &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; to follow standard naming conventions. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Respective calls to these methods in various views and tests have also been refactored to use the updated names&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 Link to pull request]&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;, and rename it to &amp;lt;code&amp;gt;awarded_review_score?&amp;lt;/code&amp;gt;&lt;br /&gt;
*''' Solution Implemented ''': After investigation, it was found that &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; does not actually perform any score computation, and shares very similar functionality with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt;. Both methods set instance variables that are retrieved by &amp;lt;code&amp;gt;team_score_score_awarded.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_score.html.erb&amp;lt;/code&amp;gt; respectively. The &amp;lt;code&amp;gt;scoring.rb&amp;lt;/code&amp;gt; model and the models that include it were investigated to find code that could possibly substitute for &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;, but it was found that no comparable method exists. Ultimately, it was decided to keep &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; as-is, but rename it to &amp;lt;code&amp;gt;awarded_review_metrics?&amp;lt;/code&amp;gt;, both to standardize its naming with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt; and to better reflect the fact this method is not involved in score calculation.&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 link]&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. This method should not be counting the number of review rounds, as that is calculated elsewhere in the system.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 here], [https://github.com/expertiza/expertiza/pull/2385/files#diff-6ed94fc2c563ffb24d16737ab83e290c7f9348e82209013580a0e822848947af here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view (&amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;). Need clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Investigate the validity of the method. If useless, remove it; else, document it and refactor if necessary.&lt;br /&gt;
          &lt;br /&gt;
*''' Solution Implemented ''': Investigation yields the purpose of this method - it adds a link to the associated files that a reviewer uploaded in association with a review (as seen in below image). As such, this is a useful function, so it remains in place. Comments were added to the method header to explain what it is doing. Additionally, the file name was changed to &amp;lt;code&amp;gt;list_review_uploaded_files&amp;lt;/code&amp;gt; to better reflect its functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2239Problem6.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update. The function.&lt;br /&gt;
&lt;br /&gt;
*'''Changes Made''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
*'''Changes Made''':[https://github.com/expertiza/expertiza/pull/2385/files#diff-1ffe08b34487becc1b3e011ae44988b88a2e7da38462753ebc16d6a828e42d6c here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-1f05f505eaa5edaf0790cdeb6e774cc499685cce4edf12b253ecd358ce710582 here]&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*&amp;lt;code&amp;gt;team_reviewed.html.erb&amp;lt;/code&amp;gt; has been added to render partials used by &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
1. Updated Rspec files according to refactoring project:&lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
  * &amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
2. Rspec Tested files: &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
  * &amp;lt;code&amp;gt;/rspec/review_mapping_controller.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
  * &amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Our refactoring method didn't change functionality.&lt;br /&gt;
No functionality test was needed.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
* GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
* GitHub Pull Request [https://github.com/expertiza/expertiza/pull/2385/files here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145176</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145176"/>
		<updated>2022-04-25T20:24:02Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': The columns of the view that were displaying the score and average score were already using partials. This logic was adopted to change the &amp;quot;Team Reviewed&amp;quot; section to use a partial as well. This included moving the code from this section of &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; into a new file in order to render the partial: &amp;lt;code&amp;gt;_team_reviewed.html.erb&amp;lt;/code&amp;gt;. This new file was commented to note what it is doing, and the calling code was modified to pass necessary local variables. The code was also cleaned up to look nicer and align with how other calls in the same block of code were being done.&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;td align = 'left'&amp;gt;&lt;br /&gt;
      &amp;lt;% @response_maps.each_with_index do |reviewer_map, index| %&amp;gt;&lt;br /&gt;
        &amp;lt;% if Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0 %&amp;gt;&lt;br /&gt;
          &amp;lt;% @team = Team.find(reviewer_map.reviewee_id) %&amp;gt;&lt;br /&gt;
          &amp;lt;%= render partial: 'team_reviewed', locals: {bgcolor: @bgcolor, team_id: @team.id, reviewer_id: reviewer.id, reviewer_map: reviewer_map, index: index, reviewer: reviewer} %&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
*''' Solution Implemented ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to end with &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; to follow standard naming conventions. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Respective calls to these methods in various views and tests have also been refactored to use the updated names&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 Link to pull request]&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;, and rename it to &amp;lt;code&amp;gt;awarded_review_score?&amp;lt;/code&amp;gt;&lt;br /&gt;
*''' Solution Implemented ''': After investigation, it was found that &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; does not actually perform any score computation, and shares very similar functionality with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt;. Both methods set instance variables that are retrieved by &amp;lt;code&amp;gt;team_score_score_awarded.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_score.html.erb&amp;lt;/code&amp;gt; respectively. The &amp;lt;code&amp;gt;scoring.rb&amp;lt;/code&amp;gt; model and the models that include it were investigated to find code that could possibly substitute for &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;, but it was found that no comparable method exists. Ultimately, it was decided to keep &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; as-is, but rename it to &amp;lt;code&amp;gt;awarded_review_metrics?&amp;lt;/code&amp;gt;, both to standardize its naming with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt; and to better reflect the fact this method is not involved in score calculation.&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 link]&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. This method should not be counting the number of review rounds, as that is calculated elsewhere in the system.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 here], [https://github.com/expertiza/expertiza/pull/2385/files#diff-6ed94fc2c563ffb24d16737ab83e290c7f9348e82209013580a0e822848947af here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view (&amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;). Need clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Investigate the validity of the method. If useless, remove it; else, document it and refactor if necessary.&lt;br /&gt;
          &lt;br /&gt;
*''' Solution Implemented ''': Investigation yields the purpose of this method - it adds a link to the associated files that a reviewer uploaded in association with a review (as seen in below image). As such, this is a useful function, so it remains in place. Comments were added to the method header to explain what it is doing. Additionally, the file name was changed to &amp;lt;code&amp;gt;list_review_uploaded_files&amp;lt;/code&amp;gt; to better reflect its functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2239Problem6.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update. The function.&lt;br /&gt;
&lt;br /&gt;
*'''Changes Made''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
*'''Changes Made''':[https://github.com/expertiza/expertiza/pull/2385/files#diff-1ffe08b34487becc1b3e011ae44988b88a2e7da38462753ebc16d6a828e42d6c here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-1f05f505eaa5edaf0790cdeb6e774cc499685cce4edf12b253ecd358ce710582 here]&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*&amp;lt;code&amp;gt;team_reviewed.html.erb&amp;lt;/code&amp;gt; has been added to render partials used by &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Updated Rspec files according to refactoring project:&lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
* &amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Rspec Tested files: &lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
- remove feedback_report_record method &lt;br /&gt;
- updated with the new method names&lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_controller.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
* &amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Our refactoring method didn't change functionality.&lt;br /&gt;
No functionality test was needed.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
* GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
* GitHub Pull Request [https://github.com/expertiza/expertiza/pull/2385/files here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145174</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145174"/>
		<updated>2022-04-25T20:22:35Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': The columns of the view that were displaying the score and average score were already using partials. This logic was adopted to change the &amp;quot;Team Reviewed&amp;quot; section to use a partial as well. This included moving the code from this section of &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; into a new file in order to render the partial: &amp;lt;code&amp;gt;_team_reviewed.html.erb&amp;lt;/code&amp;gt;. This new file was commented to note what it is doing, and the calling code was modified to pass necessary local variables. The code was also cleaned up to look nicer and align with how other calls in the same block of code were being done.&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;td align = 'left'&amp;gt;&lt;br /&gt;
      &amp;lt;% @response_maps.each_with_index do |reviewer_map, index| %&amp;gt;&lt;br /&gt;
        &amp;lt;% if Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0 %&amp;gt;&lt;br /&gt;
          &amp;lt;% @team = Team.find(reviewer_map.reviewee_id) %&amp;gt;&lt;br /&gt;
          &amp;lt;%= render partial: 'team_reviewed', locals: {bgcolor: @bgcolor, team_id: @team.id, reviewer_id: reviewer.id, reviewer_map: reviewer_map, index: index, reviewer: reviewer} %&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
*''' Solution Implemented ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to end with &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; to follow standard naming conventions. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Respective calls to these methods in various views and tests have also been refactored to use the updated names&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 Link to pull request]&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;, and rename it to &amp;lt;code&amp;gt;awarded_review_score?&amp;lt;/code&amp;gt;&lt;br /&gt;
*''' Solution Implemented ''': After investigation, it was found that &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; does not actually perform any score computation, and shares very similar functionality with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt;. Both methods set instance variables that are retrieved by &amp;lt;code&amp;gt;team_score_score_awarded.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_score.html.erb&amp;lt;/code&amp;gt; respectively. The &amp;lt;code&amp;gt;scoring.rb&amp;lt;/code&amp;gt; model and the models that include it were investigated to find code that could possibly substitute for &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;, but it was found that no comparable method exists. Ultimately, it was decided to keep &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; as-is, but rename it to &amp;lt;code&amp;gt;awarded_review_metrics?&amp;lt;/code&amp;gt;, both to standardize its naming with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt; and to better reflect the fact this method is not involved in score calculation.&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 link]&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. This method should not be counting the number of review rounds, as that is calculated elsewhere in the system.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 here], [https://github.com/expertiza/expertiza/pull/2385/files#diff-6ed94fc2c563ffb24d16737ab83e290c7f9348e82209013580a0e822848947af here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view (&amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;). Need clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Investigate the validity of the method. If useless, remove it; else, document it and refactor if necessary.&lt;br /&gt;
          &lt;br /&gt;
*''' Solution Implemented ''': Investigation yields the purpose of this method - it adds a link to the associated files that a reviewer uploaded in association with a review (as seen in below image). As such, this is a useful function, so it remains in place. Comments were added to the method header to explain what it is doing. Additionally, the file name was changed to &amp;lt;code&amp;gt;list_review_uploaded_files&amp;lt;/code&amp;gt; to better reflect its functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2239Problem6.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update. The function.&lt;br /&gt;
&lt;br /&gt;
*'''Changes Made''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
*'''Changes Made''':[https://github.com/expertiza/expertiza/pull/2385/files#diff-1ffe08b34487becc1b3e011ae44988b88a2e7da38462753ebc16d6a828e42d6c here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-1f05f505eaa5edaf0790cdeb6e774cc499685cce4edf12b253ecd358ce710582 here]&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*&amp;lt;code&amp;gt;team_reviewed.html.erb&amp;lt;/code&amp;gt; has been added to render partials used by &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Updated Rspec files according to refactoring project:&lt;br /&gt;
*-  &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
*- &amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Rspec Tested files: &lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
- remove feedback_report_record method &lt;br /&gt;
- updated with the new method names&lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_controller.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
* &amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Our refactoring method didn't change functionality.&lt;br /&gt;
No functionality test was needed.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
* GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
* GitHub Pull Request [https://github.com/expertiza/expertiza/pull/2385/files here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145173</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145173"/>
		<updated>2022-04-25T20:22:21Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* GitHub links and Pull Request */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': The columns of the view that were displaying the score and average score were already using partials. This logic was adopted to change the &amp;quot;Team Reviewed&amp;quot; section to use a partial as well. This included moving the code from this section of &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; into a new file in order to render the partial: &amp;lt;code&amp;gt;_team_reviewed.html.erb&amp;lt;/code&amp;gt;. This new file was commented to note what it is doing, and the calling code was modified to pass necessary local variables. The code was also cleaned up to look nicer and align with how other calls in the same block of code were being done.&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;td align = 'left'&amp;gt;&lt;br /&gt;
      &amp;lt;% @response_maps.each_with_index do |reviewer_map, index| %&amp;gt;&lt;br /&gt;
        &amp;lt;% if Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0 %&amp;gt;&lt;br /&gt;
          &amp;lt;% @team = Team.find(reviewer_map.reviewee_id) %&amp;gt;&lt;br /&gt;
          &amp;lt;%= render partial: 'team_reviewed', locals: {bgcolor: @bgcolor, team_id: @team.id, reviewer_id: reviewer.id, reviewer_map: reviewer_map, index: index, reviewer: reviewer} %&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
*''' Solution Implemented ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to end with &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; to follow standard naming conventions. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Respective calls to these methods in various views and tests have also been refactored to use the updated names&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 Link to pull request]&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;, and rename it to &amp;lt;code&amp;gt;awarded_review_score?&amp;lt;/code&amp;gt;&lt;br /&gt;
*''' Solution Implemented ''': After investigation, it was found that &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; does not actually perform any score computation, and shares very similar functionality with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt;. Both methods set instance variables that are retrieved by &amp;lt;code&amp;gt;team_score_score_awarded.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_score.html.erb&amp;lt;/code&amp;gt; respectively. The &amp;lt;code&amp;gt;scoring.rb&amp;lt;/code&amp;gt; model and the models that include it were investigated to find code that could possibly substitute for &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;, but it was found that no comparable method exists. Ultimately, it was decided to keep &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; as-is, but rename it to &amp;lt;code&amp;gt;awarded_review_metrics?&amp;lt;/code&amp;gt;, both to standardize its naming with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt; and to better reflect the fact this method is not involved in score calculation.&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 link]&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. This method should not be counting the number of review rounds, as that is calculated elsewhere in the system.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 here], [https://github.com/expertiza/expertiza/pull/2385/files#diff-6ed94fc2c563ffb24d16737ab83e290c7f9348e82209013580a0e822848947af here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view (&amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;). Need clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Investigate the validity of the method. If useless, remove it; else, document it and refactor if necessary.&lt;br /&gt;
          &lt;br /&gt;
*''' Solution Implemented ''': Investigation yields the purpose of this method - it adds a link to the associated files that a reviewer uploaded in association with a review (as seen in below image). As such, this is a useful function, so it remains in place. Comments were added to the method header to explain what it is doing. Additionally, the file name was changed to &amp;lt;code&amp;gt;list_review_uploaded_files&amp;lt;/code&amp;gt; to better reflect its functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2239Problem6.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update. The function.&lt;br /&gt;
&lt;br /&gt;
*'''Changes Made''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
*'''Changes Made''':[https://github.com/expertiza/expertiza/pull/2385/files#diff-1ffe08b34487becc1b3e011ae44988b88a2e7da38462753ebc16d6a828e42d6c here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-1f05f505eaa5edaf0790cdeb6e774cc499685cce4edf12b253ecd358ce710582 here]&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*&amp;lt;code&amp;gt;team_reviewed.html.erb&amp;lt;/code&amp;gt; has been added to render partials used by &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Updated Rspec files according to refactoring project:&lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
* &amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Rspec Tested files: &lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
- remove feedback_report_record method &lt;br /&gt;
- updated with the new method names&lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_controller.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
* &amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Our refactoring method didn't change functionality.&lt;br /&gt;
No functionality test was needed.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
* GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
* GitHub Pull Request [https://github.com/expertiza/expertiza/pull/2385/files here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145172</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145172"/>
		<updated>2022-04-25T20:21:38Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Problem 7: The method feedback_response_maps violates the Expert pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': The columns of the view that were displaying the score and average score were already using partials. This logic was adopted to change the &amp;quot;Team Reviewed&amp;quot; section to use a partial as well. This included moving the code from this section of &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; into a new file in order to render the partial: &amp;lt;code&amp;gt;_team_reviewed.html.erb&amp;lt;/code&amp;gt;. This new file was commented to note what it is doing, and the calling code was modified to pass necessary local variables. The code was also cleaned up to look nicer and align with how other calls in the same block of code were being done.&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;td align = 'left'&amp;gt;&lt;br /&gt;
      &amp;lt;% @response_maps.each_with_index do |reviewer_map, index| %&amp;gt;&lt;br /&gt;
        &amp;lt;% if Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0 %&amp;gt;&lt;br /&gt;
          &amp;lt;% @team = Team.find(reviewer_map.reviewee_id) %&amp;gt;&lt;br /&gt;
          &amp;lt;%= render partial: 'team_reviewed', locals: {bgcolor: @bgcolor, team_id: @team.id, reviewer_id: reviewer.id, reviewer_map: reviewer_map, index: index, reviewer: reviewer} %&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
*''' Solution Implemented ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to end with &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; to follow standard naming conventions. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Respective calls to these methods in various views and tests have also been refactored to use the updated names&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 Link to pull request]&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;, and rename it to &amp;lt;code&amp;gt;awarded_review_score?&amp;lt;/code&amp;gt;&lt;br /&gt;
*''' Solution Implemented ''': After investigation, it was found that &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; does not actually perform any score computation, and shares very similar functionality with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt;. Both methods set instance variables that are retrieved by &amp;lt;code&amp;gt;team_score_score_awarded.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_score.html.erb&amp;lt;/code&amp;gt; respectively. The &amp;lt;code&amp;gt;scoring.rb&amp;lt;/code&amp;gt; model and the models that include it were investigated to find code that could possibly substitute for &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;, but it was found that no comparable method exists. Ultimately, it was decided to keep &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; as-is, but rename it to &amp;lt;code&amp;gt;awarded_review_metrics?&amp;lt;/code&amp;gt;, both to standardize its naming with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt; and to better reflect the fact this method is not involved in score calculation.&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 link]&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. This method should not be counting the number of review rounds, as that is calculated elsewhere in the system.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 here], [https://github.com/expertiza/expertiza/pull/2385/files#diff-6ed94fc2c563ffb24d16737ab83e290c7f9348e82209013580a0e822848947af here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view (&amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;). Need clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Investigate the validity of the method. If useless, remove it; else, document it and refactor if necessary.&lt;br /&gt;
          &lt;br /&gt;
*''' Solution Implemented ''': Investigation yields the purpose of this method - it adds a link to the associated files that a reviewer uploaded in association with a review (as seen in below image). As such, this is a useful function, so it remains in place. Comments were added to the method header to explain what it is doing. Additionally, the file name was changed to &amp;lt;code&amp;gt;list_review_uploaded_files&amp;lt;/code&amp;gt; to better reflect its functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2239Problem6.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update. The function.&lt;br /&gt;
&lt;br /&gt;
*'''Changes Made''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
*'''Changes Made''':[https://github.com/expertiza/expertiza/pull/2385/files#diff-1ffe08b34487becc1b3e011ae44988b88a2e7da38462753ebc16d6a828e42d6c here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-1f05f505eaa5edaf0790cdeb6e774cc499685cce4edf12b253ecd358ce710582 here]&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*&amp;lt;code&amp;gt;team_reviewed.html.erb&amp;lt;/code&amp;gt; has been added to render partials used by &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Updated Rspec files according to refactoring project:&lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
* &amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Rspec Tested files: &lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
- remove feedback_report_record method &lt;br /&gt;
- updated with the new method names&lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_controller.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
* &amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Our refactoring method didn't change functionality.&lt;br /&gt;
No functionality test was needed.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
* GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
* GitHub Pull Request [https://github.com/expertiza/expertiza/pull/2385/files#]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145171</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145171"/>
		<updated>2022-04-25T20:21:27Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Problem 8: three small classes violates the Expert pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': The columns of the view that were displaying the score and average score were already using partials. This logic was adopted to change the &amp;quot;Team Reviewed&amp;quot; section to use a partial as well. This included moving the code from this section of &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; into a new file in order to render the partial: &amp;lt;code&amp;gt;_team_reviewed.html.erb&amp;lt;/code&amp;gt;. This new file was commented to note what it is doing, and the calling code was modified to pass necessary local variables. The code was also cleaned up to look nicer and align with how other calls in the same block of code were being done.&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;td align = 'left'&amp;gt;&lt;br /&gt;
      &amp;lt;% @response_maps.each_with_index do |reviewer_map, index| %&amp;gt;&lt;br /&gt;
        &amp;lt;% if Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0 %&amp;gt;&lt;br /&gt;
          &amp;lt;% @team = Team.find(reviewer_map.reviewee_id) %&amp;gt;&lt;br /&gt;
          &amp;lt;%= render partial: 'team_reviewed', locals: {bgcolor: @bgcolor, team_id: @team.id, reviewer_id: reviewer.id, reviewer_map: reviewer_map, index: index, reviewer: reviewer} %&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
*''' Solution Implemented ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to end with &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; to follow standard naming conventions. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Respective calls to these methods in various views and tests have also been refactored to use the updated names&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 Link to pull request]&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;, and rename it to &amp;lt;code&amp;gt;awarded_review_score?&amp;lt;/code&amp;gt;&lt;br /&gt;
*''' Solution Implemented ''': After investigation, it was found that &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; does not actually perform any score computation, and shares very similar functionality with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt;. Both methods set instance variables that are retrieved by &amp;lt;code&amp;gt;team_score_score_awarded.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_score.html.erb&amp;lt;/code&amp;gt; respectively. The &amp;lt;code&amp;gt;scoring.rb&amp;lt;/code&amp;gt; model and the models that include it were investigated to find code that could possibly substitute for &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;, but it was found that no comparable method exists. Ultimately, it was decided to keep &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; as-is, but rename it to &amp;lt;code&amp;gt;awarded_review_metrics?&amp;lt;/code&amp;gt;, both to standardize its naming with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt; and to better reflect the fact this method is not involved in score calculation.&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 link]&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. This method should not be counting the number of review rounds, as that is calculated elsewhere in the system.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 here], [https://github.com/expertiza/expertiza/pull/2385/files#diff-6ed94fc2c563ffb24d16737ab83e290c7f9348e82209013580a0e822848947af here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view (&amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;). Need clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Investigate the validity of the method. If useless, remove it; else, document it and refactor if necessary.&lt;br /&gt;
          &lt;br /&gt;
*''' Solution Implemented ''': Investigation yields the purpose of this method - it adds a link to the associated files that a reviewer uploaded in association with a review (as seen in below image). As such, this is a useful function, so it remains in place. Comments were added to the method header to explain what it is doing. Additionally, the file name was changed to &amp;lt;code&amp;gt;list_review_uploaded_files&amp;lt;/code&amp;gt; to better reflect its functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2239Problem6.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update. The function.&lt;br /&gt;
&lt;br /&gt;
*'''Changes Made''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 Here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
*'''Changes Made''':[https://github.com/expertiza/expertiza/pull/2385/files#diff-1ffe08b34487becc1b3e011ae44988b88a2e7da38462753ebc16d6a828e42d6c here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-1f05f505eaa5edaf0790cdeb6e774cc499685cce4edf12b253ecd358ce710582 here]&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*&amp;lt;code&amp;gt;team_reviewed.html.erb&amp;lt;/code&amp;gt; has been added to render partials used by &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Updated Rspec files according to refactoring project:&lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
* &amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Rspec Tested files: &lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
- remove feedback_report_record method &lt;br /&gt;
- updated with the new method names&lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_controller.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
* &amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Our refactoring method didn't change functionality.&lt;br /&gt;
No functionality test was needed.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
* GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
* GitHub Pull Request [https://github.com/expertiza/expertiza/pull/2385/files#]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145168</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145168"/>
		<updated>2022-04-25T20:20:53Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Problem 7: The method feedback_response_maps violates the Expert pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': The columns of the view that were displaying the score and average score were already using partials. This logic was adopted to change the &amp;quot;Team Reviewed&amp;quot; section to use a partial as well. This included moving the code from this section of &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; into a new file in order to render the partial: &amp;lt;code&amp;gt;_team_reviewed.html.erb&amp;lt;/code&amp;gt;. This new file was commented to note what it is doing, and the calling code was modified to pass necessary local variables. The code was also cleaned up to look nicer and align with how other calls in the same block of code were being done.&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;td align = 'left'&amp;gt;&lt;br /&gt;
      &amp;lt;% @response_maps.each_with_index do |reviewer_map, index| %&amp;gt;&lt;br /&gt;
        &amp;lt;% if Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0 %&amp;gt;&lt;br /&gt;
          &amp;lt;% @team = Team.find(reviewer_map.reviewee_id) %&amp;gt;&lt;br /&gt;
          &amp;lt;%= render partial: 'team_reviewed', locals: {bgcolor: @bgcolor, team_id: @team.id, reviewer_id: reviewer.id, reviewer_map: reviewer_map, index: index, reviewer: reviewer} %&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
*''' Solution Implemented ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to end with &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; to follow standard naming conventions. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Respective calls to these methods in various views and tests have also been refactored to use the updated names&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 Link to pull request]&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;, and rename it to &amp;lt;code&amp;gt;awarded_review_score?&amp;lt;/code&amp;gt;&lt;br /&gt;
*''' Solution Implemented ''': After investigation, it was found that &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; does not actually perform any score computation, and shares very similar functionality with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt;. Both methods set instance variables that are retrieved by &amp;lt;code&amp;gt;team_score_score_awarded.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_score.html.erb&amp;lt;/code&amp;gt; respectively. The &amp;lt;code&amp;gt;scoring.rb&amp;lt;/code&amp;gt; model and the models that include it were investigated to find code that could possibly substitute for &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;, but it was found that no comparable method exists. Ultimately, it was decided to keep &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; as-is, but rename it to &amp;lt;code&amp;gt;awarded_review_metrics?&amp;lt;/code&amp;gt;, both to standardize its naming with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt; and to better reflect the fact this method is not involved in score calculation.&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 link]&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. This method should not be counting the number of review rounds, as that is calculated elsewhere in the system.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 here], [https://github.com/expertiza/expertiza/pull/2385/files#diff-6ed94fc2c563ffb24d16737ab83e290c7f9348e82209013580a0e822848947af here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view (&amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;). Need clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Investigate the validity of the method. If useless, remove it; else, document it and refactor if necessary.&lt;br /&gt;
          &lt;br /&gt;
*''' Solution Implemented ''': Investigation yields the purpose of this method - it adds a link to the associated files that a reviewer uploaded in association with a review (as seen in below image). As such, this is a useful function, so it remains in place. Comments were added to the method header to explain what it is doing. Additionally, the file name was changed to &amp;lt;code&amp;gt;list_review_uploaded_files&amp;lt;/code&amp;gt; to better reflect its functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2239Problem6.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update. The function.&lt;br /&gt;
&lt;br /&gt;
*'''Changes Made''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 Here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
*'''Changes Made''':[https://github.com/expertiza/expertiza/pull/2385/files#diff-1ffe08b34487becc1b3e011ae44988b88a2e7da38462753ebc16d6a828e42d6c]&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-1f05f505eaa5edaf0790cdeb6e774cc499685cce4edf12b253ecd358ce710582 here]&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*&amp;lt;code&amp;gt;team_reviewed.html.erb&amp;lt;/code&amp;gt; has been added to render partials used by &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Updated Rspec files according to refactoring project:&lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
* &amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Rspec Tested files: &lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
- remove feedback_report_record method &lt;br /&gt;
- updated with the new method names&lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_controller.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
* &amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Our refactoring method didn't change functionality.&lt;br /&gt;
No functionality test was needed.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
* GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
* GitHub Pull Request [https://github.com/expertiza/expertiza/pull/2385/files#]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145167</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145167"/>
		<updated>2022-04-25T20:20:13Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Problem 7: The method feedback_response_maps violates the Expert pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': The columns of the view that were displaying the score and average score were already using partials. This logic was adopted to change the &amp;quot;Team Reviewed&amp;quot; section to use a partial as well. This included moving the code from this section of &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; into a new file in order to render the partial: &amp;lt;code&amp;gt;_team_reviewed.html.erb&amp;lt;/code&amp;gt;. This new file was commented to note what it is doing, and the calling code was modified to pass necessary local variables. The code was also cleaned up to look nicer and align with how other calls in the same block of code were being done.&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;td align = 'left'&amp;gt;&lt;br /&gt;
      &amp;lt;% @response_maps.each_with_index do |reviewer_map, index| %&amp;gt;&lt;br /&gt;
        &amp;lt;% if Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0 %&amp;gt;&lt;br /&gt;
          &amp;lt;% @team = Team.find(reviewer_map.reviewee_id) %&amp;gt;&lt;br /&gt;
          &amp;lt;%= render partial: 'team_reviewed', locals: {bgcolor: @bgcolor, team_id: @team.id, reviewer_id: reviewer.id, reviewer_map: reviewer_map, index: index, reviewer: reviewer} %&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
*''' Solution Implemented ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to end with &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; to follow standard naming conventions. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Respective calls to these methods in various views and tests have also been refactored to use the updated names&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 Link to pull request]&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;, and rename it to &amp;lt;code&amp;gt;awarded_review_score?&amp;lt;/code&amp;gt;&lt;br /&gt;
*''' Solution Implemented ''': After investigation, it was found that &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; does not actually perform any score computation, and shares very similar functionality with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt;. Both methods set instance variables that are retrieved by &amp;lt;code&amp;gt;team_score_score_awarded.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_score.html.erb&amp;lt;/code&amp;gt; respectively. The &amp;lt;code&amp;gt;scoring.rb&amp;lt;/code&amp;gt; model and the models that include it were investigated to find code that could possibly substitute for &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;, but it was found that no comparable method exists. Ultimately, it was decided to keep &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; as-is, but rename it to &amp;lt;code&amp;gt;awarded_review_metrics?&amp;lt;/code&amp;gt;, both to standardize its naming with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt; and to better reflect the fact this method is not involved in score calculation.&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 link]&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. This method should not be counting the number of review rounds, as that is calculated elsewhere in the system.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 here], [https://github.com/expertiza/expertiza/pull/2385/files#diff-6ed94fc2c563ffb24d16737ab83e290c7f9348e82209013580a0e822848947af here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view (&amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;). Need clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Investigate the validity of the method. If useless, remove it; else, document it and refactor if necessary.&lt;br /&gt;
          &lt;br /&gt;
*''' Solution Implemented ''': Investigation yields the purpose of this method - it adds a link to the associated files that a reviewer uploaded in association with a review (as seen in below image). As such, this is a useful function, so it remains in place. Comments were added to the method header to explain what it is doing. Additionally, the file name was changed to &amp;lt;code&amp;gt;list_review_uploaded_files&amp;lt;/code&amp;gt; to better reflect its functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2239Problem6.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update. The function.&lt;br /&gt;
&lt;br /&gt;
*'''Changes made''': here[https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568]&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
*'''Changes Made''':[https://github.com/expertiza/expertiza/pull/2385/files#diff-1ffe08b34487becc1b3e011ae44988b88a2e7da38462753ebc16d6a828e42d6c]&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-1f05f505eaa5edaf0790cdeb6e774cc499685cce4edf12b253ecd358ce710582 here]&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*&amp;lt;code&amp;gt;team_reviewed.html.erb&amp;lt;/code&amp;gt; has been added to render partials used by &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Updated Rspec files according to refactoring project:&lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
* &amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Rspec Tested files: &lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
- remove feedback_report_record method &lt;br /&gt;
- updated with the new method names&lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_controller.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
* &amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Our refactoring method didn't change functionality.&lt;br /&gt;
No functionality test was needed.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
* GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
* GitHub Pull Request [https://github.com/expertiza/expertiza/pull/2385/files#]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145166</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145166"/>
		<updated>2022-04-25T20:18:47Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': The columns of the view that were displaying the score and average score were already using partials. This logic was adopted to change the &amp;quot;Team Reviewed&amp;quot; section to use a partial as well. This included moving the code from this section of &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; into a new file in order to render the partial: &amp;lt;code&amp;gt;_team_reviewed.html.erb&amp;lt;/code&amp;gt;. This new file was commented to note what it is doing, and the calling code was modified to pass necessary local variables. The code was also cleaned up to look nicer and align with how other calls in the same block of code were being done.&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;td align = 'left'&amp;gt;&lt;br /&gt;
      &amp;lt;% @response_maps.each_with_index do |reviewer_map, index| %&amp;gt;&lt;br /&gt;
        &amp;lt;% if Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0 %&amp;gt;&lt;br /&gt;
          &amp;lt;% @team = Team.find(reviewer_map.reviewee_id) %&amp;gt;&lt;br /&gt;
          &amp;lt;%= render partial: 'team_reviewed', locals: {bgcolor: @bgcolor, team_id: @team.id, reviewer_id: reviewer.id, reviewer_map: reviewer_map, index: index, reviewer: reviewer} %&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
*''' Solution Implemented ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to end with &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; to follow standard naming conventions. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Respective calls to these methods in various views and tests have also been refactored to use the updated names&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 Link to pull request]&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;, and rename it to &amp;lt;code&amp;gt;awarded_review_score?&amp;lt;/code&amp;gt;&lt;br /&gt;
*''' Solution Implemented ''': After investigation, it was found that &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; does not actually perform any score computation, and shares very similar functionality with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt;. Both methods set instance variables that are retrieved by &amp;lt;code&amp;gt;team_score_score_awarded.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_score.html.erb&amp;lt;/code&amp;gt; respectively. The &amp;lt;code&amp;gt;scoring.rb&amp;lt;/code&amp;gt; model and the models that include it were investigated to find code that could possibly substitute for &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;, but it was found that no comparable method exists. Ultimately, it was decided to keep &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; as-is, but rename it to &amp;lt;code&amp;gt;awarded_review_metrics?&amp;lt;/code&amp;gt;, both to standardize its naming with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt; and to better reflect the fact this method is not involved in score calculation.&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 link]&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. This method should not be counting the number of review rounds, as that is calculated elsewhere in the system.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 here], [https://github.com/expertiza/expertiza/pull/2385/files#diff-6ed94fc2c563ffb24d16737ab83e290c7f9348e82209013580a0e822848947af here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view (&amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;). Need clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Investigate the validity of the method. If useless, remove it; else, document it and refactor if necessary.&lt;br /&gt;
          &lt;br /&gt;
*''' Solution Implemented ''': Investigation yields the purpose of this method - it adds a link to the associated files that a reviewer uploaded in association with a review (as seen in below image). As such, this is a useful function, so it remains in place. Comments were added to the method header to explain what it is doing. Additionally, the file name was changed to &amp;lt;code&amp;gt;list_review_uploaded_files&amp;lt;/code&amp;gt; to better reflect its functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2239Problem6.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update. The function.&lt;br /&gt;
&lt;br /&gt;
*'''One thing found''': For the multiple round assignment, &amp;quot;Author feedback report&amp;quot; doesn't create appropriate table. It may require refactor &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
*'''Changes Made''':[https://github.com/expertiza/expertiza/pull/2385/files#diff-1ffe08b34487becc1b3e011ae44988b88a2e7da38462753ebc16d6a828e42d6c]&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-1f05f505eaa5edaf0790cdeb6e774cc499685cce4edf12b253ecd358ce710582 here]&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*&amp;lt;code&amp;gt;team_reviewed.html.erb&amp;lt;/code&amp;gt; has been added to render partials used by &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Updated Rspec files according to refactoring project:&lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
* &amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Rspec Tested files: &lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
- remove feedback_report_record method &lt;br /&gt;
- updated with the new method names&lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_controller.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
* &amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Our refactoring method didn't change functionality.&lt;br /&gt;
No functionality test was needed.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
* GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
* GitHub Pull Request [https://github.com/expertiza/expertiza/pull/2385/files#]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145165</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145165"/>
		<updated>2022-04-25T20:18:29Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': The columns of the view that were displaying the score and average score were already using partials. This logic was adopted to change the &amp;quot;Team Reviewed&amp;quot; section to use a partial as well. This included moving the code from this section of &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; into a new file in order to render the partial: &amp;lt;code&amp;gt;_team_reviewed.html.erb&amp;lt;/code&amp;gt;. This new file was commented to note what it is doing, and the calling code was modified to pass necessary local variables. The code was also cleaned up to look nicer and align with how other calls in the same block of code were being done.&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;td align = 'left'&amp;gt;&lt;br /&gt;
      &amp;lt;% @response_maps.each_with_index do |reviewer_map, index| %&amp;gt;&lt;br /&gt;
        &amp;lt;% if Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0 %&amp;gt;&lt;br /&gt;
          &amp;lt;% @team = Team.find(reviewer_map.reviewee_id) %&amp;gt;&lt;br /&gt;
          &amp;lt;%= render partial: 'team_reviewed', locals: {bgcolor: @bgcolor, team_id: @team.id, reviewer_id: reviewer.id, reviewer_map: reviewer_map, index: index, reviewer: reviewer} %&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
*''' Solution Implemented ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to end with &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; to follow standard naming conventions. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Respective calls to these methods in various views and tests have also been refactored to use the updated names&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 Link to pull request]&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;, and rename it to &amp;lt;code&amp;gt;awarded_review_score?&amp;lt;/code&amp;gt;&lt;br /&gt;
*''' Solution Implemented ''': After investigation, it was found that &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; does not actually perform any score computation, and shares very similar functionality with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt;. Both methods set instance variables that are retrieved by &amp;lt;code&amp;gt;team_score_score_awarded.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_score.html.erb&amp;lt;/code&amp;gt; respectively. The &amp;lt;code&amp;gt;scoring.rb&amp;lt;/code&amp;gt; model and the models that include it were investigated to find code that could possibly substitute for &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;, but it was found that no comparable method exists. Ultimately, it was decided to keep &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; as-is, but rename it to &amp;lt;code&amp;gt;awarded_review_metrics?&amp;lt;/code&amp;gt;, both to standardize its naming with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt; and to better reflect the fact this method is not involved in score calculation.&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 link]&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. This method should not be counting the number of review rounds, as that is calculated elsewhere in the system.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 here], [https://github.com/expertiza/expertiza/pull/2385/files#diff-6ed94fc2c563ffb24d16737ab83e290c7f9348e82209013580a0e822848947af here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view (&amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;). Need clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Investigate the validity of the method. If useless, remove it; else, document it and refactor if necessary.&lt;br /&gt;
          &lt;br /&gt;
*''' Solution Implemented ''': Investigation yields the purpose of this method - it adds a link to the associated files that a reviewer uploaded in association with a review (as seen in below image). As such, this is a useful function, so it remains in place. Comments were added to the method header to explain what it is doing. Additionally, the file name was changed to &amp;lt;code&amp;gt;list_review_uploaded_files&amp;lt;/code&amp;gt; to better reflect its functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2239Problem6.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update. The function.&lt;br /&gt;
&lt;br /&gt;
*'''One thing found''': For the multiple round assignment, &amp;quot;Author feedback report&amp;quot; doesn't create appropriate table. It may require refactor &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
*'''Changes Made''':[https://github.com/expertiza/expertiza/pull/2385/files#diff-1ffe08b34487becc1b3e011ae44988b88a2e7da38462753ebc16d6a828e42d6c]&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-1f05f505eaa5edaf0790cdeb6e774cc499685cce4edf12b253ecd358ce710582 here]&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*&amp;lt;code&amp;gt;team_reviewed.html.erb&amp;lt;/code&amp;gt; has been added to render partials used by &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Updated Rspec files according to refactoring project:&lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
* &amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Rspec Tested files: &lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
- remove feedback_report_record method &lt;br /&gt;
- updated with the new method names&lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_controller.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
* &amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Our refactoring method didn't include functionality change.&lt;br /&gt;
No functionality test was needed.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
* GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
* GitHub Pull Request [https://github.com/expertiza/expertiza/pull/2385/files#]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145164</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145164"/>
		<updated>2022-04-25T20:16:31Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': The columns of the view that were displaying the score and average score were already using partials. This logic was adopted to change the &amp;quot;Team Reviewed&amp;quot; section to use a partial as well. This included moving the code from this section of &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; into a new file in order to render the partial: &amp;lt;code&amp;gt;_team_reviewed.html.erb&amp;lt;/code&amp;gt;. This new file was commented to note what it is doing, and the calling code was modified to pass necessary local variables. The code was also cleaned up to look nicer and align with how other calls in the same block of code were being done.&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;td align = 'left'&amp;gt;&lt;br /&gt;
      &amp;lt;% @response_maps.each_with_index do |reviewer_map, index| %&amp;gt;&lt;br /&gt;
        &amp;lt;% if Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0 %&amp;gt;&lt;br /&gt;
          &amp;lt;% @team = Team.find(reviewer_map.reviewee_id) %&amp;gt;&lt;br /&gt;
          &amp;lt;%= render partial: 'team_reviewed', locals: {bgcolor: @bgcolor, team_id: @team.id, reviewer_id: reviewer.id, reviewer_map: reviewer_map, index: index, reviewer: reviewer} %&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
*''' Solution Implemented ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to end with &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; to follow standard naming conventions. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Respective calls to these methods in various views and tests have also been refactored to use the updated names&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 Link to pull request]&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;, and rename it to &amp;lt;code&amp;gt;awarded_review_score?&amp;lt;/code&amp;gt;&lt;br /&gt;
*''' Solution Implemented ''': After investigation, it was found that &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; does not actually perform any score computation, and shares very similar functionality with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt;. Both methods set instance variables that are retrieved by &amp;lt;code&amp;gt;team_score_score_awarded.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_score.html.erb&amp;lt;/code&amp;gt; respectively. The &amp;lt;code&amp;gt;scoring.rb&amp;lt;/code&amp;gt; model and the models that include it were investigated to find code that could possibly substitute for &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;, but it was found that no comparable method exists. Ultimately, it was decided to keep &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; as-is, but rename it to &amp;lt;code&amp;gt;awarded_review_metrics?&amp;lt;/code&amp;gt;, both to standardize its naming with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt; and to better reflect the fact this method is not involved in score calculation.&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 link]&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. This method should not be counting the number of review rounds, as that is calculated elsewhere in the system.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 here], [https://github.com/expertiza/expertiza/pull/2385/files#diff-6ed94fc2c563ffb24d16737ab83e290c7f9348e82209013580a0e822848947af here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view (&amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;). Need clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Investigate the validity of the method. If useless, remove it; else, document it and refactor if necessary.&lt;br /&gt;
          &lt;br /&gt;
*''' Solution Implemented ''': Investigation yields the purpose of this method - it adds a link to the associated files that a reviewer uploaded in association with a review (as seen in below image). As such, this is a useful function, so it remains in place. Comments were added to the method header to explain what it is doing. Additionally, the file name was changed to &amp;lt;code&amp;gt;list_review_uploaded_files&amp;lt;/code&amp;gt; to better reflect its functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2239Problem6.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update. The function.&lt;br /&gt;
&lt;br /&gt;
*'''One thing found''': For the multiple round assignment, &amp;quot;Author feedback report&amp;quot; doesn't create appropriate table. It may require refactor &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
*'''Changes Made''':[https://github.com/expertiza/expertiza/pull/2385/files#diff-1ffe08b34487becc1b3e011ae44988b88a2e7da38462753ebc16d6a828e42d6c]&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-1f05f505eaa5edaf0790cdeb6e774cc499685cce4edf12b253ecd358ce710582 here]&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*&amp;lt;code&amp;gt;team_reviewed.html.erb&amp;lt;/code&amp;gt; has been added to render partials used by &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Updated Rspec files according to refactoring project:&lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
* &amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Rspec Tested files: &lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_controller.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
* &amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Case#1: Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include it in the Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
* GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
* GitHub Pull Request [https://github.com/expertiza/expertiza/pull/2385/files#]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145108</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145108"/>
		<updated>2022-04-25T02:32:53Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Problem 8: three small classes violates the Expert pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': The columns of the view that were displaying the score and average score were already using partials. This logic was adopted to change the &amp;quot;Team Reviewed&amp;quot; section to use a partial as well. This included moving the code from this section of &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; into a new file in order to render the partial: &amp;lt;code&amp;gt;_team_reviewed.html.erb&amp;lt;/code&amp;gt;. This new file was commented to note what it is doing, and the calling code was modified to pass necessary local variables. The code was also cleaned up to look nicer and align with how other calls in the same block of code were being done.&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;td align = 'left'&amp;gt;&lt;br /&gt;
      &amp;lt;% @response_maps.each_with_index do |reviewer_map, index| %&amp;gt;&lt;br /&gt;
        &amp;lt;% if Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0 %&amp;gt;&lt;br /&gt;
          &amp;lt;% @team = Team.find(reviewer_map.reviewee_id) %&amp;gt;&lt;br /&gt;
          &amp;lt;%= render partial: 'team_reviewed', locals: {bgcolor: @bgcolor, team_id: @team.id, reviewer_id: reviewer.id, reviewer_map: reviewer_map, index: index, reviewer: reviewer} %&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
*''' Solution Implemented ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to end with &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; to follow standard naming conventions. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Respective calls to these methods in various views and tests have also been refactored to use the updated names&lt;br /&gt;
*''' Changes Made ''': [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 Link to pull request]&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;, and rename it to &amp;lt;code&amp;gt;awarded_review_score?&amp;lt;/code&amp;gt;&lt;br /&gt;
*''' Solution Implemented ''': After investigation, it was found that &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; does not actually perform any score computation, and shares very similar functionality with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt;. Both methods set instance variables that are retrieved by &amp;lt;code&amp;gt;team_score_score_awarded.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_score.html.erb&amp;lt;/code&amp;gt; respectively. The &amp;lt;code&amp;gt;scoring.rb&amp;lt;/code&amp;gt; model and the models that include it were investigated to find code that could possibly substitute for &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;, but it was found that no comparable method exists. Ultimately, it was decided to keep &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; as-is, but rename it to &amp;lt;code&amp;gt;awarded_review_metrics?&amp;lt;/code&amp;gt;, both to standardize its naming with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt; and to better reflect the fact this method is not involved in score calculation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. This method should not be counting the number of review rounds, as that is calculated elsewhere in the system.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 here], [https://github.com/expertiza/expertiza/pull/2385/files#diff-6ed94fc2c563ffb24d16737ab83e290c7f9348e82209013580a0e822848947af here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view (&amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;). Need clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Investigate the validity of the method. If useless, remove it; else, document it and refactor if necessary.&lt;br /&gt;
          &lt;br /&gt;
*''' Solution Implemented ''': Investigation yields the purpose of this method - it adds a link to the associated files that a reviewer uploaded in association with a review (as seen in below image). As such, this is a useful function, so it remains in place. Comments were added to the method header to explain what it is doing. Additionally, the file name was changed to &amp;lt;code&amp;gt;list_review_uploaded_files&amp;lt;/code&amp;gt; to better reflect its functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2239Problem6.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update. The function.&lt;br /&gt;
&lt;br /&gt;
*'''One thing found''': For the multiple round assignment, &amp;quot;Author feedback report&amp;quot; doesn't create appropriate table. It may require refactor &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
*'''Changes Made''':[https://github.com/expertiza/expertiza/pull/2385/files#diff-1ffe08b34487becc1b3e011ae44988b88a2e7da38462753ebc16d6a828e42d6c]&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*&amp;lt;code&amp;gt;team_reviewed.html.erb&amp;lt;/code&amp;gt; has been added to render partials used by &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
following Rspec files have updated according to refactoring&lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
* &amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Case#1: Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include it in the Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
* GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
* GitHub Pull Request [https://github.com/expertiza/expertiza/pull/2385/files#]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145105</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145105"/>
		<updated>2022-04-25T02:31:35Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': The columns of the view that were displaying the score and average score were already using partials. This logic was adopted to change the &amp;quot;Team Reviewed&amp;quot; section to use a partial as well. This included moving the code from this section of &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; into a new file in order to render the partial: &amp;lt;code&amp;gt;_team_reviewed.html.erb&amp;lt;/code&amp;gt;. This new file was commented to note what it is doing, and the calling code was modified to pass necessary local variables. The code was also cleaned up to look nicer and align with how other calls in the same block of code were being done.&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;td align = 'left'&amp;gt;&lt;br /&gt;
      &amp;lt;% @response_maps.each_with_index do |reviewer_map, index| %&amp;gt;&lt;br /&gt;
        &amp;lt;% if Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0 %&amp;gt;&lt;br /&gt;
          &amp;lt;% @team = Team.find(reviewer_map.reviewee_id) %&amp;gt;&lt;br /&gt;
          &amp;lt;%= render partial: 'team_reviewed', locals: {bgcolor: @bgcolor, team_id: @team.id, reviewer_id: reviewer.id, reviewer_map: reviewer_map, index: index, reviewer: reviewer} %&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
*''' Solution Implemented ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to end with &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; to follow standard naming conventions. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Respective calls to these methods in various views and tests have also been refactored to use the updated names&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;, and rename it to &amp;lt;code&amp;gt;awarded_review_score?&amp;lt;/code&amp;gt;&lt;br /&gt;
*''' Solution Implemented ''': After investigation, it was found that &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; does not actually perform any score computation, and shares very similar functionality with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt;. Both methods set instance variables that are retrieved by &amp;lt;code&amp;gt;team_score_score_awarded.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_score.html.erb&amp;lt;/code&amp;gt; respectively. The &amp;lt;code&amp;gt;scoring.rb&amp;lt;/code&amp;gt; model and the models that include it were investigated to find code that could possibly substitute for &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;, but it was found that no comparable method exists. Ultimately, it was decided to keep &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; as-is, but rename it to &amp;lt;code&amp;gt;awarded_review_metrics?&amp;lt;/code&amp;gt;, both to standardize its naming with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt; and to better reflect the fact this method is not involved in score calculation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. This method should not be counting the number of review rounds, as that is calculated elsewhere in the system.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 here], [https://github.com/expertiza/expertiza/pull/2385/files#diff-6ed94fc2c563ffb24d16737ab83e290c7f9348e82209013580a0e822848947af here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view (&amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;). Need clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Investigate the validity of the method. If useless, remove it; else, document it and refactor if necessary.&lt;br /&gt;
          &lt;br /&gt;
*''' Solution Implemented ''': Investigation yields the purpose of this method - it adds a link to the associated files that a reviewer uploaded in association with a review (as seen in below image). As such, this is a useful function, so it remains in place. Comments were added to the method header to explain what it is doing. Additionally, the file name was changed to &amp;lt;code&amp;gt;list_review_uploaded_files&amp;lt;/code&amp;gt; to better reflect its functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2239Problem6.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update. The function.&lt;br /&gt;
&lt;br /&gt;
*'''One thing found''': For the multiple round assignment, &amp;quot;Author feedback report&amp;quot; doesn't create appropriate table. It may require refactor &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*&amp;lt;code&amp;gt;team_reviewed.html.erb&amp;lt;/code&amp;gt; has been added to render partials used by &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
following Rspec files have updated according to refactoring&lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
* &amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Case#1: Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include it in the Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
* GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
* GitHub Pull Request [https://github.com/expertiza/expertiza/pull/2385/files#]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145104</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145104"/>
		<updated>2022-04-25T02:30:59Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': The columns of the view that were displaying the score and average score were already using partials. This logic was adopted to change the &amp;quot;Team Reviewed&amp;quot; section to use a partial as well. This included moving the code from this section of &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; into a new file in order to render the partial: &amp;lt;code&amp;gt;_team_reviewed.html.erb&amp;lt;/code&amp;gt;. This new file was commented to note what it is doing, and the calling code was modified to pass necessary local variables. The code was also cleaned up to look nicer and align with how other calls in the same block of code were being done.&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;td align = 'left'&amp;gt;&lt;br /&gt;
      &amp;lt;% @response_maps.each_with_index do |reviewer_map, index| %&amp;gt;&lt;br /&gt;
        &amp;lt;% if Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0 %&amp;gt;&lt;br /&gt;
          &amp;lt;% @team = Team.find(reviewer_map.reviewee_id) %&amp;gt;&lt;br /&gt;
          &amp;lt;%= render partial: 'team_reviewed', locals: {bgcolor: @bgcolor, team_id: @team.id, reviewer_id: reviewer.id, reviewer_map: reviewer_map, index: index, reviewer: reviewer} %&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
*''' Solution Implemented ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to end with &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; to follow standard naming conventions. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Respective calls to these methods in various views and tests have also been refactored to use the updated names&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;, and rename it to &amp;lt;code&amp;gt;awarded_review_score?&amp;lt;/code&amp;gt;&lt;br /&gt;
*''' Solution Implemented ''': After investigation, it was found that &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; does not actually perform any score computation, and shares very similar functionality with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt;. Both methods set instance variables that are retrieved by &amp;lt;code&amp;gt;team_score_score_awarded.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_score.html.erb&amp;lt;/code&amp;gt; respectively. The &amp;lt;code&amp;gt;scoring.rb&amp;lt;/code&amp;gt; model and the models that include it were investigated to find code that could possibly substitute for &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;, but it was found that no comparable method exists. Ultimately, it was decided to keep &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; as-is, but rename it to &amp;lt;code&amp;gt;awarded_review_metrics?&amp;lt;/code&amp;gt;, both to standardize its naming with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt; and to better reflect the fact this method is not involved in score calculation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. This method should not be counting the number of review rounds, as that is calculated elsewhere in the system.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Changes:  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here],  [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 here], [https://github.com/expertiza/expertiza/pull/2385/files#diff-6ed94fc2c563ffb24d16737ab83e290c7f9348e82209013580a0e822848947af here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view (&amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;). Need clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Investigate the validity of the method. If useless, remove it; else, document it and refactor if necessary.&lt;br /&gt;
          &lt;br /&gt;
*''' Solution Implemented ''': Investigation yields the purpose of this method - it adds a link to the associated files that a reviewer uploaded in association with a review (as seen in below image). As such, this is a useful function, so it remains in place. Comments were added to the method header to explain what it is doing. Additionally, the file name was changed to &amp;lt;code&amp;gt;list_review_uploaded_files&amp;lt;/code&amp;gt; to better reflect its functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2239Problem6.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update. The function.&lt;br /&gt;
&lt;br /&gt;
*'''One thing found''': For the multiple round assignment, &amp;quot;Author feedback report&amp;quot; doesn't create appropriate table. It may require refactor &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*&amp;lt;code&amp;gt;team_reviewed.html.erb&amp;lt;/code&amp;gt; has been added to render partials used by &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Rspec file &lt;br /&gt;
* &amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
* &amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; has updated.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Case#1: Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include it in the Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
* GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
* GitHub Pull Request [https://github.com/expertiza/expertiza/pull/2385/files#]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145102</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145102"/>
		<updated>2022-04-25T02:29:20Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* GitHub links and Pull Request */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': The columns of the view that were displaying the score and average score were already using partials. This logic was adopted to change the &amp;quot;Team Reviewed&amp;quot; section to use a partial as well. This included moving the code from this section of &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; into a new file in order to render the partial: &amp;lt;code&amp;gt;_team_reviewed.html.erb&amp;lt;/code&amp;gt;. This new file was commented to note what it is doing, and the calling code was modified to pass necessary local variables. The code was also cleaned up to look nicer and align with how other calls in the same block of code were being done.&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;td align = 'left'&amp;gt;&lt;br /&gt;
      &amp;lt;% @response_maps.each_with_index do |reviewer_map, index| %&amp;gt;&lt;br /&gt;
        &amp;lt;% if Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0 %&amp;gt;&lt;br /&gt;
          &amp;lt;% @team = Team.find(reviewer_map.reviewee_id) %&amp;gt;&lt;br /&gt;
          &amp;lt;%= render partial: 'team_reviewed', locals: {bgcolor: @bgcolor, team_id: @team.id, reviewer_id: reviewer.id, reviewer_map: reviewer_map, index: index, reviewer: reviewer} %&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
*''' Solution Implemented ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to end with &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; to follow standard naming conventions. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Respective calls to these methods in various views and tests have also been refactored to use the updated names&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;, and rename it to &amp;lt;code&amp;gt;awarded_review_score?&amp;lt;/code&amp;gt;&lt;br /&gt;
*''' Solution Implemented ''': After investigation, it was found that &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; does not actually perform any score computation, and shares very similar functionality with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt;. Both methods set instance variables that are retrieved by &amp;lt;code&amp;gt;team_score_score_awarded.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_score.html.erb&amp;lt;/code&amp;gt; respectively. The &amp;lt;code&amp;gt;scoring.rb&amp;lt;/code&amp;gt; model and the models that include it were investigated to find code that could possibly substitute for &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;, but it was found that no comparable method exists. Ultimately, it was decided to keep &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; as-is, but rename it to &amp;lt;code&amp;gt;awarded_review_metrics?&amp;lt;/code&amp;gt;, both to standardize its naming with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt; and to better reflect the fact this method is not involved in score calculation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. This method should not be counting the number of review rounds, as that is calculated elsewhere in the system.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Change 1 -  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here]&lt;br /&gt;
                       File Change 2 -  [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 here]&lt;br /&gt;
                       File Change 3 -  [https://github.com/expertiza/expertiza/pull/2385/files#diff-6ed94fc2c563ffb24d16737ab83e290c7f9348e82209013580a0e822848947af here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view (&amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;). Need clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Investigate the validity of the method. If useless, remove it; else, document it and refactor if necessary.&lt;br /&gt;
          &lt;br /&gt;
*''' Solution Implemented ''': Investigation yields the purpose of this method - it adds a link to the associated files that a reviewer uploaded in association with a review (as seen in below image). As such, this is a useful function, so it remains in place. Comments were added to the method header to explain what it is doing. Additionally, the file name was changed to &amp;lt;code&amp;gt;list_review_uploaded_files&amp;lt;/code&amp;gt; to better reflect its functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2239Problem6.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update. The function.&lt;br /&gt;
&lt;br /&gt;
*'''One thing found''': For the multiple round assignment, &amp;quot;Author feedback report&amp;quot; doesn't create appropriate table. It may require refactor &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*&amp;lt;code&amp;gt;team_reviewed.html.erb&amp;lt;/code&amp;gt; has been added to render partials used by &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Rspec file &lt;br /&gt;
&amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; has updated.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Case#1: Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include it in the Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
* GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
* GitHub Pull Request [https://github.com/expertiza/expertiza/pull/2385/files#]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145101</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145101"/>
		<updated>2022-04-25T02:28:55Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* GitHub links and Pull Request */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': The columns of the view that were displaying the score and average score were already using partials. This logic was adopted to change the &amp;quot;Team Reviewed&amp;quot; section to use a partial as well. This included moving the code from this section of &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; into a new file in order to render the partial: &amp;lt;code&amp;gt;_team_reviewed.html.erb&amp;lt;/code&amp;gt;. This new file was commented to note what it is doing, and the calling code was modified to pass necessary local variables. The code was also cleaned up to look nicer and align with how other calls in the same block of code were being done.&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;td align = 'left'&amp;gt;&lt;br /&gt;
      &amp;lt;% @response_maps.each_with_index do |reviewer_map, index| %&amp;gt;&lt;br /&gt;
        &amp;lt;% if Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0 %&amp;gt;&lt;br /&gt;
          &amp;lt;% @team = Team.find(reviewer_map.reviewee_id) %&amp;gt;&lt;br /&gt;
          &amp;lt;%= render partial: 'team_reviewed', locals: {bgcolor: @bgcolor, team_id: @team.id, reviewer_id: reviewer.id, reviewer_map: reviewer_map, index: index, reviewer: reviewer} %&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
*''' Solution Implemented ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to end with &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; to follow standard naming conventions. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Respective calls to these methods in various views and tests have also been refactored to use the updated names&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;, and rename it to &amp;lt;code&amp;gt;awarded_review_score?&amp;lt;/code&amp;gt;&lt;br /&gt;
*''' Solution Implemented ''': After investigation, it was found that &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; does not actually perform any score computation, and shares very similar functionality with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt;. Both methods set instance variables that are retrieved by &amp;lt;code&amp;gt;team_score_score_awarded.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_score.html.erb&amp;lt;/code&amp;gt; respectively. The &amp;lt;code&amp;gt;scoring.rb&amp;lt;/code&amp;gt; model and the models that include it were investigated to find code that could possibly substitute for &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;, but it was found that no comparable method exists. Ultimately, it was decided to keep &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; as-is, but rename it to &amp;lt;code&amp;gt;awarded_review_metrics?&amp;lt;/code&amp;gt;, both to standardize its naming with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt; and to better reflect the fact this method is not involved in score calculation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. This method should not be counting the number of review rounds, as that is calculated elsewhere in the system.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Change 1 -  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here]&lt;br /&gt;
                       File Change 2 -  [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 here]&lt;br /&gt;
                       File Change 3 -  [https://github.com/expertiza/expertiza/pull/2385/files#diff-6ed94fc2c563ffb24d16737ab83e290c7f9348e82209013580a0e822848947af here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view (&amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;). Need clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Investigate the validity of the method. If useless, remove it; else, document it and refactor if necessary.&lt;br /&gt;
          &lt;br /&gt;
*''' Solution Implemented ''': Investigation yields the purpose of this method - it adds a link to the associated files that a reviewer uploaded in association with a review (as seen in below image). As such, this is a useful function, so it remains in place. Comments were added to the method header to explain what it is doing. Additionally, the file name was changed to &amp;lt;code&amp;gt;list_review_uploaded_files&amp;lt;/code&amp;gt; to better reflect its functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2239Problem6.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update. The function.&lt;br /&gt;
&lt;br /&gt;
*'''One thing found''': For the multiple round assignment, &amp;quot;Author feedback report&amp;quot; doesn't create appropriate table. It may require refactor &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*&amp;lt;code&amp;gt;team_reviewed.html.erb&amp;lt;/code&amp;gt; has been added to render partials used by &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Rspec file &lt;br /&gt;
&amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; has updated.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Case#1: Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include it in the Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
- GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
- GitHub Pull Request [https://github.com/expertiza/expertiza/pull/2385/files#]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145100</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145100"/>
		<updated>2022-04-25T02:28:37Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* GitHub links and Pull Request */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': The columns of the view that were displaying the score and average score were already using partials. This logic was adopted to change the &amp;quot;Team Reviewed&amp;quot; section to use a partial as well. This included moving the code from this section of &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; into a new file in order to render the partial: &amp;lt;code&amp;gt;_team_reviewed.html.erb&amp;lt;/code&amp;gt;. This new file was commented to note what it is doing, and the calling code was modified to pass necessary local variables. The code was also cleaned up to look nicer and align with how other calls in the same block of code were being done.&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;td align = 'left'&amp;gt;&lt;br /&gt;
      &amp;lt;% @response_maps.each_with_index do |reviewer_map, index| %&amp;gt;&lt;br /&gt;
        &amp;lt;% if Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0 %&amp;gt;&lt;br /&gt;
          &amp;lt;% @team = Team.find(reviewer_map.reviewee_id) %&amp;gt;&lt;br /&gt;
          &amp;lt;%= render partial: 'team_reviewed', locals: {bgcolor: @bgcolor, team_id: @team.id, reviewer_id: reviewer.id, reviewer_map: reviewer_map, index: index, reviewer: reviewer} %&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
*''' Solution Implemented ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to end with &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; to follow standard naming conventions. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Respective calls to these methods in various views and tests have also been refactored to use the updated names&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;, and rename it to &amp;lt;code&amp;gt;awarded_review_score?&amp;lt;/code&amp;gt;&lt;br /&gt;
*''' Solution Implemented ''': After investigation, it was found that &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; does not actually perform any score computation, and shares very similar functionality with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt;. Both methods set instance variables that are retrieved by &amp;lt;code&amp;gt;team_score_score_awarded.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_score.html.erb&amp;lt;/code&amp;gt; respectively. The &amp;lt;code&amp;gt;scoring.rb&amp;lt;/code&amp;gt; model and the models that include it were investigated to find code that could possibly substitute for &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;, but it was found that no comparable method exists. Ultimately, it was decided to keep &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; as-is, but rename it to &amp;lt;code&amp;gt;awarded_review_metrics?&amp;lt;/code&amp;gt;, both to standardize its naming with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt; and to better reflect the fact this method is not involved in score calculation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. This method should not be counting the number of review rounds, as that is calculated elsewhere in the system.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
*''' Changes Made ''': File Change 1 -  [https://github.com/expertiza/expertiza/pull/2385/files#diff-c41058c9caa3baa134bad689e28b7903d372d6a64388daccbb2e0ced964da568 here]&lt;br /&gt;
                       File Change 2 -  [https://github.com/expertiza/expertiza/pull/2385/files#diff-dd3da33cc930dd8c0ea397047960fedc8ad0ddd531fa579844c9725d23bdd003 here]&lt;br /&gt;
                       File Change 3 -  [https://github.com/expertiza/expertiza/pull/2385/files#diff-6ed94fc2c563ffb24d16737ab83e290c7f9348e82209013580a0e822848947af here]&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view (&amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;). Need clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Investigate the validity of the method. If useless, remove it; else, document it and refactor if necessary.&lt;br /&gt;
          &lt;br /&gt;
*''' Solution Implemented ''': Investigation yields the purpose of this method - it adds a link to the associated files that a reviewer uploaded in association with a review (as seen in below image). As such, this is a useful function, so it remains in place. Comments were added to the method header to explain what it is doing. Additionally, the file name was changed to &amp;lt;code&amp;gt;list_review_uploaded_files&amp;lt;/code&amp;gt; to better reflect its functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2239Problem6.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update. The function.&lt;br /&gt;
&lt;br /&gt;
*'''One thing found''': For the multiple round assignment, &amp;quot;Author feedback report&amp;quot; doesn't create appropriate table. It may require refactor &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*&amp;lt;code&amp;gt;team_reviewed.html.erb&amp;lt;/code&amp;gt; has been added to render partials used by &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Rspec file &lt;br /&gt;
&amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; has updated.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Case#1: Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include it in the Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
GitHub Pull Request [https://github.com/expertiza/expertiza/pull/2385/files#]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145098</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145098"/>
		<updated>2022-04-25T02:23:52Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': The columns of the view that were displaying the score and average score were already using partials. This logic was adopted to change the &amp;quot;Team Reviewed&amp;quot; section to use a partial as well. This included moving the code from this section of &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; into a new file in order to render the partial: &amp;lt;code&amp;gt;_team_reviewed.html.erb&amp;lt;/code&amp;gt;. This new file was commented to note what it is doing, and the calling code was modified to pass necessary local variables. The code was also cleaned up to look nicer and align with how other calls in the same block of code were being done.&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;td align = 'left'&amp;gt;&lt;br /&gt;
      &amp;lt;% @response_maps.each_with_index do |reviewer_map, index| %&amp;gt;&lt;br /&gt;
        &amp;lt;% if Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0 %&amp;gt;&lt;br /&gt;
          &amp;lt;% @team = Team.find(reviewer_map.reviewee_id) %&amp;gt;&lt;br /&gt;
          &amp;lt;%= render partial: 'team_reviewed', locals: {bgcolor: @bgcolor, team_id: @team.id, reviewer_id: reviewer.id, reviewer_map: reviewer_map, index: index, reviewer: reviewer} %&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
*''' Solution Implemented ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to end with &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; to follow standard naming conventions. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Respective calls to these methods in various views and tests have also been refactored to use the updated names&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;, and rename it to &amp;lt;code&amp;gt;awarded_review_score?&amp;lt;/code&amp;gt;&lt;br /&gt;
*''' Solution Implemented ''': After investigation, it was found that &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; does not actually perform any score computation, and shares very similar functionality with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt;. Both methods set instance variables that are retrieved by &amp;lt;code&amp;gt;team_score_score_awarded.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_score.html.erb&amp;lt;/code&amp;gt; respectively. The &amp;lt;code&amp;gt;scoring.rb&amp;lt;/code&amp;gt; model and the models that include it were investigated to find code that could possibly substitute for &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;, but it was found that no comparable method exists. Ultimately, it was decided to keep &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; as-is, but rename it to &amp;lt;code&amp;gt;awarded_review_metrics?&amp;lt;/code&amp;gt;, both to standardize its naming with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt; and to better reflect the fact this method is not involved in score calculation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. This method should not be counting the number of review rounds, as that is calculated elsewhere in the system.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view (&amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;). Need clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Investigate the validity of the method. If useless, remove it; else, document it and refactor if necessary.&lt;br /&gt;
          &lt;br /&gt;
*''' Solution Implemented ''': Investigation yields the purpose of this method - it adds a link to the associated files that a reviewer uploaded in association with a review (as seen in below image). As such, this is a useful function, so it remains in place. Comments were added to the method header to explain what it is doing. Additionally, the file name was changed to &amp;lt;code&amp;gt;list_review_uploaded_files&amp;lt;/code&amp;gt; to better reflect its functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2239Problem6.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update. The function.&lt;br /&gt;
&lt;br /&gt;
*'''One thing found''': For the multiple round assignment, &amp;quot;Author feedback report&amp;quot; doesn't create appropriate table. It may require refactor &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*&amp;lt;code&amp;gt;team_reviewed.html.erb&amp;lt;/code&amp;gt; has been added to render partials used by &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Rspec file &lt;br /&gt;
&amp;lt;code&amp;gt;/rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; has updated.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Case#1: Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include it in the Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145097</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145097"/>
		<updated>2022-04-25T02:17:40Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': The columns of the view that were displaying the score and average score were already using partials. This logic was adopted to change the &amp;quot;Team Reviewed&amp;quot; section to use a partial as well. This included moving the code from this section of &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; into a new file in order to render the partial: &amp;lt;code&amp;gt;_team_reviewed.html.erb&amp;lt;/code&amp;gt;. This new file was commented to note what it is doing, and the calling code was modified to pass necessary local variables. The code was also cleaned up to look nicer and align with how other calls in the same block of code were being done.&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;td align = 'left'&amp;gt;&lt;br /&gt;
      &amp;lt;% @response_maps.each_with_index do |reviewer_map, index| %&amp;gt;&lt;br /&gt;
        &amp;lt;% if Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0 %&amp;gt;&lt;br /&gt;
          &amp;lt;% @team = Team.find(reviewer_map.reviewee_id) %&amp;gt;&lt;br /&gt;
          &amp;lt;%= render partial: 'team_reviewed', locals: {bgcolor: @bgcolor, team_id: @team.id, reviewer_id: reviewer.id, reviewer_map: reviewer_map, index: index, reviewer: reviewer} %&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
*''' Solution Implemented ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to end with &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; to follow standard naming conventions. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Respective calls to these methods in various views and tests have also been refactored to use the updated names&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;, and rename it to &amp;lt;code&amp;gt;awarded_review_score?&amp;lt;/code&amp;gt;&lt;br /&gt;
*''' Solution Implemented ''': After investigation, it was found that &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; does not actually perform any score computation, and shares very similar functionality with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt;. Both methods set instance variables that are retrieved by &amp;lt;code&amp;gt;team_score_score_awarded.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_score.html.erb&amp;lt;/code&amp;gt; respectively. The &amp;lt;code&amp;gt;scoring.rb&amp;lt;/code&amp;gt; model and the models that include it were investigated to find code that could possibly substitute for &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;, but it was found that no comparable method exists. Ultimately, it was decided to keep &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; as-is, but rename it to &amp;lt;code&amp;gt;awarded_review_metrics?&amp;lt;/code&amp;gt;, both to standardize its naming with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt; and to better reflect the fact this method is not involved in score calculation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. This method should not be counting the number of review rounds, as that is calculated elsewhere in the system.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view (&amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;). Need clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Investigate the validity of the method. If useless, remove it; else, document it and refactor if necessary.&lt;br /&gt;
          &lt;br /&gt;
*''' Solution Implemented ''': Investigation yields the purpose of this method - it adds a link to the associated files that a reviewer uploaded in association with a review (as seen in below image). As such, this is a useful function, so it remains in place. Comments were added to the method header to explain what it is doing. Additionally, the file name was changed to &amp;lt;code&amp;gt;list_review_uploaded_files&amp;lt;/code&amp;gt; to better reflect its functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2239Problem6.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update. The function.&lt;br /&gt;
&lt;br /&gt;
*'''One thing found''': For the multiple round assignment, &amp;quot;Author feedback report&amp;quot; doesn't create appropriate table. It may require refactor &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*&amp;lt;code&amp;gt;team_reviewed.html.erb&amp;lt;/code&amp;gt; has been added to render partials used by &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Rspec file &amp;lt;code&amp;gt; /rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;code&amp;gt; /rspec/review_mapping_chart_helper_spec.rb&amp;lt;/code&amp;gt; has updated.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Case#1: Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include it in the Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145095</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145095"/>
		<updated>2022-04-25T00:32:40Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Problem 7: The method feedback_response_maps violates the Expert pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': The columns of the view that were displaying the score and average score were already using partials. This logic was adopted to change the &amp;quot;Team Reviewed&amp;quot; section to use a partial as well. This included moving the code from this section of &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; into a new file in order to render the partial: &amp;lt;code&amp;gt;_team_reviewed.html.erb&amp;lt;/code&amp;gt;. This new file was commented to note what it is doing, and the calling code was modified to pass necessary local variables. The code was also cleaned up to look nicer and align with how other calls in the same block of code were being done.&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;td align = 'left'&amp;gt;&lt;br /&gt;
      &amp;lt;% @response_maps.each_with_index do |reviewer_map, index| %&amp;gt;&lt;br /&gt;
        &amp;lt;% if Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0 %&amp;gt;&lt;br /&gt;
          &amp;lt;% @team = Team.find(reviewer_map.reviewee_id) %&amp;gt;&lt;br /&gt;
          &amp;lt;%= render partial: 'team_reviewed', locals: {bgcolor: @bgcolor, team_id: @team.id, reviewer_id: reviewer.id, reviewer_map: reviewer_map, index: index, reviewer: reviewer} %&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
*''' Solution Implemented ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to end with &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; to follow standard naming conventions. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Respective calls to these methods in various views and tests have also been refactored to use the updated names&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;, and rename it to &amp;lt;code&amp;gt;awarded_review_score?&amp;lt;/code&amp;gt;&lt;br /&gt;
*''' Solution Implemented ''': After investigation, it was found that &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; does not actually perform any score computation, and shares very similar functionality with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt;. Both methods set instance variables that are retrieved by &amp;lt;code&amp;gt;team_score_score_awarded.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_score.html.erb&amp;lt;/code&amp;gt; respectively. The &amp;lt;code&amp;gt;scoring.rb&amp;lt;/code&amp;gt; model and the models that include it were investigated to find code that could possibly substitute for &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;, but it was found that no comparable method exists. Ultimately, it was decided to keep &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; as-is, but rename it to &amp;lt;code&amp;gt;awarded_review_metrics?&amp;lt;/code&amp;gt;, both to standardize its naming with &amp;lt;code&amp;gt;review_metrics&amp;lt;/code&amp;gt; and to better reflect the fact this method is not involved in score calculation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. This method should not be counting the number of review rounds, as that is calculated elsewhere in the system.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view (&amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;). Need clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Investigate the validity of the method. If useless, remove it; else, document it and refactor if necessary.&lt;br /&gt;
          &lt;br /&gt;
*''' Solution Implemented ''': Investigation yields the purpose of this method - it adds a link to the associated files that a reviewer uploaded in association with a review (as seen in below image). As such, this is a useful function, so it remains in place. Comments were added to the method header to explain what it is doing. Additionally, the file name was changed to &amp;lt;code&amp;gt;list_review_uploaded_files&amp;lt;/code&amp;gt; to better reflect its functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2239Problem6.png]]&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update. The function.&lt;br /&gt;
&lt;br /&gt;
*'''One thing found''': For the multiple round assignment, &amp;quot;Author feedback report&amp;quot; doesn't create appropriate table. It may require refactor &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*&amp;lt;code&amp;gt;team_reviewed.html.erb&amp;lt;/code&amp;gt; has been added to render partials used by &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Rspec file &amp;lt;code&amp;gt; /rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; will be updated depending on the following cases.&lt;br /&gt;
&lt;br /&gt;
1. Case#1: Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include it in the Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145052</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145052"/>
		<updated>2022-04-24T01:16:45Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Problem 7: The method feedback_response_maps violates the Expert pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
*''' Solution Implemented ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to end with &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; to follow standard naming conventions. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Respective calls to these methods in various views and tests have also been refactored to use the updated names&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view. Needs clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': See if there is a way to get rid of it or incorporate it into the main method.&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update.&lt;br /&gt;
&lt;br /&gt;
*'''One thing found''': For the multiple round assignment, &amp;quot;Author feedback report&amp;quot; doesn't create appropriate table. It may require refactor &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Rspec file &amp;lt;code&amp;gt; /rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; will be updated depending on the following cases.&lt;br /&gt;
&lt;br /&gt;
1. Case#1: Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include it in the Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145049</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145049"/>
		<updated>2022-04-23T19:24:00Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Problem 7: The method feedback_response_maps violates the Expert pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view. Needs clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': See if there is a way to get rid of it or incorporate it into the main method.&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
'''FeedbackResponseMap''' found in two places in &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; =&amp;gt; will add comments to make this code understandable.&lt;br /&gt;
&lt;br /&gt;
   def get_certain_review_and_feedback_response_map(author)&lt;br /&gt;
       @feedback_response_maps = '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?', @all_review_response_ids, author.id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update.&lt;br /&gt;
&lt;br /&gt;
*'''One thing found''': For the multiple round assignment, &amp;quot;Author feedback report&amp;quot; doesn't create appropriate table. It may require refactor &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Rspec file &amp;lt;code&amp;gt; /rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; will be updated depending on the following cases.&lt;br /&gt;
&lt;br /&gt;
1. Case#1: Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include it in the Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145048</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145048"/>
		<updated>2022-04-23T19:19:04Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Problem 7: The method feedback_response_maps violates the Expert pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view. Needs clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': See if there is a way to get rid of it or incorporate it into the main method.&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
'''FeedbackResponseMap''' found in two places in &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; =&amp;gt; will add comments to make this code understandable.&lt;br /&gt;
&lt;br /&gt;
   def get_certain_review_and_feedback_response_map(author)&lt;br /&gt;
       @feedback_response_maps = '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?', @all_review_response_ids, author.id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and the instance variable for each round is already assigned in &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update.&lt;br /&gt;
&lt;br /&gt;
*'''One thing found''': For the multiple round assignment, &amp;quot;Author feedback report&amp;quot; doesn't create appropriate table. It may require refactor &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Rspec file &amp;lt;code&amp;gt; /rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; will be updated depending on the following cases.&lt;br /&gt;
&lt;br /&gt;
1. Case#1: Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include it in the Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145047</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145047"/>
		<updated>2022-04-23T19:17:13Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Problem 7: The method feedback_response_maps violates the Expert pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view. Needs clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': See if there is a way to get rid of it or incorporate it into the main method.&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps &amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
'''FeedbackResponseMap''' found in two places in &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; =&amp;gt; will add comments to make this code understandable.&lt;br /&gt;
&lt;br /&gt;
   def get_certain_review_and_feedback_response_map(author)&lt;br /&gt;
       @feedback_response_maps = '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?', @all_review_response_ids, author.id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and the instance variable for each round is already assigned in &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update.&lt;br /&gt;
&lt;br /&gt;
*'''One thing found''': For the multiple round assignment, &amp;quot;Author feedback report&amp;quot; doesn't create appropriate table. It may require refactor &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Rspec file &amp;lt;code&amp;gt; /rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; will be updated depending on the following cases.&lt;br /&gt;
&lt;br /&gt;
1. Case#1: Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include it in the Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145046</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145046"/>
		<updated>2022-04-23T18:58:05Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Problem 7: The method feedback_response_maps violates the Expert pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view. Needs clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': See if there is a way to get rid of it or incorporate it into the main method.&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps &amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
'''FeedbackResponseMap''' found in two places in &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; =&amp;gt; will add comments to make this code understandable.&lt;br /&gt;
&lt;br /&gt;
   def get_certain_review_and_feedback_response_map(author)&lt;br /&gt;
       @feedback_response_maps = '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?', @all_review_response_ids, author.id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt; and the instance variable for each round is already assigned in &amp;lt;code&amp;gt;feedback_response_map&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update.&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Rspec file &amp;lt;code&amp;gt; /rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; will be updated depending on the following cases.&lt;br /&gt;
&lt;br /&gt;
1. Case#1: Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include it in the Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145045</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145045"/>
		<updated>2022-04-23T05:16:34Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Problem 8: three small classes violates the Expert pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view. Needs clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': See if there is a way to get rid of it or incorporate it into the main method.&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps &amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
'''FeedbackResponseMap''' found in two places in &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; =&amp;gt; will add comments to make this code understandable.&lt;br /&gt;
&lt;br /&gt;
   def get_certain_review_and_feedback_response_map(author)&lt;br /&gt;
       @feedback_response_maps = '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?', @all_review_response_ids, author.id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update.&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy.rb&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy.rb&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Rspec file &amp;lt;code&amp;gt; /rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; will be updated depending on the following cases.&lt;br /&gt;
&lt;br /&gt;
1. Case#1: Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include it in the Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145044</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145044"/>
		<updated>2022-04-23T05:16:15Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Problem 8: three small classes violates the Expert pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view. Needs clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': See if there is a way to get rid of it or incorporate it into the main method.&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps &amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
'''FeedbackResponseMap''' found in two places in &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; =&amp;gt; will add comments to make this code understandable.&lt;br /&gt;
&lt;br /&gt;
   def get_certain_review_and_feedback_response_map(author)&lt;br /&gt;
       @feedback_response_maps = '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?', @all_review_response_ids, author.id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update.&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
*'''Solution Implemented''': To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Rspec file &amp;lt;code&amp;gt; /rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; will be updated depending on the following cases.&lt;br /&gt;
&lt;br /&gt;
1. Case#1: Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include it in the Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145043</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145043"/>
		<updated>2022-04-23T05:15:49Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Problem 8: three small classes violates the Expert pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view. Needs clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': See if there is a way to get rid of it or incorporate it into the main method.&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps &amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
'''FeedbackResponseMap''' found in two places in &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; =&amp;gt; will add comments to make this code understandable.&lt;br /&gt;
&lt;br /&gt;
   def get_certain_review_and_feedback_response_map(author)&lt;br /&gt;
       @feedback_response_maps = '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?', @all_review_response_ids, author.id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update.&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
Solution Implemented: To remove single responsibility violation, extra model files are created: &amp;lt;code&amp;gt; review_strategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;student_review_strategy.rb&amp;lt;/code&amp;gt;.and &amp;lt;code&amp;gt;team_review_strategy&amp;lt;/code&amp;gt;. &lt;br /&gt;
The associated method &amp;lt;code&amp;gt;automatic_reivew_mapping_startegy&amp;lt;/code&amp;gt; rspec test pass with this change.&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Rspec file &amp;lt;code&amp;gt; /rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; will be updated depending on the following cases.&lt;br /&gt;
&lt;br /&gt;
1. Case#1: Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include it in the Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145039</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145039"/>
		<updated>2022-04-22T06:58:54Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Problem 7: The method feedback_response_maps violates the Expert pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view. Needs clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': See if there is a way to get rid of it or incorporate it into the main method.&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps &amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
'''FeedbackResponseMap''' found in two places in &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; =&amp;gt; will add comments to make this code understandable.&lt;br /&gt;
&lt;br /&gt;
   def get_certain_review_and_feedback_response_map(author)&lt;br /&gt;
       @feedback_response_maps = '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?', @all_review_response_ids, author.id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY. Rspec test also applied this update.&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Rspec file &amp;lt;code&amp;gt; /rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; will be updated depending on the following cases.&lt;br /&gt;
&lt;br /&gt;
1. Case#1: Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include it in the Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145038</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145038"/>
		<updated>2022-04-22T06:54:51Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Problem 7: The method feedback_response_maps violates the Expert pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view. Needs clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': See if there is a way to get rid of it or incorporate it into the main method.&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps &amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
'''FeedbackResponseMap''' found in two places in &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; =&amp;gt; will add comments to make this code understandable.&lt;br /&gt;
&lt;br /&gt;
   def get_certain_review_and_feedback_response_map(author)&lt;br /&gt;
       @feedback_response_maps = '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?', @all_review_response_ids, author.id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;/code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY.&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Rspec file &amp;lt;code&amp;gt; /rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; will be updated depending on the following cases.&lt;br /&gt;
&lt;br /&gt;
1. Case#1: Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include it in the Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145037</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145037"/>
		<updated>2022-04-22T06:54:28Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Problem 7: The method feedback_response_maps violates the Expert pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view. Needs clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': See if there is a way to get rid of it or incorporate it into the main method.&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps &amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
'''FeedbackResponseMap''' found in two places in &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; =&amp;gt; will add comments to make this code understandable.&lt;br /&gt;
&lt;br /&gt;
   def get_certain_review_and_feedback_response_map(author)&lt;br /&gt;
       @feedback_response_maps = '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?', @all_review_response_ids, author.id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
*'''Solution Implemented''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY.&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Rspec file &amp;lt;code&amp;gt; /rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; will be updated depending on the following cases.&lt;br /&gt;
&lt;br /&gt;
1. Case#1: Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include it in the Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145036</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145036"/>
		<updated>2022-04-22T06:54:02Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Problem 7: The method feedback_response_maps violates the Expert pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view. Needs clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': See if there is a way to get rid of it or incorporate it into the main method.&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps &amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
'''FeedbackResponseMap''' found in two places in &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; =&amp;gt; will add comments to make this code understandable.&lt;br /&gt;
&lt;br /&gt;
   def get_certain_review_and_feedback_response_map(author)&lt;br /&gt;
       @feedback_response_maps = '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?', @all_review_response_ids, author.id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
*''' Implemented Solution ''':The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY.&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Rspec file &amp;lt;code&amp;gt; /rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; will be updated depending on the following cases.&lt;br /&gt;
&lt;br /&gt;
1. Case#1: Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include it in the Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145035</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145035"/>
		<updated>2022-04-22T06:53:12Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Problem 7: The method feedback_response_maps violates the Expert pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view. Needs clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': See if there is a way to get rid of it or incorporate it into the main method.&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps &amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
'''FeedbackResponseMap''' found in two places in &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; =&amp;gt; will add comments to make this code understandable.&lt;br /&gt;
&lt;br /&gt;
   def get_certain_review_and_feedback_response_map(author)&lt;br /&gt;
       @feedback_response_maps = '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?', @all_review_response_ids, author.id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
The method &amp;lt;code&amp;gt;feedback_response_map_record&amp;lt;code&amp;gt; is for the assignment has multiple rounds. However, the same function is already in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt;. This method is better to be removed from this helper method for DRY.&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Rspec file &amp;lt;code&amp;gt; /rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; will be updated depending on the following cases.&lt;br /&gt;
&lt;br /&gt;
1. Case#1: Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include it in the Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145034</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145034"/>
		<updated>2022-04-22T06:51:19Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Problem 7: The method feedback_response_maps violates the Expert pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view. Needs clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': See if there is a way to get rid of it or incorporate it into the main method.&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps &amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
'''FeedbackResponseMap''' found in two places in &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; =&amp;gt; will add comments to make this code understandable.&lt;br /&gt;
&lt;br /&gt;
   def get_certain_review_and_feedback_response_map(author)&lt;br /&gt;
       @feedback_response_maps = '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?', @all_review_response_ids, author.id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
=&amp;gt; This method code is repeated in &amp;lt;code&amp;gt;views/reports/feedback_report&amp;lt;/code&amp;gt;.&lt;br /&gt;
This method can be removed from this helper method.&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Rspec file &amp;lt;code&amp;gt; /rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; will be updated depending on the following cases.&lt;br /&gt;
&lt;br /&gt;
1. Case#1: Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include it in the Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145033</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=145033"/>
		<updated>2022-04-22T05:18:09Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses more on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== History: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ==&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
== Previous Methods/Classes and their Usages ==&lt;br /&gt;
&lt;br /&gt;
This Chart shows each method in the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file before our changes will be implemented. Since this project is a refactor, the overall usage of the file will not change, but some methods may be combined, added, destroyed, or moved to other files. The helper file also contains inner classes that work with the &amp;lt;code&amp;gt;review_mapping_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:MethodUsage.JPG|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as a number of suggestions, or a number of suggestions + number of problems detected. This will also justify a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/21/2022 &amp;lt;/code&amp;gt; These methods were moved to &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, all related tests were also moved, comments were added to the view files to reflect changes.&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view. Needs clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': See if there is a way to get rid of it or incorporate it into the main method.&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps &amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
'''FeedbackResponseMap''' found in two places in &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; =&amp;gt; will add comments to make this code understandable.&lt;br /&gt;
&lt;br /&gt;
   def get_certain_review_and_feedback_response_map(author)&lt;br /&gt;
       @feedback_response_maps = '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?', @all_review_response_ids, author.id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
=== Problem 9: The method get_team_color begins with &amp;lt;code&amp;gt;get_&amp;lt;/code&amp;gt; and another method called &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; exists ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; violates naming conventions, &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; also has a similar name and is only used by &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; can be considered a private method, so testing could be removed if its callee is alredy being tested.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, the contents of &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; will be moved to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
*''' Solution Implemented ''': &amp;lt;code&amp;gt; Done 4/22/2022&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt; get_team_color&amp;lt;/code&amp;gt; method was renamed to &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, tests and view files have been updated with the proper naming. &amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt;'s code as been moved into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. The tests for it have also been deleted since the code was already testing the called method contents before refactoring.&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;, as the the former was called by the latter and was not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''': Refactor Aim for &amp;quot; Always have working Code&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Rspec file &amp;lt;code&amp;gt; /rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; will be updated depending on the following cases.&lt;br /&gt;
&lt;br /&gt;
1. Case#1: Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include it in the Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=144859</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=144859"/>
		<updated>2022-04-12T02:01:45Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses moreso on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Histories: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as number of suggestions, or number of suggestions + number of problems detected. This will also jusity a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view. Needs clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': See if there is a way to get rid of it or incorporate it into the main method.&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps &amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
'''FeedbackResponseMap''' found in two places in &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; =&amp;gt; will add comments to make this code understandable.&lt;br /&gt;
&lt;br /&gt;
   def get_certain_review_and_feedback_response_map(author)&lt;br /&gt;
       @feedback_response_maps = '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?', @all_review_response_ids, author.id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;, as the the former is called by the latter and is not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''':&lt;br /&gt;
&lt;br /&gt;
Rspec file &amp;lt;code&amp;gt; /rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; will be updated depending on the following cases.&lt;br /&gt;
&lt;br /&gt;
1. Case#1 : Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include in Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=144857</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=144857"/>
		<updated>2022-04-12T01:59:14Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Problem 7: The method feedback_response_maps violates the Expert pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses moreso on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Histories: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as number of suggestions, or number of suggestions + number of problems detected. This will also jusity a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view. Needs clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': See if there is a way to get rid of it or incorporate it into the main method.&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps &amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
'''FeedbackResponseMap''' found in two places in &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; =&amp;gt; will add comments to make this code understandable.&lt;br /&gt;
&lt;br /&gt;
   def get_certain_review_and_feedback_response_map(author)&lt;br /&gt;
       @feedback_response_maps = '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?', @all_review_response_ids, author.id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;, as the the former is called by the latter and is not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''':&lt;br /&gt;
&lt;br /&gt;
Rspec file &amp;lt;code&amp;gt; /rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; will be updated depending on the following cases.&lt;br /&gt;
&lt;br /&gt;
1. case#1 : Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include in Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=144856</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=144856"/>
		<updated>2022-04-12T01:58:09Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Problem 7: The method feedback_response_maps violates the Expert pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses moreso on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Histories: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as number of suggestions, or number of suggestions + number of problems detected. This will also jusity a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view. Needs clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': See if there is a way to get rid of it or incorporate it into the main method.&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps &amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
'''FeedbackResponseMap''' found in two places in &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   def get_certain_review_and_feedback_response_map(author)&lt;br /&gt;
       @feedback_response_maps = '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?', @all_review_response_ids, author.id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;, as the the former is called by the latter and is not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''':&lt;br /&gt;
&lt;br /&gt;
Rspec file &amp;lt;code&amp;gt; /rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; will be updated depending on the following cases.&lt;br /&gt;
&lt;br /&gt;
1. case#1 : Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include in Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=144855</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=144855"/>
		<updated>2022-04-12T01:56:47Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Problem 7: The method feedback_response_maps violates the Expert pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses moreso on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Histories: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as number of suggestions, or number of suggestions + number of problems detected. This will also jusity a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view. Needs clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': See if there is a way to get rid of it or incorporate it into the main method.&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps &amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
'''FeedbackResponseMap''' found in two places in &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
def get_certain_review_and_feedback_response_map(author)&lt;br /&gt;
    @feedback_response_maps = '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?', @all_review_response_ids, author.id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;, as the the former is called by the latter and is not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''':&lt;br /&gt;
&lt;br /&gt;
Rspec file &amp;lt;code&amp;gt; /rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; will be updated depending on the following cases.&lt;br /&gt;
&lt;br /&gt;
1. case#1 : Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include in Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=144854</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=144854"/>
		<updated>2022-04-12T01:56:10Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Problem 7: The method feedback_response_maps violates the Expert pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses moreso on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Histories: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;. Other method names beginning with verbs will also be reviewed&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as number of suggestions, or number of suggestions + number of problems detected. This will also jusity a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': These methods will be moved to a new helper class, &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;. This should separate their functionality from &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;, and better illustrate their independent usage by &amp;lt;code&amp;gt;review_report.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;answer_tagging.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view. Needs clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': See if there is a way to get rid of it or incorporate it into the main method.&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps &amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
'''FeedbackResponseMap''' found in two places in &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
def get_certain_review_and_feedback_response_map(author)&lt;br /&gt;
    @feedback_response_maps = '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?', @all_review_response_ids, author.id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def feedback_response_map_record(author)&lt;br /&gt;
    { 1 =&amp;gt; 'one', 2 =&amp;gt; 'two', 3 =&amp;gt; 'three' }.each do |key, round_num|&lt;br /&gt;
      instance_variable_set('@review_responses_round_' + round_num,&lt;br /&gt;
                            Response.where(['map_id IN (?) and round = ?', @review_response_map_ids, key]))&lt;br /&gt;
      # Calculate feedback response map records&lt;br /&gt;
      instance_variable_set('@feedback_response_maps_round_' + round_num,&lt;br /&gt;
                            '''FeedbackResponseMap'''.where(['reviewed_object_id IN (?) and reviewer_id = ?',&lt;br /&gt;
                                                       instance_variable_get('@all_review_response_ids_round_' + round_num), author.id]))&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;, as the the former is called by the latter and is not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class &amp;lt;code&amp;gt;review_mapping_chart_helper.rb&amp;lt;/code&amp;gt;, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''':&lt;br /&gt;
&lt;br /&gt;
Rspec file &amp;lt;code&amp;gt; /rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; will be updated depending on the following cases.&lt;br /&gt;
&lt;br /&gt;
1. case#1 : Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include in Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=144847</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=144847"/>
		<updated>2022-04-12T01:34:40Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Problem 8: three small classes violates the Expert pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses moreso on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Histories: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as number of suggestions, or number of suggestions + number of problems detected. This will also jusity a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Move these methods to a new helper or mixin.&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view. Needs clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': See if there is a way to get rid of it or incorporate it into the main method.&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps &amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;, as the the former is called by the latter and is not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''':&lt;br /&gt;
&lt;br /&gt;
Rspec file &amp;lt;code&amp;gt; /rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; will be updated depending on the following cases.&lt;br /&gt;
&lt;br /&gt;
1. case#1 : Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include in Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=144845</id>
		<title>CSC/ECE 517 Spring 2022 - E2239: Further refactoring and improvement of review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2239:_Further_refactoring_and_improvement_of_review_mapping_helper.rb&amp;diff=144845"/>
		<updated>2022-04-12T01:34:20Z</updated>

		<summary type="html">&lt;p&gt;Hson: /* Problem 8: three small classes violates the Expert pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Within Expertiza, one of the functionalities is for one participant to review the submission of another participant (or team) by answering specific questions about the submission and leaving comments and feedback. This involves the interaction of many tables: users, assignments, teams, reviews, and review_mappings. The &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; is the primary file which handles the code for reviews, but it also relies on &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; for additional methods. While &amp;lt;code&amp;gt;review_mapping_controller&amp;lt;/code&amp;gt; focuses mostly on CRUD operations for reviews, reviewers, and scores, &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; focuses moreso on which data are presented and how (colors, sorting, charts, etc). This project focuses on refactoring &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt; and seeks to make the current code more understandable and transparent, such as by using partials, renaming methods with more standard conventions, adding additional comments, removing/modifying unnecessary methods, and making other methods more robust and useful. This project builds on the work done by E2125, which focused on simplifying some methods in &amp;lt;code&amp;gt;review_mapping_helper&amp;lt;/code&amp;gt;.&lt;br /&gt;
== Problems and planned changes ==&lt;br /&gt;
&lt;br /&gt;
=== Histories: Previous project for refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
 * E2225 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2225:_Refactor_review_mapping_helper.rb]&lt;br /&gt;
 * E2162 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper]&lt;br /&gt;
 * E1913 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2019_-_Project_E1913._Refactor_review_mapping_helper.rb]&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: The method get_data_for_review_report violates the Expert pattern ===&lt;br /&gt;
&amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; passes back a data structure with multiple &amp;lt;code&amp;gt;response&amp;lt;/code&amp;gt; objects to the &amp;lt;code&amp;gt;_review_report.html.erb&amp;lt;/code&amp;gt; view. This violates the Expert pattern, because the given view does not know how to break apart the structure passed to it.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt; will be refactored to use partials&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Several method names begin with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This naming convention is not Ruby-like, and needs to be changed.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; will be refactored to use more appropriate names. e.g. &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt; will be refactored into &amp;lt;code&amp;gt;team_color?&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 3: The method get_awarded_review_score needs to be updated ===&lt;br /&gt;
&amp;lt;code&amp;gt; get_awarded_review_score &amp;lt;/code&amp;gt; computes an overall score based upon scores awarded in individual rounds. This is one of many places in Expertiza where scores are being calculated.  Score-calculation code for multiple rounds is being standardized now, in &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Change the method to utilize the standard code from &amp;lt;code&amp;gt; response_map.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 4: The method sort_reviewer_by_review_volume_desc needs to be generalized ===&lt;br /&gt;
&amp;lt;code&amp;gt; sort_reviewer_by_review_volume_desc &amp;lt;/code&amp;gt; only sorts by review volume, which is very specific. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Modify the method to be able to sort by multiple different metrics such as number of suggestions, or number of suggestions + number of problems detected. This will also jusity a method name change (and possible parameter change/additions), which will have to be updated elsewhere in the app.&lt;br /&gt;
&lt;br /&gt;
=== Problem 5: Several methods are used for generating charts and should be moved to another file  ===&lt;br /&gt;
Including &amp;lt;code&amp;gt; initialize_chart_elements &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_volume_metric_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; display_tagging_interval_chart &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; calculate_key_chart_information &amp;lt;/code&amp;gt;.They are cohesive enough to just be moved to another file.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': Move these methods to a new helper or mixin.&lt;br /&gt;
&lt;br /&gt;
=== Problem 6: Investigate the use of &amp;lt;code&amp;gt; list_review_submissions &amp;lt;/code&amp;gt; ===&lt;br /&gt;
It is not all clear that this method is needed, though it is used in one view. Needs clarification if this function is being used or not.&lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': See if there is a way to get rid of it or incorporate it into the main method.&lt;br /&gt;
&lt;br /&gt;
=== Problem 7: The method feedback_response_maps violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; feedback_response_maps &amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''':&lt;br /&gt;
Look up the expertiza wiki for the documentation, and make it clearer what they are doing&lt;br /&gt;
&lt;br /&gt;
=== Problem 8: three small classes violates the Expert pattern ===&lt;br /&gt;
It is not clear why &amp;lt;code&amp;gt; ReviewStrategy &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; are here. &lt;br /&gt;
&lt;br /&gt;
*''' Proposed Solution ''': &lt;br /&gt;
Class &amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt; is called in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt; =&amp;gt; Better to move this Class to &lt;br /&gt;
&amp;lt;code&amp;gt;reveiw_mapping_model.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Class ReviewStrategy&amp;lt;/code&amp;gt; example in &amp;lt;code&amp;gt;reveiw_mapping_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
    def automatic_review_mapping_strategy()&lt;br /&gt;
    ...&lt;br /&gt;
       if !student_review_num.zero? &amp;amp;&amp;amp; submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::StudentReviewStrategy'''.new(participants, teams, student_review_num)&lt;br /&gt;
       elsif student_review_num.zero? &amp;amp;&amp;amp; !submission_review_num.zero?&lt;br /&gt;
         review_strategy = '''ReviewMappingHelper::TeamReviewStrategy'''.new(participants, teams, submission_review_num)&lt;br /&gt;
       end&lt;br /&gt;
    ...&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
A picture of the current and proposed UML diagram is included below&lt;br /&gt;
&lt;br /&gt;
[[File:517 E2239 UML Diagram.vpd.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
The updated schema makes these changes:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;obtain_team_color&amp;lt;/code&amp;gt; has been refactored into &amp;lt;code&amp;gt;get_team_color&amp;lt;/code&amp;gt;, as the the former is called by the latter and is not unique enough to exist as a separate method&lt;br /&gt;
*&amp;lt;code&amp;gt;initialze_chart_elements&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;calculate_key_chart_information&amp;lt;/code&amp;gt; have been refactored into a separate helper class, as their functionality is self-contained enough to exist on their own&lt;br /&gt;
*&amp;lt;code&amp;gt;ReviewStrategy&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;StudentReviewStrategy&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;TeamReviewStrategy&amp;lt;/code&amp;gt; have ben refactored as inner classes of &amp;lt;code&amp;gt;review_mapping_model&amp;lt;/code&amp;gt; as this is the only class that interacts with these inner-classes.&lt;br /&gt;
*All method names beginning with &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; have been refactored to use &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; in order to conform to ruby standards&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
*''' RSpec Unit Tests''':&lt;br /&gt;
&lt;br /&gt;
Rspec file &amp;lt;code&amp;gt; /rspec/review_mapping_helper_spec.rb&amp;lt;/code&amp;gt; will be updated depending on the following cases.&lt;br /&gt;
&lt;br /&gt;
1. case#1 : Methods not included in Rspec =&amp;gt; review the method to refactor &amp;amp; include in Rspec file. &lt;br /&gt;
&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_data_for_review_report&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;initialize_chart_elements&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_volume_metric_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;display_tagging_interval_chart&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;list_hyperlink_submission&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_each_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;get_certain_review_and_feedback_response_map&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class ReviewStrategy &amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class StudentReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
 - &amp;lt;code&amp;gt;Class TeamReviewStrategy&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Case #2: Refactoring may cause to break existing Rspec. =&amp;gt; refactor Rspec as well&lt;br /&gt;
&lt;br /&gt;
3. Case #3: Adding a new method =&amp;gt; Add new Rspec scenario&lt;br /&gt;
&lt;br /&gt;
4. Case #4: Removing methods =&amp;gt; Remove from Rspec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*''' Functionality Tests''':&lt;br /&gt;
&lt;br /&gt;
Functionality test will be added when our refactor causes to change in the logic. Our focus on this project is refactoring &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; to be more readable and understandable.&lt;br /&gt;
&lt;br /&gt;
==GitHub links and Pull Request==&lt;br /&gt;
&lt;br /&gt;
GitHub link [https://github.com/andypip88/expertiza here]&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
Evan Brown&lt;br /&gt;
&lt;br /&gt;
Chaitanya Patel&lt;br /&gt;
&lt;br /&gt;
Rachel Hyo Son&lt;br /&gt;
&lt;br /&gt;
Andrew Pippin&lt;/div&gt;</summary>
		<author><name>Hson</name></author>
	</entry>
</feed>