<?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=Spatel68</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=Spatel68"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Spatel68"/>
	<updated>2026-05-11T00:27:28Z</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_2025_-_E2524_Reimplement_student_review_controller&amp;diff=164838</id>
		<title>CSC/ECE 517 Spring 2025 - E2524 Reimplement student review controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2524_Reimplement_student_review_controller&amp;diff=164838"/>
		<updated>2025-04-22T23:42:03Z</updated>

		<summary type="html">&lt;p&gt;Spatel68: /* Controller Diagram */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
The goal of this project is to reimplement the `StudentReviewController` and its associated views. The reimplementation will introduce a new service layer, streamline logic, and remove obsolete code (e.g., references to metareviews). The new design prioritizes clarity, modularity, and maintainability, following Rails best practices and RESTful conventions.&lt;br /&gt;
&lt;br /&gt;
=== Purpose and Scope ===&lt;br /&gt;
This reimplementation addresses longstanding design issues in the original controller, including overly complex methods, redundant logic, and tight coupling between controller and view layers.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
* Redesign the controller to delegate all business logic to a new service class&lt;br /&gt;
* Eliminate obsolete functionality (e.g., metareviews)&lt;br /&gt;
* Improve testability by enabling unit tests on the service layer&lt;br /&gt;
* Simplify the view templates by preparing data in the controller beforehand&lt;br /&gt;
* Adhere to Rails RESTful conventions and best practices.&lt;br /&gt;
* Improve maintainability, localization support, and scalability.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
Reimplement the `StudentReviewController` and ensure all associated components function correctly. The components involved include:&lt;br /&gt;
&lt;br /&gt;
=== Models Used ===&lt;br /&gt;
* `AssignmentParticipant`&lt;br /&gt;
* `Assignment`&lt;br /&gt;
* `SignedUpTeam`&lt;br /&gt;
* `ReviewResponseMap`&lt;br /&gt;
* `SampleReview`&lt;br /&gt;
* `MetareviewResponseMap` (obsolete – all references to be removed)&lt;br /&gt;
&lt;br /&gt;
==Existing Issues==  &lt;br /&gt;
* '''Controller Complexity:'''  &lt;br /&gt;
  - The `list` method is too long and handles multiple responsibilities: data loading, logic, rendering setup, and redirects.  &lt;br /&gt;
  - Business logic is intertwined with HTTP concerns (e.g., redirection, instance variables).  &lt;br /&gt;
&lt;br /&gt;
* '''Redundant Logic:'''  &lt;br /&gt;
  - The `action_allowed?` method checks for student privileges multiple times.&lt;br /&gt;
&lt;br /&gt;
* '''Hard-Coded Values:'''  &lt;br /&gt;
  - Literal strings like `&amp;quot;list&amp;quot;` and `&amp;quot;submitter&amp;quot;` are used instead of constants.&lt;br /&gt;
&lt;br /&gt;
* '''Obsolete Code:'''  &lt;br /&gt;
  - The `MetareviewResponseMap` model is no longer relevant but still referenced.&lt;br /&gt;
&lt;br /&gt;
* '''Lack of Separation of Concerns:'''  &lt;br /&gt;
  - Controller handles business logic that should reside in service/model layers.&lt;br /&gt;
&lt;br /&gt;
== Design Principles Analysis ==&lt;br /&gt;
&lt;br /&gt;
This section outlines how our application aligns with core software design principles, based on a detailed analysis of the &amp;lt;code&amp;gt;StudentReviewService&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ApplicationController&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;AuthenticationController&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Single Responsibility Principle (SRP) ===&lt;br /&gt;
* '''Focused Responsibilities:'''  &lt;br /&gt;
  - &amp;lt;code&amp;gt;StudentReviewService&amp;lt;/code&amp;gt; handles only review-related operations.  &lt;br /&gt;
  - &amp;lt;code&amp;gt;ApplicationController&amp;lt;/code&amp;gt; manages cross-cutting concerns such as authorization and locale setting.  &lt;br /&gt;
  - Each class and method has one clear and dedicated purpose.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  def calculate_review_progress&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    @num_reviews_completed = @review_mappings.count do |map|&lt;br /&gt;
      !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
    end&lt;br /&gt;
    @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== DRY (Don’t Repeat Yourself) ===&lt;br /&gt;
* '''Centralized Logic:'''  &lt;br /&gt;
  - Shared methods like &amp;lt;code&amp;gt;load_participant_and_assignment&amp;lt;/code&amp;gt; promote reuse.  &lt;br /&gt;
  - Authorization and locale-setting logic are abstracted into concerns.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  def load_participant_and_assignment(participant_id)&lt;br /&gt;
    @participant = AssignmentParticipant.find(participant_id)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@assignment.id, @participant.user_id)&lt;br /&gt;
    @review_phase = @assignment.current_stage(@topic_id)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Maintainability and Testability ===&lt;br /&gt;
* '''Modular Design:'''  &lt;br /&gt;
  - Business logic is placed in services to simplify future updates.  &lt;br /&gt;
  - Private methods are used to improve unit test isolation.  &lt;br /&gt;
  - Clear method names improve code readability.  &lt;br /&gt;
&lt;br /&gt;
  def load_review_mappings&lt;br /&gt;
    reviewer = @participant.get_reviewer&lt;br /&gt;
    @review_mappings = reviewer ? ReviewResponseMap.where(...) : []&lt;br /&gt;
    @review_mappings = @review_mappings.sort_by { |m| m.id % 5 } if @assignment.is_calibrated&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== RESTful Best Practices ===&lt;br /&gt;
* '''Rails-Conventional Controllers:'''  &lt;br /&gt;
  - RESTful routes and actions are followed.  &lt;br /&gt;
  - &amp;lt;code&amp;gt;AuthenticationController&amp;lt;/code&amp;gt; includes a clear and secure login endpoint.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  def login&lt;br /&gt;
    user = User.find_by(name: params[:user_name]) || User.find_by(email: params[:user_name])&lt;br /&gt;
    if user&amp;amp;.authenticate(params[:password])&lt;br /&gt;
      token = JsonWebToken.encode({ id: user.id, ... }, 24.hours.from_now)&lt;br /&gt;
      render json: { token: }, status: :ok&lt;br /&gt;
    else&lt;br /&gt;
      render json: { error: 'Invalid username / password' }, status: :unauthorized&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Localization and Internationalization ===&lt;br /&gt;
* '''Locale Handling:'''  &lt;br /&gt;
  - Locale is determined from parameters or browser headers.  &lt;br /&gt;
  - Rails i18n support is properly configured and applied.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  def set_locale&lt;br /&gt;
    I18n.locale = extract_locale || I18n.default_locale&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Summary Table ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Principle&lt;br /&gt;
! Status&lt;br /&gt;
! Notes&lt;br /&gt;
|-&lt;br /&gt;
| '''Single Responsibility'''&lt;br /&gt;
| Implemented&lt;br /&gt;
| Each class has one focused responsibility&lt;br /&gt;
|-&lt;br /&gt;
| '''DRY'''&lt;br /&gt;
| Implemented&lt;br /&gt;
| Shared logic centralized in service methods&lt;br /&gt;
|-&lt;br /&gt;
| '''Maintainability &amp;amp; Testability'''&lt;br /&gt;
| Implemented&lt;br /&gt;
| Modular code with helper methods and clear naming&lt;br /&gt;
|-&lt;br /&gt;
| '''RESTful Practices'''&lt;br /&gt;
| Implemented&lt;br /&gt;
| Follows Rails conventions&lt;br /&gt;
|-&lt;br /&gt;
| '''Localization/i18n'''&lt;br /&gt;
| Implemented&lt;br /&gt;
| Locale handled through params and headers&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Additional Strengths ===  &lt;br /&gt;
&lt;br /&gt;
* '''Service Object Pattern:'''  &lt;br /&gt;
  - Business logic is encapsulated in dedicated service classes, improving modularity and reuse.  &lt;br /&gt;
&lt;br /&gt;
* '''JWT Authentication:'''  &lt;br /&gt;
  - Secure authentication is implemented using JSON Web Tokens with proper token generation and expiration handling.  &lt;br /&gt;
&lt;br /&gt;
* '''Readable Method Naming:'''  &lt;br /&gt;
  - Method names clearly reflect their responsibilities, enhancing code readability and maintainability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Controller Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:controllerdiagram.png]]&lt;br /&gt;
&lt;br /&gt;
== Design / Proposed Solution ==&lt;br /&gt;
&lt;br /&gt;
=== Separation of Concerns ===&lt;br /&gt;
This reimplementation is based on a clear separation of responsibilities:&lt;br /&gt;
* The controller handles only routing, access validation, and view setup.&lt;br /&gt;
* The service object encapsulates all business logic and data handling.&lt;br /&gt;
* Obsolete functionality such as `MetareviewResponseMap` is eliminated to simplify the design.&lt;br /&gt;
&lt;br /&gt;
=== Architectural Overview ===&lt;br /&gt;
The new design will be based on the following structure:&lt;br /&gt;
* A `StudentReviewController` that handles only HTTP responsibilities.&lt;br /&gt;
* A new `StudentReviewService` that encapsulates all business logic.&lt;br /&gt;
* Continued use of models like `AssignmentParticipant`, `Assignment`, and `ReviewResponseMap` (excluding `MetareviewResponseMap`).&lt;br /&gt;
* Views adjusted to work with service-driven data.&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Controller Responsibilities ===&lt;br /&gt;
* Validate access using a simplified `action_allowed?` method&lt;br /&gt;
* Set locale using controller_locale&lt;br /&gt;
* Call `StudentReviewService.new(id, current_user).perform` to gather data&lt;br /&gt;
* Assign service output to instance variables for the view&lt;br /&gt;
* Redirect if bidding is enabled&lt;br /&gt;
&lt;br /&gt;
=== Breakdown of Service Object Responsibilities ===&lt;br /&gt;
* Retrieve `AssignmentParticipant` and associated `Assignment`&lt;br /&gt;
* Calculate `topic_id` using `SignedUpTeam.topic_id`&lt;br /&gt;
* Determine review phase using `assignment.current_stage`&lt;br /&gt;
* Get reviewer via `participant.get_reviewer`&lt;br /&gt;
* Load and (if applicable) sort review mappings (`ReviewResponseMap`)&lt;br /&gt;
* Count completed and in-progress reviews&lt;br /&gt;
* Load sample reviews (`SampleReview`) and extract `response_ids`&lt;br /&gt;
* Check if bidding is enabled&lt;br /&gt;
&lt;br /&gt;
=== Removal of Obsolete Code ===&lt;br /&gt;
* All logic involving `MetareviewResponseMap` will be deleted&lt;br /&gt;
* Related counters for metareview progress will be removed from both controller and views&lt;br /&gt;
&lt;br /&gt;
=== action_allowed? Method ===&lt;br /&gt;
* Eliminate redundant privilege check: `|| current_user_has_student_privileges?`&lt;br /&gt;
* Use constants instead of literal strings (`LIST_ACTION = 'list'`)&lt;br /&gt;
* Restructure logic as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  LIST_ACTION     = 'list'.freeze&lt;br /&gt;
  SUBMITTER_ROLE  = 'submitter'.freeze&lt;br /&gt;
&lt;br /&gt;
  before_action :authorize_user, only: [LIST_ACTION.to_sym]&lt;br /&gt;
  before_action :load_service, only: [:list]&lt;br /&gt;
&lt;br /&gt;
  private&lt;br /&gt;
&lt;br /&gt;
  def authorize_user&lt;br /&gt;
    unless action_allowed?&lt;br /&gt;
      render json: { error: 'Unauthorized' }, status: :unauthorized&lt;br /&gt;
      return&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Quick-exit unless they're a student.&lt;br /&gt;
  # Then, only allow the LIST_ACTION for users who also have the SUBMITTER_ROLE on this resource.&lt;br /&gt;
  def action_allowed?&lt;br /&gt;
    # guard clause: must be a student at all&lt;br /&gt;
    return false unless current_user_has_student_privileges?  # early return&lt;br /&gt;
&lt;br /&gt;
    # only permit “list” for submitters&lt;br /&gt;
    action_name == LIST_ACTION &amp;amp;&amp;amp;&lt;br /&gt;
      are_needed_authorizations_present?(params[:id], SUBMITTER_ROLE)&lt;br /&gt;
  end&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== controller_locale Method ===&lt;br /&gt;
&lt;br /&gt;
* Ensure the `controller_locale` method sets the locale appropriately for student users, supporting internationalization and accessibility. Adding the below code to ApplicationController Class.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # 1) Set locale for every request&lt;br /&gt;
  before_action :set_locale&lt;br /&gt;
  # 2) Perform authorization&lt;br /&gt;
  before_action :authorize&lt;br /&gt;
&lt;br /&gt;
  private&lt;br /&gt;
&lt;br /&gt;
  # Sets I18n.locale based on params, Accept-Language header, or default&lt;br /&gt;
  def set_locale&lt;br /&gt;
    I18n.locale = extract_locale || I18n.default_locale&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Returns a valid locale symbol or nil&lt;br /&gt;
  def extract_locale&lt;br /&gt;
    # 1) Param override&lt;br /&gt;
    if params[:locale].present?&lt;br /&gt;
      sym = params[:locale].to_sym&lt;br /&gt;
      return sym if I18n.available_locales.include?(sym)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    # 2) Accept-Language header fallback&lt;br /&gt;
    header = request.env['HTTP_ACCEPT_LANGUAGE'].to_s&lt;br /&gt;
    header&lt;br /&gt;
      .split(',')&lt;br /&gt;
      .map { |l| l[0..1].downcase.to_sym }&lt;br /&gt;
      .find { |loc| I18n.available_locales.include?(loc) }&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== list Method ===&lt;br /&gt;
The `list` method will be removed and replaced with a simplified call to the service:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def list&lt;br /&gt;
  return unless valid_participant?&lt;br /&gt;
  @data = StudentReviewService.new(params[:id], current_user.id).perform&lt;br /&gt;
  redirect_to bidding_path if @data[:bidding_enabled]&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== View Refactoring Plan ==&lt;br /&gt;
&lt;br /&gt;
* `list.html.erb`: Simplify to only display data passed in from `@data`&lt;br /&gt;
* `_responses.html.erb`: Remove inline logic (e.g., topic ID lookups) and rely on passed-in values&lt;br /&gt;
* `_set_dynamic_*`: May be removed if dynamic review logic is relocated or rewritten&lt;br /&gt;
* View logic for metareviews will be removed&lt;br /&gt;
* Ensure views follow Rails i18n localization conventions by replacing any hardcoded strings with translation keys where appropriate.&lt;br /&gt;
&lt;br /&gt;
== Test Coverage Summary ==&lt;br /&gt;
To ensure the integrity of the reimplementation, both the service objects and controller actions should have dedicated tests. It is recommended to generate test skeletons as soon as the methods are in place.&lt;br /&gt;
&lt;br /&gt;
[[File:Screenshot_2025-04-22_at_12.29.17_PM.png|thumb|none|600px|RSpec Tests Report]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- This blank line creates the space --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Name&lt;br /&gt;
! Test Coverage&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/controllers/api/v1/student_review_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
| 86.67%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/controllers/application_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
| 100.0%&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/services/student_review_service.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
| 85.71%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- This blank line creates the space --&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
[[File:Ckecks.png|thumb|none|600px|All checks have passed]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- This blank line creates the space --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Summary of Tests in StudentReviewController Spec ==&lt;br /&gt;
&lt;br /&gt;
The test file provides comprehensive test coverage for the &amp;lt;code&amp;gt;Api::V1::StudentReviewController&amp;lt;/code&amp;gt;. Here's a summary of what was tested:&lt;br /&gt;
&lt;br /&gt;
=== Core Controller Functionality ===&lt;br /&gt;
* '''Controller Action Existence:'''  &lt;br /&gt;
  - Verifies that the &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt; action is defined.&lt;br /&gt;
* '''Response Structure:'''  &lt;br /&gt;
  - Confirms the controller returns the expected JSON structure with all required fields.&lt;br /&gt;
* '''Authorization Logic:'''  &lt;br /&gt;
  - Ensures that proper authorization checks are in place and function correctly.&lt;br /&gt;
&lt;br /&gt;
=== Authorization Tests ===&lt;br /&gt;
* '''Proper Authorization:'''  &lt;br /&gt;
  - Tests scenarios where a user is authorized to access resources.&lt;br /&gt;
* '''Unauthorized Access:'''  &lt;br /&gt;
  - Ensures unauthorized users receive a 401 response.&lt;br /&gt;
* '''Student Privileges:'''  &lt;br /&gt;
  - Tests the &amp;lt;code&amp;gt;action_allowed?&amp;lt;/code&amp;gt; method with and without student privileges.&lt;br /&gt;
* '''Participant Authorization:'''  &lt;br /&gt;
  - Verifies the &amp;lt;code&amp;gt;authorized_participant?&amp;lt;/code&amp;gt; method behavior.&lt;br /&gt;
&lt;br /&gt;
=== Bidding Functionality ===&lt;br /&gt;
* '''Bidding Enabled:'''  &lt;br /&gt;
  - Verifies redirection occurs when bidding is enabled.&lt;br /&gt;
* '''Bidding Disabled:'''  &lt;br /&gt;
  - Ensures no redirection occurs when bidding is disabled.&lt;br /&gt;
* '''&amp;lt;code&amp;gt;check_bidding_redirect&amp;lt;/code&amp;gt; Method:'''  &lt;br /&gt;
  - Tests the method independently to verify redirection logic.&lt;br /&gt;
&lt;br /&gt;
=== Service Integration ===&lt;br /&gt;
* '''Service Loading:'''  &lt;br /&gt;
  - Tests for proper initialization of the &amp;lt;code&amp;gt;load_service&amp;lt;/code&amp;gt; method.&lt;br /&gt;
* '''Service Data Usage:'''  &lt;br /&gt;
  - Confirms service output is correctly used in controller responses.&lt;br /&gt;
&lt;br /&gt;
=== Reviewer-related Tests ===&lt;br /&gt;
* '''With Reviewer:'''  &lt;br /&gt;
  - Tests the flow when a participant has an associated reviewer.&lt;br /&gt;
* '''Without Reviewer:'''  &lt;br /&gt;
  - Tests behavior when no reviewer is present.&lt;br /&gt;
&lt;br /&gt;
=== Special Assignment Types ===&lt;br /&gt;
* '''Calibrated Assignments:'''  &lt;br /&gt;
  - Tests functionality related to calibration logic.&lt;br /&gt;
* '''Topic ID Handling:'''  &lt;br /&gt;
  - Verifies accurate calculation of &amp;lt;code&amp;gt;topic_id&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Internationalization ===&lt;br /&gt;
* '''Locale Setting:'''  &lt;br /&gt;
  - Tests &amp;lt;code&amp;gt;controller_locale&amp;lt;/code&amp;gt; method functionality.&lt;br /&gt;
* '''User Locale Preference:'''  &lt;br /&gt;
  - Tests locale assignment when user has preferences.&lt;br /&gt;
* '''Default Locale Fallback:'''  &lt;br /&gt;
  - Ensures fallback to default locale works properly.&lt;br /&gt;
&lt;br /&gt;
=== Edge Cases ===&lt;br /&gt;
* '''Missing Reviewer:'''  &lt;br /&gt;
  - Verifies behavior when the reviewer does not exist.&lt;br /&gt;
* '''Review Mappings Sorting:'''  &lt;br /&gt;
  - Tests sorting logic for review mappings under various conditions.&lt;br /&gt;
&lt;br /&gt;
This comprehensive test suite ensures that all aspects of the &amp;lt;code&amp;gt;StudentReviewController&amp;lt;/code&amp;gt; are thoroughly tested—from basic functionality to edge cases and error handling—achieving a test coverage rate of '''86.67%'''.&lt;br /&gt;
&lt;br /&gt;
== Summary of Tests in ApplicationController Spec ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;application_controller_spec.rb&amp;lt;/code&amp;gt; file provides thorough test coverage for the internationalization (i18n) functionality in the &amp;lt;code&amp;gt;ApplicationController&amp;lt;/code&amp;gt;. Here's a summary of what was tested:&lt;br /&gt;
&lt;br /&gt;
=== Locale Setting Logic ===&lt;br /&gt;
* '''Set Locale Method:'''  &lt;br /&gt;
  - Tests the &amp;lt;code&amp;gt;set_locale&amp;lt;/code&amp;gt; method that configures the application's current locale.&lt;br /&gt;
* '''Invalid Locale Handling:'''  &lt;br /&gt;
  - Verifies that invalid locales passed in parameters are properly ignored.&lt;br /&gt;
* '''Default Locale Fallback:'''  &lt;br /&gt;
  - Ensures fallback to the default locale when no valid locale is found.&lt;br /&gt;
&lt;br /&gt;
=== Locale Extraction ===&lt;br /&gt;
* '''Extract Locale Method:'''  &lt;br /&gt;
  - Tests the &amp;lt;code&amp;gt;extract_locale&amp;lt;/code&amp;gt; method for determining the locale to use.&lt;br /&gt;
* '''Parameter-based Extraction:'''  &lt;br /&gt;
  - Verifies that the locale is correctly extracted from URL parameters.&lt;br /&gt;
* '''HTTP Header Extraction:'''  &lt;br /&gt;
  - Tests extraction of locale from the &amp;lt;code&amp;gt;Accept-Language&amp;lt;/code&amp;gt; HTTP header.&lt;br /&gt;
* '''Validation:'''  &lt;br /&gt;
  - Confirms extracted locales are checked against &amp;lt;code&amp;gt;I18n.available_locales&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== HTTP Accept-Language Header Parsing ===&lt;br /&gt;
* '''Country-Specific Codes:'''  &lt;br /&gt;
  - Tests proper handling of country-specific language codes such as &amp;lt;code&amp;gt;en-US&amp;lt;/code&amp;gt;.&lt;br /&gt;
* '''Quality Factors:'''  &lt;br /&gt;
  - Tests parsing of language quality preferences (e.g., &amp;lt;code&amp;gt;fr;q=0.9&amp;lt;/code&amp;gt;).&lt;br /&gt;
* '''Multiple Languages:'''  &lt;br /&gt;
  - Verifies behavior when the header includes multiple language options.&lt;br /&gt;
* '''Invalid Languages:'''  &lt;br /&gt;
  - Ensures that unsupported languages are safely ignored.&lt;br /&gt;
* '''Empty/Nil Headers:'''  &lt;br /&gt;
  - Tests how the system behaves when the language header is empty or missing.&lt;br /&gt;
&lt;br /&gt;
=== Edge Cases ===&lt;br /&gt;
* '''Multi-part Headers:'''  &lt;br /&gt;
  - Tests parsing of complex &amp;lt;code&amp;gt;Accept-Language&amp;lt;/code&amp;gt; headers.&lt;br /&gt;
* '''Priority Handling:'''  &lt;br /&gt;
  - Ensures that language preferences are honored based on quality factors.&lt;br /&gt;
* '''Fallback Behavior:'''  &lt;br /&gt;
  - Verifies fallback logic when preferred languages are not available.&lt;br /&gt;
&lt;br /&gt;
These tests use RSpec’s controller testing features with an anonymous controller inheriting from &amp;lt;code&amp;gt;ApplicationController&amp;lt;/code&amp;gt; to isolate i18n behavior. Setup and teardown logic ensures that the original i18n configuration is restored after each test.&lt;br /&gt;
&lt;br /&gt;
Overall, this test suite ensures robust support for multilingual scenarios, helping maintain internationalization integrity throughout the application.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Summary of Tests in StudentReviewService Spec ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;student_review_service_spec.rb&amp;lt;/code&amp;gt; file provides comprehensive test coverage for the &amp;lt;code&amp;gt;StudentReviewService&amp;lt;/code&amp;gt; class. Here's a breakdown of what was tested:&lt;br /&gt;
&lt;br /&gt;
=== Initialization and Setup ===&lt;br /&gt;
* '''Constructor Testing:'''  &lt;br /&gt;
  - Verifies proper initialization, including loading of the participant and assignment.&lt;br /&gt;
* '''Topic ID and Review Phase:'''  &lt;br /&gt;
  - Ensures that &amp;lt;code&amp;gt;topic_id&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;review_phase&amp;lt;/code&amp;gt; are set correctly.&lt;br /&gt;
* '''Error Handling:'''  &lt;br /&gt;
  - Tests that appropriate exceptions are raised when the participant does not exist.&lt;br /&gt;
&lt;br /&gt;
=== Core Functionality ===&lt;br /&gt;
* '''Bidding Enabled Check:'''  &lt;br /&gt;
  - Tests the &amp;lt;code&amp;gt;bidding_enabled?&amp;lt;/code&amp;gt; method under both enabled and disabled conditions.&lt;br /&gt;
* '''Review Mappings:'''  &lt;br /&gt;
  - Verifies correct loading and sorting of review mappings.&lt;br /&gt;
* '''Response IDs:'''  &lt;br /&gt;
  - Confirms that response IDs are correctly extracted from the database.&lt;br /&gt;
&lt;br /&gt;
=== Special Assignment Cases ===&lt;br /&gt;
* '''Calibrated Assignments:'''  &lt;br /&gt;
  - Tests sorting logic specific to calibrated assignments:&lt;br /&gt;
    - Uses &amp;lt;code&amp;gt;id % 5&amp;lt;/code&amp;gt; criteria.&lt;br /&gt;
    - Covers specific IDs (1, 2, 5, 6, 7) to ensure sorting correctness.&lt;br /&gt;
&lt;br /&gt;
=== Edge Cases ===&lt;br /&gt;
* '''No Reviewer:'''  &lt;br /&gt;
  - Ensures &amp;lt;code&amp;gt;review_mappings&amp;lt;/code&amp;gt; is set to an empty array.&lt;br /&gt;
  - Verifies that progress counters for reviews are zero.&lt;br /&gt;
&lt;br /&gt;
=== Response Handling ===&lt;br /&gt;
* '''Response ID Loading:'''  &lt;br /&gt;
  - Confirms response IDs are correctly retrieved from &amp;lt;code&amp;gt;SampleReview&amp;lt;/code&amp;gt;.&lt;br /&gt;
* '''Empty Response Lists:'''  &lt;br /&gt;
  - Tests proper handling when no responses are available.&lt;br /&gt;
&lt;br /&gt;
=== Testing Approach ===&lt;br /&gt;
This test suite uses RSpec's mocking and stubbing features to isolate logic from external dependencies:&lt;br /&gt;
* Uses doubles for models like &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Assignment&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;Participant&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Stubs private methods when needed to focus tests on expected behavior.&lt;br /&gt;
* Mocks &amp;lt;code&amp;gt;SampleReview&amp;lt;/code&amp;gt; for controlled data input.&lt;br /&gt;
* Uses RSpec's expectation syntax to assert correctness.&lt;br /&gt;
&lt;br /&gt;
Overall, this test suite thoroughly validates the &amp;lt;code&amp;gt;StudentReviewService&amp;lt;/code&amp;gt; class under both standard and edge-case scenarios, ensuring correct functionality for calibrated assignments, bidding, review progress, and reviewer absence.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor'''&lt;br /&gt;
* Janice Uwujaren&lt;br /&gt;
&lt;br /&gt;
'''Students'''&lt;br /&gt;
* Kenil Patel (kpatel47)&lt;br /&gt;
* Smit Patel (spatel68)&lt;br /&gt;
* Katerina Vilkomir (evilkom)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
&lt;br /&gt;
* '''Controller (Original Expertiza Repo):'''  &lt;br /&gt;
  https://github.com/expertiza/expertiza/blob/main/app/controllers/student_review_controller.rb&lt;br /&gt;
&lt;br /&gt;
* '''Views (one controller action view and three partials):'''  &lt;br /&gt;
  https://github.com/expertiza/expertiza/tree/main/app/views/student_review&lt;br /&gt;
&lt;br /&gt;
* '''StudentReviewService Implementation Repo (Kii4ka):'''  &lt;br /&gt;
  https://github.com/Kii4ka/reimplementation-back-end&lt;br /&gt;
&lt;br /&gt;
* '''Pull Request to Expertiza Reimplementation Repo (#197):'''  &lt;br /&gt;
  https://github.com/expertiza/reimplementation-back-end/pull/197&lt;/div&gt;</summary>
		<author><name>Spatel68</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Controllerdiagram.png&amp;diff=164836</id>
		<title>File:Controllerdiagram.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Controllerdiagram.png&amp;diff=164836"/>
		<updated>2025-04-22T23:39:20Z</updated>

		<summary type="html">&lt;p&gt;Spatel68: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Spatel68</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2501:_Refactor_review_mapping_helper.rb&amp;diff=162556</id>
		<title>CSC/ECE 517 Spring 2025 - E2501: Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2501:_Refactor_review_mapping_helper.rb&amp;diff=162556"/>
		<updated>2025-03-25T00:54:25Z</updated>

		<summary type="html">&lt;p&gt;Spatel68: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team ==&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Janice Uwujaren &lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Katerina Vilkomir (evilkom)&lt;br /&gt;
* Smit Patel (spatel68)&lt;br /&gt;
* Kenil Patel (kpatel47)&lt;br /&gt;
&lt;br /&gt;
=== Relevant Links ===&lt;br /&gt;
* '''Link to Expertiza Repository:''' https://github.com/expertiza/expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Link to Forked Repository: ''' https://github.com/Kii4ka/expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* ''' Link to Pull Request: ''' &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Expertiza Background==&lt;br /&gt;
Expertiza is a Ruby on Rails framework-based open-source web application. It is kept up by NC State University employees and students. With the help of this program, instructors can fully manage the assignments and responsibilities assigned in their classes. Expertiza provides many strong features, such as subject addition, group creation, and peer review administration. It is a flexible platform that can manage many kinds of tasks. Users can consult the Expertiza wiki to get more in-depth details about the many capabilities that Expertiza offers.&lt;br /&gt;
&lt;br /&gt;
== About Helper ==&lt;br /&gt;
The review_mapping_helper is integral to the peer review process, handling tasks such as calculating review scores, managing submission statuses, generating reports, and displaying review metrics. However, the module is complex because it depends on numerous instance variables, like @assignment and @review_scores, and mixes business logic with view logic.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The tight coupling and unclear separation of concerns make the code difficult to understand, test, and manage. To improve the overall quality of the codebase, the goal of this project is to refactor to ensure that the required info is passed as parameters and to separate business logic from view-related logic.&lt;br /&gt;
&lt;br /&gt;
== What Needs To Be Done == &lt;br /&gt;
*''' Separation of Business Logic and Helpers.'''&lt;br /&gt;
** The get_data_for_review_report method in the ReviewMappingHelper module contains business logic. To improve separation of concerns, create a dedicated Review Report Service to handle calculations, allowing the helper class to focus on view-related logic.&lt;br /&gt;
** Similarly, the display_volume_metric_chart method includes business logic for generating chart data. A Chart Data Service should be introduced to manage these calculations, leaving the helper responsible for rendering.&lt;br /&gt;
** The Charts Module is tightly coupled with the helper class due to its reliance on initialize_chart_elements. To enhance modularity, a separate service object should handle chart initialization.&lt;br /&gt;
&lt;br /&gt;
*'''Improving Method Clarity and Consistency'''&lt;br /&gt;
**Some methods use inconsistent naming conventions (determine, get, obtain). Align method names with Ruby conventions—&amp;quot;get&amp;quot; is generally preferred.&lt;br /&gt;
**Methods like get_data_for_review_report rely on instance variables such as @assignment, assuming they are set beforehand. To improve clarity and reduce potential errors, pass these variables as parameters instead of assuming their existence.&lt;br /&gt;
&lt;br /&gt;
*'''Reducing Unnecessary Comments and Inline Styles'''&lt;br /&gt;
**Replace redundant comments with meaningful explanations that provide insight rather than restating what the code does.&lt;br /&gt;
**Remove these comments from _review_rounds.html.erb. They add no value. Also, remove any hardcoded values.&lt;br /&gt;
*** &amp;amp;lt;!-- Hard-coded Dr.Kidd's question to display link. --&amp;amp;gt;&lt;br /&gt;
*** &amp;amp;lt;!-- Later, we can create a hyperlink question type to deal with this situation. --&amp;amp;gt;&lt;br /&gt;
**The image_tag in _grade_and_comments_form.html.erb uses inline styles; these should be moved to a CSS stylesheet for better maintainability.&lt;br /&gt;
**The _reviewer_info.html.erb view also contains inline styles that should be extracted into a stylesheet.&lt;br /&gt;
&lt;br /&gt;
*'''Removing Unused and Inefficient Code'''&lt;br /&gt;
**The ReviewMappingHelper class contains commented-out code. If this code is no longer needed, delete it.&lt;br /&gt;
**Identify opportunities to use guard clauses to break out of methods early, reducing unnecessary nesting and improving readability.&lt;br /&gt;
*'''Efficient Database Queries'''&lt;br /&gt;
**Several views, such as _response_maps.html.erb and _review_rounds.html.erb, execute database queries directly within the view, making multiple database calls. This logic should be moved to the model, with the Controller passing pre-fetched data to the view.&lt;br /&gt;
**The _reviewer_info.html.erb view accesses session data directly, which should instead be retrieved from the Controller to uphold the Separation of Concerns principle.&lt;br /&gt;
*'''Testing and Code Validation'''&lt;br /&gt;
**Ensure all new Service Classes created for report calculations, chart data, and database queries are thoroughly tested.&lt;br /&gt;
**Review existing tests and fix any failing tests to ensure correctness.&lt;br /&gt;
**Ensure full test coverage for all helper methods.&lt;br /&gt;
*'''Clarify Hardcoded Logic'''&lt;br /&gt;
**The _reviewer_info.html.erb view references reviewer.id == 1, but the significance of this ID is unclear. Either document its importance or store it in a constant that makes sense for better readability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
The Refactoring pattern is essential to enhance code readability, maintainability, and adherence to best practices. By systematically restructuring code components, eliminating redundancies, and applying standard conventions, the Refactoring pattern ensures improved code quality and easier future modifications.&lt;br /&gt;
&lt;br /&gt;
==Plan of work==&lt;br /&gt;
&lt;br /&gt;
We began our work by examining the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file to understand its connection to the rest of the codebase. We then had detailed discussions with our mentor about the project's flow and structure. We organized our project requirements by difficulty levels, assigned tasks among the team, and began refactoring existing methods and creating new files as needed. We made sure to preserve the integrity of existing test cases while adding new ones where needed.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
&lt;br /&gt;
'''Issue #29:''' Removed redundant comments from &amp;lt;code&amp;gt;_review_rounds.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*'''Solution:'''The solution involved cleaning up the code by removing redundant and outdated comments that were no longer necessary or too specific, such as references to team name handling and hard-coded logic for a particular instructor. The code was also slightly refactored for better readability, including consistent use of quotes in HTML attributes and ERB tags.&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Removed_redundant_comments.jpg]] &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #24:'''Inline styles fix for &amp;lt;code&amp;gt;_grades_and_comments._form.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;_reviewer_info.html.erb&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Solution:'''Removed inline styles from the image tag and added a CSS class called &amp;quot;text_macros&amp;quot;. Properly closed the form_with block by adding the missing &amp;lt;% end %&amp;gt;.No major changes were made in _reviewer_info.html.erb, only some formatting improvements..&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:grade_and_comments_form.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:reviewer_info.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #25:''' Move database queries to models in &amp;lt;code&amp;gt;_response_maps.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;_review_rounds.html.erb&amp;lt;/code&amp;gt;. &amp;lt;br&amp;gt;&lt;br /&gt;
*'''Solution:''' Moved database queries to models by replacing &amp;lt;code&amp;gt;Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;Team.from_response_map(reviewer_map)&amp;lt;/code&amp;gt;, encapsulating team retrieval logic in the model. Removed redundant &amp;lt;code&amp;gt;Team.find&amp;lt;/code&amp;gt; calls and replaced &amp;lt;code&amp;gt;Response.exists?(map_id: reviewer_map.id)&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;reviewer_response_map.has_response?&amp;lt;/code&amp;gt;. &amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Removed_redundant_comments.jpg]] &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Response maps.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Issue #27:''' Retrieved Session data from controller and Replace magic number with constant &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*'''Solution:''' Retrieved session data from the controller by replacing session[:ip] with @session_ip, it's set in the controller. Replaced the magic number reviewer.id == 1 with &amp;lt;code&amp;gt;user.super_admin?&amp;lt;/code&amp;gt;, super_admin? is a model method defining the condition&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Reviewer_info_constant.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
'''Issue #7:''' Several methods for feedback_response_maps, check docs to manage this confusion&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Methods involved:''' &amp;lt;code&amp;gt; feedback_response_for_author()&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Previous Code:''' previous code had an ambiguous variable name&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Problem:''' The purpose of the variable was unclear.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Solution:''' Rename the variable to enhance its clarity and provide comments to explain its purpose clearly.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Issue7.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
This project involves refactoring, meaning that the original functionality should remain unchanged. Tasks included adding comments to existing code, altering variable names, and similar adjustments that didn't affect the test cases. When method names were modified or moved to different files, corresponding changes were made in the relevant RSpec files. All test cases passed successfully, indicating that the refactoring didn't break the existing functionality.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As part of this project, the following actions were taken to ensure '''test accuracy and full functionality''':&lt;br /&gt;
* RSpec files were updated to reflect the new service class structure.&lt;br /&gt;
* The test suite was run after each change to confirm that behavior remained consistent across helper and service files.&lt;br /&gt;
* New service classes were fully tested, achieving '''100% test coverage'''.&lt;br /&gt;
* The `ReviewMappingHelper` was thoroughly reviewed and maintained a high coverage rate of '''87.85%''', confirming strong existing test quality.&lt;br /&gt;
* All helper methods dependent on parameters like `@assignment` were validated to ensure they functioned correctly after being decoupled from instance variables.&lt;br /&gt;
* No failing or broken tests were introduced during or after the refactor.&lt;br /&gt;
* '''Test skeletons''' (review_mapping_helper_spec.rb, chart_data_service_spec.rb, and review_report_service_spec.rb) were provided by '''Nitya Naga Sai Atluri natluri@ncsu.edu'''. These were used as the foundation for validating and extending test coverage.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
! File&lt;br /&gt;
! % Covered&lt;br /&gt;
! Lines&lt;br /&gt;
! Relevant Lines&lt;br /&gt;
! Lines Covered&lt;br /&gt;
! Lines Missed&lt;br /&gt;
! Avg. Hits/Line&lt;br /&gt;
|-&lt;br /&gt;
| app/helpers/review_mapping_helper.rb&lt;br /&gt;
| 87.85%&lt;br /&gt;
| 319&lt;br /&gt;
| 181&lt;br /&gt;
| 159&lt;br /&gt;
| 22&lt;br /&gt;
| 3.5&lt;br /&gt;
|-&lt;br /&gt;
| app/services/chart_data_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 112&lt;br /&gt;
| 30&lt;br /&gt;
| 30&lt;br /&gt;
| 0&lt;br /&gt;
| 3.9&lt;br /&gt;
|-&lt;br /&gt;
| app/services/chart_initialization_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 34&lt;br /&gt;
| 22&lt;br /&gt;
| 22&lt;br /&gt;
| 0&lt;br /&gt;
| 243.4&lt;br /&gt;
|-&lt;br /&gt;
| app/services/review_report_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 53&lt;br /&gt;
| 26&lt;br /&gt;
| 26&lt;br /&gt;
| 0&lt;br /&gt;
| 11.9&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Spatel68</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Reviewer_info_constant.jpg&amp;diff=162547</id>
		<title>File:Reviewer info constant.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Reviewer_info_constant.jpg&amp;diff=162547"/>
		<updated>2025-03-25T00:52:58Z</updated>

		<summary type="html">&lt;p&gt;Spatel68: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Spatel68</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2501:_Refactor_review_mapping_helper.rb&amp;diff=162544</id>
		<title>CSC/ECE 517 Spring 2025 - E2501: Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2501:_Refactor_review_mapping_helper.rb&amp;diff=162544"/>
		<updated>2025-03-25T00:51:42Z</updated>

		<summary type="html">&lt;p&gt;Spatel68: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team ==&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Janice Uwujaren &lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Katerina Vilkomir (evilkom)&lt;br /&gt;
* Smit Patel (spatel68)&lt;br /&gt;
* Kenil Patel (kpatel47)&lt;br /&gt;
&lt;br /&gt;
=== Relevant Links ===&lt;br /&gt;
* '''Link to Expertiza Repository:''' https://github.com/expertiza/expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Link to Forked Repository: ''' https://github.com/Kii4ka/expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* ''' Link to Pull Request: ''' &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Expertiza Background==&lt;br /&gt;
Expertiza is a Ruby on Rails framework-based open-source web application. It is kept up by NC State University employees and students. With the help of this program, instructors can fully manage the assignments and responsibilities assigned in their classes. Expertiza provides many strong features, such as subject addition, group creation, and peer review administration. It is a flexible platform that can manage many kinds of tasks. Users can consult the Expertiza wiki to get more in-depth details about the many capabilities that Expertiza offers.&lt;br /&gt;
&lt;br /&gt;
== About Helper ==&lt;br /&gt;
The review_mapping_helper is integral to the peer review process, handling tasks such as calculating review scores, managing submission statuses, generating reports, and displaying review metrics. However, the module is complex because it depends on numerous instance variables, like @assignment and @review_scores, and mixes business logic with view logic.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The tight coupling and unclear separation of concerns make the code difficult to understand, test, and manage. To improve the overall quality of the codebase, the goal of this project is to refactor to ensure that the required info is passed as parameters and to separate business logic from view-related logic.&lt;br /&gt;
&lt;br /&gt;
== What Needs To Be Done == &lt;br /&gt;
*''' Separation of Business Logic and Helpers.'''&lt;br /&gt;
** The get_data_for_review_report method in the ReviewMappingHelper module contains business logic. To improve separation of concerns, create a dedicated Review Report Service to handle calculations, allowing the helper class to focus on view-related logic.&lt;br /&gt;
** Similarly, the display_volume_metric_chart method includes business logic for generating chart data. A Chart Data Service should be introduced to manage these calculations, leaving the helper responsible for rendering.&lt;br /&gt;
** The Charts Module is tightly coupled with the helper class due to its reliance on initialize_chart_elements. To enhance modularity, a separate service object should handle chart initialization.&lt;br /&gt;
&lt;br /&gt;
*'''Improving Method Clarity and Consistency'''&lt;br /&gt;
**Some methods use inconsistent naming conventions (determine, get, obtain). Align method names with Ruby conventions—&amp;quot;get&amp;quot; is generally preferred.&lt;br /&gt;
**Methods like get_data_for_review_report rely on instance variables such as @assignment, assuming they are set beforehand. To improve clarity and reduce potential errors, pass these variables as parameters instead of assuming their existence.&lt;br /&gt;
&lt;br /&gt;
*'''Reducing Unnecessary Comments and Inline Styles'''&lt;br /&gt;
**Replace redundant comments with meaningful explanations that provide insight rather than restating what the code does.&lt;br /&gt;
**Remove these comments from _review_rounds.html.erb. They add no value. Also, remove any hardcoded values.&lt;br /&gt;
*** &amp;amp;lt;!-- Hard-coded Dr.Kidd's question to display link. --&amp;amp;gt;&lt;br /&gt;
*** &amp;amp;lt;!-- Later, we can create a hyperlink question type to deal with this situation. --&amp;amp;gt;&lt;br /&gt;
**The image_tag in _grade_and_comments_form.html.erb uses inline styles; these should be moved to a CSS stylesheet for better maintainability.&lt;br /&gt;
**The _reviewer_info.html.erb view also contains inline styles that should be extracted into a stylesheet.&lt;br /&gt;
&lt;br /&gt;
*'''Removing Unused and Inefficient Code'''&lt;br /&gt;
**The ReviewMappingHelper class contains commented-out code. If this code is no longer needed, delete it.&lt;br /&gt;
**Identify opportunities to use guard clauses to break out of methods early, reducing unnecessary nesting and improving readability.&lt;br /&gt;
*'''Efficient Database Queries'''&lt;br /&gt;
**Several views, such as _response_maps.html.erb and _review_rounds.html.erb, execute database queries directly within the view, making multiple database calls. This logic should be moved to the model, with the Controller passing pre-fetched data to the view.&lt;br /&gt;
**The _reviewer_info.html.erb view accesses session data directly, which should instead be retrieved from the Controller to uphold the Separation of Concerns principle.&lt;br /&gt;
*'''Testing and Code Validation'''&lt;br /&gt;
**Ensure all new Service Classes created for report calculations, chart data, and database queries are thoroughly tested.&lt;br /&gt;
**Review existing tests and fix any failing tests to ensure correctness.&lt;br /&gt;
**Ensure full test coverage for all helper methods.&lt;br /&gt;
*'''Clarify Hardcoded Logic'''&lt;br /&gt;
**The _reviewer_info.html.erb view references reviewer.id == 1, but the significance of this ID is unclear. Either document its importance or store it in a constant that makes sense for better readability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
The Refactoring pattern is essential to enhance code readability, maintainability, and adherence to best practices. By systematically restructuring code components, eliminating redundancies, and applying standard conventions, the Refactoring pattern ensures improved code quality and easier future modifications.&lt;br /&gt;
&lt;br /&gt;
==Plan of work==&lt;br /&gt;
&lt;br /&gt;
We began our work by examining the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file to understand its connection to the rest of the codebase. We then had detailed discussions with our mentor about the project's flow and structure. We organized our project requirements by difficulty levels, assigned tasks among the team, and began refactoring existing methods and creating new files as needed. We made sure to preserve the integrity of existing test cases while adding new ones where needed.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
&lt;br /&gt;
'''Issue #29:''' Removed redundant comments from &amp;lt;code&amp;gt;_review_rounds.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*'''Solution:'''The solution involved cleaning up the code by removing redundant and outdated comments that were no longer necessary or too specific, such as references to team name handling and hard-coded logic for a particular instructor. The code was also slightly refactored for better readability, including consistent use of quotes in HTML attributes and ERB tags.&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Removed_redundant_comments.jpg]] &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #24:'''Inline styles fix for &amp;lt;code&amp;gt;_grades_and_comments._form.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;_reviewer_info.html.erb&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Solution:'''Removed inline styles from the image tag and added a CSS class called &amp;quot;text_macros&amp;quot;. Properly closed the form_with block by adding the missing &amp;lt;% end %&amp;gt;.No major changes were made in _reviewer_info.html.erb, only some formatting improvements..&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:grade_and_comments_form.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:reviewer_info.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #25:''' Move database queries to models in &amp;lt;code&amp;gt;_response_maps.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;_review_rounds.html.erb&amp;lt;/code&amp;gt;. &amp;lt;br&amp;gt;&lt;br /&gt;
*'''Solution:''' Moved database queries to models by replacing &amp;lt;code&amp;gt;Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;Team.from_response_map(reviewer_map)&amp;lt;/code&amp;gt;, encapsulating team retrieval logic in the model. Removed redundant &amp;lt;code&amp;gt;Team.find&amp;lt;/code&amp;gt; calls and replaced &amp;lt;code&amp;gt;Response.exists?(map_id: reviewer_map.id)&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;reviewer_response_map.has_response?&amp;lt;/code&amp;gt;. &amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Removed_redundant_comments.jpg]] &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Response maps.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Issue #27:''' Retrieved Session data from controller and Replace magic number with constant &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*'''Solution:''' Retrieved session data from the controller by replacing session[:ip] with @session_ip, it's set in the controller. Replaced the magic number reviewer.id == 1 with &amp;lt;code&amp;gt;user.super_admin?&amp;lt;/code&amp;gt;, super_admin? is a model method defining the condition&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Issue7.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
'''Issue #7:''' Several methods for feedback_response_maps, check docs to manage this confusion&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Methods involved:''' &amp;lt;code&amp;gt; feedback_response_for_author()&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Previous Code:''' previous code had an ambiguous variable name&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Problem:''' The purpose of the variable was unclear.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Solution:''' Rename the variable to enhance its clarity and provide comments to explain its purpose clearly.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Issue7.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
This project involves refactoring, meaning that the original functionality should remain unchanged. Tasks included adding comments to existing code, altering variable names, and similar adjustments that didn't affect the test cases. When method names were modified or moved to different files, corresponding changes were made in the relevant RSpec files. All test cases passed successfully, indicating that the refactoring didn't break the existing functionality.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As part of this project, the following actions were taken to ensure '''test accuracy and full functionality''':&lt;br /&gt;
* RSpec files were updated to reflect the new service class structure.&lt;br /&gt;
* The test suite was run after each change to confirm that behavior remained consistent across helper and service files.&lt;br /&gt;
* New service classes were fully tested, achieving '''100% test coverage'''.&lt;br /&gt;
* The `ReviewMappingHelper` was thoroughly reviewed and maintained a high coverage rate of '''87.85%''', confirming strong existing test quality.&lt;br /&gt;
* All helper methods dependent on parameters like `@assignment` were validated to ensure they functioned correctly after being decoupled from instance variables.&lt;br /&gt;
* No failing or broken tests were introduced during or after the refactor.&lt;br /&gt;
* '''Test skeletons''' (review_mapping_helper_spec.rb, chart_data_service_spec.rb, and review_report_service_spec.rb) were provided by '''Nitya Naga Sai Atluri natluri@ncsu.edu'''. These were used as the foundation for validating and extending test coverage.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
! File&lt;br /&gt;
! % Covered&lt;br /&gt;
! Lines&lt;br /&gt;
! Relevant Lines&lt;br /&gt;
! Lines Covered&lt;br /&gt;
! Lines Missed&lt;br /&gt;
! Avg. Hits/Line&lt;br /&gt;
|-&lt;br /&gt;
| app/helpers/review_mapping_helper.rb&lt;br /&gt;
| 87.85%&lt;br /&gt;
| 319&lt;br /&gt;
| 181&lt;br /&gt;
| 159&lt;br /&gt;
| 22&lt;br /&gt;
| 3.5&lt;br /&gt;
|-&lt;br /&gt;
| app/services/chart_data_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 112&lt;br /&gt;
| 30&lt;br /&gt;
| 30&lt;br /&gt;
| 0&lt;br /&gt;
| 3.9&lt;br /&gt;
|-&lt;br /&gt;
| app/services/chart_initialization_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 34&lt;br /&gt;
| 22&lt;br /&gt;
| 22&lt;br /&gt;
| 0&lt;br /&gt;
| 243.4&lt;br /&gt;
|-&lt;br /&gt;
| app/services/review_report_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 53&lt;br /&gt;
| 26&lt;br /&gt;
| 26&lt;br /&gt;
| 0&lt;br /&gt;
| 11.9&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Spatel68</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2501:_Refactor_review_mapping_helper.rb&amp;diff=162518</id>
		<title>CSC/ECE 517 Spring 2025 - E2501: Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2501:_Refactor_review_mapping_helper.rb&amp;diff=162518"/>
		<updated>2025-03-25T00:40:57Z</updated>

		<summary type="html">&lt;p&gt;Spatel68: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team ==&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Janice Uwujaren &lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Katerina Vilkomir (evilkom)&lt;br /&gt;
* Smit Patel (spatel68)&lt;br /&gt;
* Kenil Patel (kpatel47)&lt;br /&gt;
&lt;br /&gt;
=== Relevant Links ===&lt;br /&gt;
* '''Link to Expertiza Repository:''' https://github.com/expertiza/expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Link to Forked Repository: ''' https://github.com/Kii4ka/expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* ''' Link to Pull Request: ''' &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Expertiza Background==&lt;br /&gt;
Expertiza is a Ruby on Rails framework-based open-source web application. It is kept up by NC State University employees and students. With the help of this program, instructors can fully manage the assignments and responsibilities assigned in their classes. Expertiza provides many strong features, such as subject addition, group creation, and peer review administration. It is a flexible platform that can manage many kinds of tasks. Users can consult the Expertiza wiki to get more in-depth details about the many capabilities that Expertiza offers.&lt;br /&gt;
&lt;br /&gt;
== About Helper ==&lt;br /&gt;
The review_mapping_helper is integral to the peer review process, handling tasks such as calculating review scores, managing submission statuses, generating reports, and displaying review metrics. However, the module is complex because it depends on numerous instance variables, like @assignment and @review_scores, and mixes business logic with view logic.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The tight coupling and unclear separation of concerns make the code difficult to understand, test, and manage. To improve the overall quality of the codebase, the goal of this project is to refactor to ensure that the required info is passed as parameters and to separate business logic from view-related logic.&lt;br /&gt;
&lt;br /&gt;
== What Needs To Be Done == &lt;br /&gt;
*''' Separation of Business Logic and Helpers.'''&lt;br /&gt;
** The get_data_for_review_report method in the ReviewMappingHelper module contains business logic. To improve separation of concerns, create a dedicated Review Report Service to handle calculations, allowing the helper class to focus on view-related logic.&lt;br /&gt;
** Similarly, the display_volume_metric_chart method includes business logic for generating chart data. A Chart Data Service should be introduced to manage these calculations, leaving the helper responsible for rendering.&lt;br /&gt;
** The Charts Module is tightly coupled with the helper class due to its reliance on initialize_chart_elements. To enhance modularity, a separate service object should handle chart initialization.&lt;br /&gt;
&lt;br /&gt;
*'''Improving Method Clarity and Consistency'''&lt;br /&gt;
**Some methods use inconsistent naming conventions (determine, get, obtain). Align method names with Ruby conventions—&amp;quot;get&amp;quot; is generally preferred.&lt;br /&gt;
**Methods like get_data_for_review_report rely on instance variables such as @assignment, assuming they are set beforehand. To improve clarity and reduce potential errors, pass these variables as parameters instead of assuming their existence.&lt;br /&gt;
&lt;br /&gt;
*'''Reducing Unnecessary Comments and Inline Styles'''&lt;br /&gt;
**Replace redundant comments with meaningful explanations that provide insight rather than restating what the code does.&lt;br /&gt;
**Remove these comments from _review_rounds.html.erb. They add no value. Also, remove any hardcoded values.&lt;br /&gt;
*** &amp;amp;lt;!-- Hard-coded Dr.Kidd's question to display link. --&amp;amp;gt;&lt;br /&gt;
*** &amp;amp;lt;!-- Later, we can create a hyperlink question type to deal with this situation. --&amp;amp;gt;&lt;br /&gt;
**The image_tag in _grade_and_comments_form.html.erb uses inline styles; these should be moved to a CSS stylesheet for better maintainability.&lt;br /&gt;
**The _reviewer_info.html.erb view also contains inline styles that should be extracted into a stylesheet.&lt;br /&gt;
&lt;br /&gt;
*'''Removing Unused and Inefficient Code'''&lt;br /&gt;
**The ReviewMappingHelper class contains commented-out code. If this code is no longer needed, delete it.&lt;br /&gt;
**Identify opportunities to use guard clauses to break out of methods early, reducing unnecessary nesting and improving readability.&lt;br /&gt;
*'''Efficient Database Queries'''&lt;br /&gt;
**Several views, such as _response_maps.html.erb and _review_rounds.html.erb, execute database queries directly within the view, making multiple database calls. This logic should be moved to the model, with the Controller passing pre-fetched data to the view.&lt;br /&gt;
**The _reviewer_info.html.erb view accesses session data directly, which should instead be retrieved from the Controller to uphold the Separation of Concerns principle.&lt;br /&gt;
*'''Testing and Code Validation'''&lt;br /&gt;
**Ensure all new Service Classes created for report calculations, chart data, and database queries are thoroughly tested.&lt;br /&gt;
**Review existing tests and fix any failing tests to ensure correctness.&lt;br /&gt;
**Ensure full test coverage for all helper methods.&lt;br /&gt;
*'''Clarify Hardcoded Logic'''&lt;br /&gt;
**The _reviewer_info.html.erb view references reviewer.id == 1, but the significance of this ID is unclear. Either document its importance or store it in a constant that makes sense for better readability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
The Refactoring pattern is essential to enhance code readability, maintainability, and adherence to best practices. By systematically restructuring code components, eliminating redundancies, and applying standard conventions, the Refactoring pattern ensures improved code quality and easier future modifications.&lt;br /&gt;
&lt;br /&gt;
==Plan of work==&lt;br /&gt;
&lt;br /&gt;
We began our work by examining the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file to understand its connection to the rest of the codebase. We then had detailed discussions with our mentor about the project's flow and structure. We organized our project requirements by difficulty levels, assigned tasks among the team, and began refactoring existing methods and creating new files as needed. We made sure to preserve the integrity of existing test cases while adding new ones where needed.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
&lt;br /&gt;
'''Issue #29:''' Removed redundant comments from &amp;lt;code&amp;gt;_review_rounds.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*'''Solution:'''The solution involved cleaning up the code by removing redundant and outdated comments that were no longer necessary or too specific, such as references to team name handling and hard-coded logic for a particular instructor. The code was also slightly refactored for better readability, including consistent use of quotes in HTML attributes and ERB tags.&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Removed_redundant_comments.jpg]] &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #24:'''Inline styles fix for &amp;lt;code&amp;gt;_grades_and_comments._form.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;_reviewer_info.html.erb&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Solution:'''Removed inline styles from the image tag and added a CSS class called &amp;quot;text_macros&amp;quot;. Properly closed the form_with block by adding the missing &amp;lt;% end %&amp;gt;.No major changes were made in _reviewer_info.html.erb, only some formatting improvements..&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:grade_and_comments_form.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:reviewer_info.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #6:''' Move database queries to models in &amp;lt;code&amp;gt;_response_maps.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;_review_rounds.html.erb&amp;lt;/code&amp;gt;. &amp;lt;br&amp;gt;&lt;br /&gt;
*'''Solution:''' Moved database queries to models by replacing &amp;lt;code&amp;gt;Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;Team.from_response_map(reviewer_map)&amp;lt;/code&amp;gt;, encapsulating team retrieval logic in the model. Removed redundant &amp;lt;code&amp;gt;Team.find&amp;lt;/code&amp;gt; calls and replaced &amp;lt;code&amp;gt;Response.exists?(map_id: reviewer_map.id)&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;reviewer_response_map.has_response?&amp;lt;/code&amp;gt;. &amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Removed_redundant_comments.jpg]] &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[Response maps.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #7:''' Several methods for feedback_response_maps, check docs to manage this confusion&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Methods involved:''' &amp;lt;code&amp;gt; feedback_response_for_author()&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Previous Code:''' previous code had an ambiguous variable name&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Problem:''' The purpose of the variable was unclear.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Solution:''' Rename the variable to enhance its clarity and provide comments to explain its purpose clearly.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Issue7.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
This project involves refactoring, meaning that the original functionality should remain unchanged. Tasks included adding comments to existing code, altering variable names, and similar adjustments that didn't affect the test cases. When method names were modified or moved to different files, corresponding changes were made in the relevant RSpec files. All test cases passed successfully, indicating that the refactoring didn't break the existing functionality.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As part of this project, the following actions were taken to ensure '''test accuracy and full functionality''':&lt;br /&gt;
* RSpec files were updated to reflect the new service class structure.&lt;br /&gt;
* The test suite was run after each change to confirm that behavior remained consistent across helper and service files.&lt;br /&gt;
* New service classes were fully tested, achieving '''100% test coverage'''.&lt;br /&gt;
* The `ReviewMappingHelper` was thoroughly reviewed and maintained a high coverage rate of '''87.85%''', confirming strong existing test quality.&lt;br /&gt;
* All helper methods dependent on parameters like `@assignment` were validated to ensure they functioned correctly after being decoupled from instance variables.&lt;br /&gt;
* No failing or broken tests were introduced during or after the refactor.&lt;br /&gt;
* '''Test skeletons''' (review_mapping_helper_spec.rb, chart_data_service_spec.rb, and review_report_service_spec.rb) were provided by '''Nitya Naga Sai Atluri natluri@ncsu.edu'''. These were used as the foundation for validating and extending test coverage.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
! File&lt;br /&gt;
! % Covered&lt;br /&gt;
! Lines&lt;br /&gt;
! Relevant Lines&lt;br /&gt;
! Lines Covered&lt;br /&gt;
! Lines Missed&lt;br /&gt;
! Avg. Hits/Line&lt;br /&gt;
|-&lt;br /&gt;
| app/helpers/review_mapping_helper.rb&lt;br /&gt;
| 87.85%&lt;br /&gt;
| 319&lt;br /&gt;
| 181&lt;br /&gt;
| 159&lt;br /&gt;
| 22&lt;br /&gt;
| 3.5&lt;br /&gt;
|-&lt;br /&gt;
| app/services/chart_data_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 112&lt;br /&gt;
| 30&lt;br /&gt;
| 30&lt;br /&gt;
| 0&lt;br /&gt;
| 3.9&lt;br /&gt;
|-&lt;br /&gt;
| app/services/chart_initialization_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 34&lt;br /&gt;
| 22&lt;br /&gt;
| 22&lt;br /&gt;
| 0&lt;br /&gt;
| 243.4&lt;br /&gt;
|-&lt;br /&gt;
| app/services/review_report_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 53&lt;br /&gt;
| 26&lt;br /&gt;
| 26&lt;br /&gt;
| 0&lt;br /&gt;
| 11.9&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Spatel68</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2501:_Refactor_review_mapping_helper.rb&amp;diff=162517</id>
		<title>CSC/ECE 517 Spring 2025 - E2501: Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2501:_Refactor_review_mapping_helper.rb&amp;diff=162517"/>
		<updated>2025-03-25T00:40:02Z</updated>

		<summary type="html">&lt;p&gt;Spatel68: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team ==&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Janice Uwujaren &lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Katerina Vilkomir (evilkom)&lt;br /&gt;
* Smit Patel (spatel68)&lt;br /&gt;
* Kenil Patel (kpatel47)&lt;br /&gt;
&lt;br /&gt;
=== Relevant Links ===&lt;br /&gt;
* '''Link to Expertiza Repository:''' https://github.com/expertiza/expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Link to Forked Repository: ''' https://github.com/Kii4ka/expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* ''' Link to Pull Request: ''' &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Expertiza Background==&lt;br /&gt;
Expertiza is a Ruby on Rails framework-based open-source web application. It is kept up by NC State University employees and students. With the help of this program, instructors can fully manage the assignments and responsibilities assigned in their classes. Expertiza provides many strong features, such as subject addition, group creation, and peer review administration. It is a flexible platform that can manage many kinds of tasks. Users can consult the Expertiza wiki to get more in-depth details about the many capabilities that Expertiza offers.&lt;br /&gt;
&lt;br /&gt;
== About Helper ==&lt;br /&gt;
The review_mapping_helper is integral to the peer review process, handling tasks such as calculating review scores, managing submission statuses, generating reports, and displaying review metrics. However, the module is complex because it depends on numerous instance variables, like @assignment and @review_scores, and mixes business logic with view logic.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The tight coupling and unclear separation of concerns make the code difficult to understand, test, and manage. To improve the overall quality of the codebase, the goal of this project is to refactor to ensure that the required info is passed as parameters and to separate business logic from view-related logic.&lt;br /&gt;
&lt;br /&gt;
== What Needs To Be Done == &lt;br /&gt;
*''' Separation of Business Logic and Helpers.'''&lt;br /&gt;
** The get_data_for_review_report method in the ReviewMappingHelper module contains business logic. To improve separation of concerns, create a dedicated Review Report Service to handle calculations, allowing the helper class to focus on view-related logic.&lt;br /&gt;
** Similarly, the display_volume_metric_chart method includes business logic for generating chart data. A Chart Data Service should be introduced to manage these calculations, leaving the helper responsible for rendering.&lt;br /&gt;
** The Charts Module is tightly coupled with the helper class due to its reliance on initialize_chart_elements. To enhance modularity, a separate service object should handle chart initialization.&lt;br /&gt;
&lt;br /&gt;
*'''Improving Method Clarity and Consistency'''&lt;br /&gt;
**Some methods use inconsistent naming conventions (determine, get, obtain). Align method names with Ruby conventions—&amp;quot;get&amp;quot; is generally preferred.&lt;br /&gt;
**Methods like get_data_for_review_report rely on instance variables such as @assignment, assuming they are set beforehand. To improve clarity and reduce potential errors, pass these variables as parameters instead of assuming their existence.&lt;br /&gt;
&lt;br /&gt;
*'''Reducing Unnecessary Comments and Inline Styles'''&lt;br /&gt;
**Replace redundant comments with meaningful explanations that provide insight rather than restating what the code does.&lt;br /&gt;
**Remove these comments from _review_rounds.html.erb. They add no value. Also, remove any hardcoded values.&lt;br /&gt;
*** &amp;amp;lt;!-- Hard-coded Dr.Kidd's question to display link. --&amp;amp;gt;&lt;br /&gt;
*** &amp;amp;lt;!-- Later, we can create a hyperlink question type to deal with this situation. --&amp;amp;gt;&lt;br /&gt;
**The image_tag in _grade_and_comments_form.html.erb uses inline styles; these should be moved to a CSS stylesheet for better maintainability.&lt;br /&gt;
**The _reviewer_info.html.erb view also contains inline styles that should be extracted into a stylesheet.&lt;br /&gt;
&lt;br /&gt;
*'''Removing Unused and Inefficient Code'''&lt;br /&gt;
**The ReviewMappingHelper class contains commented-out code. If this code is no longer needed, delete it.&lt;br /&gt;
**Identify opportunities to use guard clauses to break out of methods early, reducing unnecessary nesting and improving readability.&lt;br /&gt;
*'''Efficient Database Queries'''&lt;br /&gt;
**Several views, such as _response_maps.html.erb and _review_rounds.html.erb, execute database queries directly within the view, making multiple database calls. This logic should be moved to the model, with the Controller passing pre-fetched data to the view.&lt;br /&gt;
**The _reviewer_info.html.erb view accesses session data directly, which should instead be retrieved from the Controller to uphold the Separation of Concerns principle.&lt;br /&gt;
*'''Testing and Code Validation'''&lt;br /&gt;
**Ensure all new Service Classes created for report calculations, chart data, and database queries are thoroughly tested.&lt;br /&gt;
**Review existing tests and fix any failing tests to ensure correctness.&lt;br /&gt;
**Ensure full test coverage for all helper methods.&lt;br /&gt;
*'''Clarify Hardcoded Logic'''&lt;br /&gt;
**The _reviewer_info.html.erb view references reviewer.id == 1, but the significance of this ID is unclear. Either document its importance or store it in a constant that makes sense for better readability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
The Refactoring pattern is essential to enhance code readability, maintainability, and adherence to best practices. By systematically restructuring code components, eliminating redundancies, and applying standard conventions, the Refactoring pattern ensures improved code quality and easier future modifications.&lt;br /&gt;
&lt;br /&gt;
==Plan of work==&lt;br /&gt;
&lt;br /&gt;
We began our work by examining the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file to understand its connection to the rest of the codebase. We then had detailed discussions with our mentor about the project's flow and structure. We organized our project requirements by difficulty levels, assigned tasks among the team, and began refactoring existing methods and creating new files as needed. We made sure to preserve the integrity of existing test cases while adding new ones where needed.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
&lt;br /&gt;
'''Issue #29:''' Removed redundant comments from &amp;lt;code&amp;gt;_review_rounds.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*'''Solution:'''The solution involved cleaning up the code by removing redundant and outdated comments that were no longer necessary or too specific, such as references to team name handling and hard-coded logic for a particular instructor. The code was also slightly refactored for better readability, including consistent use of quotes in HTML attributes and ERB tags.&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Removed_redundant_comments.jpg]] &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #24:'''Inline styles fix for &amp;lt;code&amp;gt;_grades_and_comments._form.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;_reviewer_info.html.erb&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Solution:'''Removed inline styles from the image tag and added a CSS class called &amp;quot;text_macros&amp;quot;. Properly closed the form_with block by adding the missing &amp;lt;% end %&amp;gt;.No major changes were made in _reviewer_info.html.erb, only some formatting improvements..&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:grade_and_comments_form.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:reviewer_info.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #6:''' Move database queries to models in &amp;lt;code&amp;gt;_response_maps.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;_review_rounds.html.erb&amp;lt;/code&amp;gt;. &amp;lt;br&amp;gt;&lt;br /&gt;
*'''Solution:''' Moved database queries to models by replacing &amp;lt;code&amp;gt;Team.where(id: reviewer_map.reviewee_id).length &amp;gt; 0&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;Team.from_response_map(reviewer_map)&amp;lt;/code&amp;gt;, encapsulating team retrieval logic in the model. Removed redundant &amp;lt;code&amp;gt;Team.find&amp;lt;/code&amp;gt; calls and replaced &amp;lt;code&amp;gt;Response.exists?(map_id: reviewer_map.id)&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;reviewer_response_map.has_response?&amp;lt;/code&amp;gt;. &amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Removed_redundant_comments.jpg]] &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[response_maps.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #7:''' Several methods for feedback_response_maps, check docs to manage this confusion&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Methods involved:''' &amp;lt;code&amp;gt; feedback_response_for_author()&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Previous Code:''' previous code had an ambiguous variable name&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Problem:''' The purpose of the variable was unclear.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Solution:''' Rename the variable to enhance its clarity and provide comments to explain its purpose clearly.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Issue7.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
This project involves refactoring, meaning that the original functionality should remain unchanged. Tasks included adding comments to existing code, altering variable names, and similar adjustments that didn't affect the test cases. When method names were modified or moved to different files, corresponding changes were made in the relevant RSpec files. All test cases passed successfully, indicating that the refactoring didn't break the existing functionality.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As part of this project, the following actions were taken to ensure '''test accuracy and full functionality''':&lt;br /&gt;
* RSpec files were updated to reflect the new service class structure.&lt;br /&gt;
* The test suite was run after each change to confirm that behavior remained consistent across helper and service files.&lt;br /&gt;
* New service classes were fully tested, achieving '''100% test coverage'''.&lt;br /&gt;
* The `ReviewMappingHelper` was thoroughly reviewed and maintained a high coverage rate of '''87.85%''', confirming strong existing test quality.&lt;br /&gt;
* All helper methods dependent on parameters like `@assignment` were validated to ensure they functioned correctly after being decoupled from instance variables.&lt;br /&gt;
* No failing or broken tests were introduced during or after the refactor.&lt;br /&gt;
* '''Test skeletons''' (review_mapping_helper_spec.rb, chart_data_service_spec.rb, and review_report_service_spec.rb) were provided by '''Nitya Naga Sai Atluri natluri@ncsu.edu'''. These were used as the foundation for validating and extending test coverage.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
! File&lt;br /&gt;
! % Covered&lt;br /&gt;
! Lines&lt;br /&gt;
! Relevant Lines&lt;br /&gt;
! Lines Covered&lt;br /&gt;
! Lines Missed&lt;br /&gt;
! Avg. Hits/Line&lt;br /&gt;
|-&lt;br /&gt;
| app/helpers/review_mapping_helper.rb&lt;br /&gt;
| 87.85%&lt;br /&gt;
| 319&lt;br /&gt;
| 181&lt;br /&gt;
| 159&lt;br /&gt;
| 22&lt;br /&gt;
| 3.5&lt;br /&gt;
|-&lt;br /&gt;
| app/services/chart_data_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 112&lt;br /&gt;
| 30&lt;br /&gt;
| 30&lt;br /&gt;
| 0&lt;br /&gt;
| 3.9&lt;br /&gt;
|-&lt;br /&gt;
| app/services/chart_initialization_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 34&lt;br /&gt;
| 22&lt;br /&gt;
| 22&lt;br /&gt;
| 0&lt;br /&gt;
| 243.4&lt;br /&gt;
|-&lt;br /&gt;
| app/services/review_report_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 53&lt;br /&gt;
| 26&lt;br /&gt;
| 26&lt;br /&gt;
| 0&lt;br /&gt;
| 11.9&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Spatel68</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Response_maps.jpg&amp;diff=162516</id>
		<title>File:Response maps.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Response_maps.jpg&amp;diff=162516"/>
		<updated>2025-03-25T00:39:05Z</updated>

		<summary type="html">&lt;p&gt;Spatel68: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Spatel68</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Reviewer_info.jpg&amp;diff=162373</id>
		<title>File:Reviewer info.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Reviewer_info.jpg&amp;diff=162373"/>
		<updated>2025-03-24T21:01:51Z</updated>

		<summary type="html">&lt;p&gt;Spatel68: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Spatel68</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Grade_and_comments_form.jpg&amp;diff=162372</id>
		<title>File:Grade and comments form.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Grade_and_comments_form.jpg&amp;diff=162372"/>
		<updated>2025-03-24T21:01:31Z</updated>

		<summary type="html">&lt;p&gt;Spatel68: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Spatel68</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2501:_Refactor_review_mapping_helper.rb&amp;diff=162371</id>
		<title>CSC/ECE 517 Spring 2025 - E2501: Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2501:_Refactor_review_mapping_helper.rb&amp;diff=162371"/>
		<updated>2025-03-24T20:57:06Z</updated>

		<summary type="html">&lt;p&gt;Spatel68: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team ==&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Janice Uwujaren &lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Katerina Vilkomir (evilkom)&lt;br /&gt;
* Smit Patel (spatel68)&lt;br /&gt;
* Kenil Patel (kpatel47)&lt;br /&gt;
&lt;br /&gt;
=== Relevant Links ===&lt;br /&gt;
* '''Link to Expertiza Repository:''' https://github.com/expertiza/expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Link to Forked Repository: ''' https://github.com/Kii4ka/expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* ''' Link to Pull Request: ''' &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Expertiza Background==&lt;br /&gt;
Expertiza is a Ruby on Rails framework-based open-source web application. It is kept up by NC State University employees and students. With the help of this program, instructors can fully manage the assignments and responsibilities assigned in their classes. Expertiza provides many strong features, such as subject addition, group creation, and peer review administration. It is a flexible platform that can manage many kinds of tasks. Users can consult the Expertiza wiki to get more in-depth details about the many capabilities that Expertiza offers.&lt;br /&gt;
&lt;br /&gt;
== About Helper ==&lt;br /&gt;
The review_mapping_helper is integral to the peer review process, handling tasks such as calculating review scores, managing submission statuses, generating reports, and displaying review metrics. However, the module is complex because it depends on numerous instance variables, like @assignment and @review_scores, and mixes business logic with view logic.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The tight coupling and unclear separation of concerns make the code difficult to understand, test, and manage. To improve the overall quality of the codebase, the goal of this project is to refactor to ensure that the required info is passed as parameters and to separate business logic from view-related logic.&lt;br /&gt;
&lt;br /&gt;
== What Needs To Be Done == &lt;br /&gt;
*''' Separation of Business Logic and Helpers.'''&lt;br /&gt;
** The get_data_for_review_report method in the ReviewMappingHelper module contains business logic. To improve separation of concerns, create a dedicated Review Report Service to handle calculations, allowing the helper class to focus on view-related logic.&lt;br /&gt;
** Similarly, the display_volume_metric_chart method includes business logic for generating chart data. A Chart Data Service should be introduced to manage these calculations, leaving the helper responsible for rendering.&lt;br /&gt;
** The Charts Module is tightly coupled with the helper class due to its reliance on initialize_chart_elements. To enhance modularity, a separate service object should handle chart initialization.&lt;br /&gt;
&lt;br /&gt;
*'''Improving Method Clarity and Consistency'''&lt;br /&gt;
**Some methods use inconsistent naming conventions (determine, get, obtain). Align method names with Ruby conventions—&amp;quot;get&amp;quot; is generally preferred.&lt;br /&gt;
**Methods like get_data_for_review_report rely on instance variables such as @assignment, assuming they are set beforehand. To improve clarity and reduce potential errors, pass these variables as parameters instead of assuming their existence.&lt;br /&gt;
&lt;br /&gt;
*'''Reducing Unnecessary Comments and Inline Styles'''&lt;br /&gt;
**Replace redundant comments with meaningful explanations that provide insight rather than restating what the code does.&lt;br /&gt;
**Remove these comments from _review_rounds.html.erb. They add no value. Also, remove any hardcoded values.&lt;br /&gt;
*** &amp;amp;lt;!-- Hard-coded Dr.Kidd's question to display link. --&amp;amp;gt;&lt;br /&gt;
*** &amp;amp;lt;!-- Later, we can create a hyperlink question type to deal with this situation. --&amp;amp;gt;&lt;br /&gt;
**The image_tag in _grade_and_comments_form.html.erb uses inline styles; these should be moved to a CSS stylesheet for better maintainability.&lt;br /&gt;
**The _reviewer_info.html.erb view also contains inline styles that should be extracted into a stylesheet.&lt;br /&gt;
&lt;br /&gt;
*'''Removing Unused and Inefficient Code'''&lt;br /&gt;
**The ReviewMappingHelper class contains commented-out code. If this code is no longer needed, delete it.&lt;br /&gt;
**Identify opportunities to use guard clauses to break out of methods early, reducing unnecessary nesting and improving readability.&lt;br /&gt;
*'''Efficient Database Queries'''&lt;br /&gt;
**Several views, such as _response_maps.html.erb and _review_rounds.html.erb, execute database queries directly within the view, making multiple database calls. This logic should be moved to the model, with the Controller passing pre-fetched data to the view.&lt;br /&gt;
**The _reviewer_info.html.erb view accesses session data directly, which should instead be retrieved from the Controller to uphold the Separation of Concerns principle.&lt;br /&gt;
*'''Testing and Code Validation'''&lt;br /&gt;
**Ensure all new Service Classes created for report calculations, chart data, and database queries are thoroughly tested.&lt;br /&gt;
**Review existing tests and fix any failing tests to ensure correctness.&lt;br /&gt;
**Ensure full test coverage for all helper methods.&lt;br /&gt;
*'''Clarify Hardcoded Logic'''&lt;br /&gt;
**The _reviewer_info.html.erb view references reviewer.id == 1, but the significance of this ID is unclear. Either document its importance or store it in a constant that makes sense for better readability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
The Refactoring pattern is essential to enhance code readability, maintainability, and adherence to best practices. By systematically restructuring code components, eliminating redundancies, and applying standard conventions, the Refactoring pattern ensures improved code quality and easier future modifications.&lt;br /&gt;
&lt;br /&gt;
==Plan of work==&lt;br /&gt;
&lt;br /&gt;
We began our work by examining the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file to understand its connection to the rest of the codebase. We then had detailed discussions with our mentor about the project's flow and structure. We organized our project requirements by difficulty levels, assigned tasks among the team, and began refactoring existing methods and creating new files as needed. We made sure to preserve the integrity of existing test cases while adding new ones where needed.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
&lt;br /&gt;
'''Issue #29:''' Removed redundant comments from &amp;lt;code&amp;gt;_review_rounds.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*'''Solution:'''The solution involved cleaning up the code by removing redundant and outdated comments that were no longer necessary or too specific, such as references to team name handling and hard-coded logic for a particular instructor. The code was also slightly refactored for better readability, including consistent use of quotes in HTML attributes and ERB tags.&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Removed_redundant_comments.jpg]] &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #5:'''Inline styles fix for &amp;lt;code&amp;gt;_grades_and_comments._form.html.erb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;_reviewer_info.html.erb&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Solution:'''Removed inline styles from the image tag and added a CSS class called &amp;quot;text_macros&amp;quot;. Properly closed the form_with block by adding the missing &amp;lt;% end %&amp;gt;.No major changes were made in _reviewer_info.html.erb, only some formatting improvements..&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:5_1.jpg]]t&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Issue_Metrics5.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #6:''' make a separate file for for chart related elements in &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Methods involved:''' &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;br&amp;gt;&lt;br /&gt;
*'''Previous Code:''' The methods mentioned used to be included in the review_mapping_helper.rb file, but they should have been in their own helper file.&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Problem:''' These techniques carry out comparable functions in creating graphs and can be implemented as either distinct modules or mixins. Additionally, each method contains more than 30 lines, making them excessively lengthy.&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Solution:''' Created new module named 'Charts' withinthe same file. This way the chart helper methods are separated from review_mapping_helper where they are out of place and difficult for any developer to find. &amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Issue6.jpg]]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Issue6.2.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #7:''' Several methods for feedback_response_maps, check docs to manage this confusion&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Methods involved:''' &amp;lt;code&amp;gt; feedback_response_for_author()&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Previous Code:''' previous code had an ambiguous variable name&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Problem:''' The purpose of the variable was unclear.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Solution:''' Rename the variable to enhance its clarity and provide comments to explain its purpose clearly.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Issue7.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
This project involves refactoring, meaning that the original functionality should remain unchanged. Tasks included adding comments to existing code, altering variable names, and similar adjustments that didn't affect the test cases. When method names were modified or moved to different files, corresponding changes were made in the relevant RSpec files. All test cases passed successfully, indicating that the refactoring didn't break the existing functionality.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As part of this project, the following actions were taken to ensure '''test accuracy and full functionality''':&lt;br /&gt;
* RSpec files were updated to reflect the new service class structure.&lt;br /&gt;
* The test suite was run after each change to confirm that behavior remained consistent across helper and service files.&lt;br /&gt;
* New service classes were fully tested, achieving '''100% test coverage'''.&lt;br /&gt;
* The `ReviewMappingHelper` was thoroughly reviewed and maintained a high coverage rate of '''87.85%''', confirming strong existing test quality.&lt;br /&gt;
* All helper methods dependent on parameters like `@assignment` were validated to ensure they functioned correctly after being decoupled from instance variables.&lt;br /&gt;
* No failing or broken tests were introduced during or after the refactor.&lt;br /&gt;
* '''Test skeletons''' (review_mapping_helper_spec.rb, chart_data_service_spec.rb, and review_report_service_spec.rb) were provided by '''Nitya Naga Sai Atluri natluri@ncsu.edu'''. These were used as the foundation for validating and extending test coverage.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
! File&lt;br /&gt;
! % Covered&lt;br /&gt;
! Lines&lt;br /&gt;
! Relevant Lines&lt;br /&gt;
! Lines Covered&lt;br /&gt;
! Lines Missed&lt;br /&gt;
! Avg. Hits/Line&lt;br /&gt;
|-&lt;br /&gt;
| app/helpers/review_mapping_helper.rb&lt;br /&gt;
| 87.85%&lt;br /&gt;
| 319&lt;br /&gt;
| 181&lt;br /&gt;
| 159&lt;br /&gt;
| 22&lt;br /&gt;
| 3.5&lt;br /&gt;
|-&lt;br /&gt;
| app/services/chart_data_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 112&lt;br /&gt;
| 30&lt;br /&gt;
| 30&lt;br /&gt;
| 0&lt;br /&gt;
| 3.9&lt;br /&gt;
|-&lt;br /&gt;
| app/services/chart_initialization_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 34&lt;br /&gt;
| 22&lt;br /&gt;
| 22&lt;br /&gt;
| 0&lt;br /&gt;
| 243.4&lt;br /&gt;
|-&lt;br /&gt;
| app/services/review_report_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 53&lt;br /&gt;
| 26&lt;br /&gt;
| 26&lt;br /&gt;
| 0&lt;br /&gt;
| 11.9&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Spatel68</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Removed_redundant_comments.jpg&amp;diff=162104</id>
		<title>File:Removed redundant comments.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Removed_redundant_comments.jpg&amp;diff=162104"/>
		<updated>2025-03-23T21:51:21Z</updated>

		<summary type="html">&lt;p&gt;Spatel68: Spatel68 uploaded a new version of File:Removed redundant comments.jpg&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Spatel68</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2501:_Refactor_review_mapping_helper.rb&amp;diff=162103</id>
		<title>CSC/ECE 517 Spring 2025 - E2501: Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2501:_Refactor_review_mapping_helper.rb&amp;diff=162103"/>
		<updated>2025-03-23T21:50:48Z</updated>

		<summary type="html">&lt;p&gt;Spatel68: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team ==&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Janice Uwujaren &lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Katerina Vilkomir (evilkom)&lt;br /&gt;
* Smit Patel (spatel68)&lt;br /&gt;
* Kenil Patel (kpatel47)&lt;br /&gt;
&lt;br /&gt;
=== Relevant Links ===&lt;br /&gt;
* '''Link to Expertiza Repository:''' https://github.com/expertiza/expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Link to Forked Repository: ''' https://github.com/Kii4ka/expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* ''' Link to Pull Request: ''' &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Expertiza Background==&lt;br /&gt;
Expertiza is a Ruby on Rails framework-based open-source web application. It is kept up by NC State University employees and students. With the help of this program, instructors can fully manage the assignments and responsibilities assigned in their classes. Expertiza provides many strong features, such as subject addition, group creation, and peer review administration. It is a flexible platform that can manage many kinds of tasks. Users can consult the Expertiza wiki to get more in-depth details about the many capabilities that Expertiza offers.&lt;br /&gt;
&lt;br /&gt;
== About Helper ==&lt;br /&gt;
The review_mapping_helper is integral to the peer review process, handling tasks such as calculating review scores, managing submission statuses, generating reports, and displaying review metrics. However, the module is complex because it depends on numerous instance variables, like @assignment and @review_scores, and mixes business logic with view logic.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The tight coupling and unclear separation of concerns make the code difficult to understand, test, and manage. To improve the overall quality of the codebase, the goal of this project is to refactor to ensure that the required info is passed as parameters and to separate business logic from view-related logic.&lt;br /&gt;
&lt;br /&gt;
== What Needs To Be Done == &lt;br /&gt;
*''' Separation of Business Logic and Helpers.'''&lt;br /&gt;
** The get_data_for_review_report method in the ReviewMappingHelper module contains business logic. To improve separation of concerns, create a dedicated Review Report Service to handle calculations, allowing the helper class to focus on view-related logic.&lt;br /&gt;
** Similarly, the display_volume_metric_chart method includes business logic for generating chart data. A Chart Data Service should be introduced to manage these calculations, leaving the helper responsible for rendering.&lt;br /&gt;
** The Charts Module is tightly coupled with the helper class due to its reliance on initialize_chart_elements. To enhance modularity, a separate service object should handle chart initialization.&lt;br /&gt;
&lt;br /&gt;
*'''Improving Method Clarity and Consistency'''&lt;br /&gt;
**Some methods use inconsistent naming conventions (determine, get, obtain). Align method names with Ruby conventions—&amp;quot;get&amp;quot; is generally preferred.&lt;br /&gt;
**Methods like get_data_for_review_report rely on instance variables such as @assignment, assuming they are set beforehand. To improve clarity and reduce potential errors, pass these variables as parameters instead of assuming their existence.&lt;br /&gt;
&lt;br /&gt;
*'''Reducing Unnecessary Comments and Inline Styles'''&lt;br /&gt;
**Replace redundant comments with meaningful explanations that provide insight rather than restating what the code does.&lt;br /&gt;
**Remove these comments from _review_rounds.html.erb. They add no value. Also, remove any hardcoded values.&lt;br /&gt;
*** &amp;amp;lt;!-- Hard-coded Dr.Kidd's question to display link. --&amp;amp;gt;&lt;br /&gt;
*** &amp;amp;lt;!-- Later, we can create a hyperlink question type to deal with this situation. --&amp;amp;gt;&lt;br /&gt;
**The image_tag in _grade_and_comments_form.html.erb uses inline styles; these should be moved to a CSS stylesheet for better maintainability.&lt;br /&gt;
**The _reviewer_info.html.erb view also contains inline styles that should be extracted into a stylesheet.&lt;br /&gt;
&lt;br /&gt;
*'''Removing Unused and Inefficient Code'''&lt;br /&gt;
**The ReviewMappingHelper class contains commented-out code. If this code is no longer needed, delete it.&lt;br /&gt;
**Identify opportunities to use guard clauses to break out of methods early, reducing unnecessary nesting and improving readability.&lt;br /&gt;
*'''Efficient Database Queries'''&lt;br /&gt;
**Several views, such as _response_maps.html.erb and _review_rounds.html.erb, execute database queries directly within the view, making multiple database calls. This logic should be moved to the model, with the Controller passing pre-fetched data to the view.&lt;br /&gt;
**The _reviewer_info.html.erb view accesses session data directly, which should instead be retrieved from the Controller to uphold the Separation of Concerns principle.&lt;br /&gt;
*'''Testing and Code Validation'''&lt;br /&gt;
**Ensure all new Service Classes created for report calculations, chart data, and database queries are thoroughly tested.&lt;br /&gt;
**Review existing tests and fix any failing tests to ensure correctness.&lt;br /&gt;
**Ensure full test coverage for all helper methods.&lt;br /&gt;
*'''Clarify Hardcoded Logic'''&lt;br /&gt;
**The _reviewer_info.html.erb view references reviewer.id == 1, but the significance of this ID is unclear. Either document its importance or store it in a constant that makes sense for better readability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
The Refactoring pattern is essential to enhance code readability, maintainability, and adherence to best practices. By systematically restructuring code components, eliminating redundancies, and applying standard conventions, the Refactoring pattern ensures improved code quality and easier future modifications.&lt;br /&gt;
&lt;br /&gt;
==Plan of work==&lt;br /&gt;
&lt;br /&gt;
We began our work by examining the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file to understand its connection to the rest of the codebase. We then had detailed discussions with our mentor about the project's flow and structure. We organized our project requirements by difficulty levels, assigned tasks among the team, and began refactoring existing methods and creating new files as needed. We made sure to preserve the integrity of existing test cases while adding new ones where needed.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
&lt;br /&gt;
'''Issue #29:''' Removed redundant comments from &amp;lt;code&amp;gt;_review_rounds.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*'''Solution:'''The solution involved cleaning up the code by removing redundant and outdated comments that were no longer necessary or too specific, such as references to team name handling and hard-coded logic for a particular instructor. The code was also slightly refactored for better readability, including consistent use of quotes in HTML attributes and ERB tags.&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Removed_redundant_comments.jpg]] &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #5:''' The method &amp;lt;code&amp;gt;sort_reviewer_by_review_volume_desc&amp;lt;/code&amp;gt; should be generalized so that it can sort by any metric, not just review volume. Other metrics might include number of suggestions, or number of suggestions + number of problems detected. This method should not be counting the number of review rounds! Since other places in the code will need to know the number of review rounds, it should be calculated somewhere else in the system.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Methods involved:''' &amp;lt;code&amp;gt;sort_reviewer_by_review_volume_desc&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Problem:''' The current function, sort_reviewer_by_review_volume_desc, arranges reviewers in descending order based solely on review volume. This limited approach means it can't be applied to sorting by other metrics.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Solution:'''The idea is to create a more versatile approach by changing the name of &amp;lt;code&amp;gt;sort_reviewer_by_review_volume_desc&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;sort_reviewer_desc&amp;lt;/code&amp;gt; and allowing a metric argument for sorting reviewers, as demonstrated below. This modification was also applied to the &amp;lt;code&amp;gt;review_report&amp;lt;/code&amp;gt; section where it was originally used.&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:5_1.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Issue_Metrics5.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #6:''' make a separate file for for chart related elements in &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Methods involved:''' &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;br&amp;gt;&lt;br /&gt;
*'''Previous Code:''' The methods mentioned used to be included in the review_mapping_helper.rb file, but they should have been in their own helper file.&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Problem:''' These techniques carry out comparable functions in creating graphs and can be implemented as either distinct modules or mixins. Additionally, each method contains more than 30 lines, making them excessively lengthy.&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Solution:''' Created new module named 'Charts' withinthe same file. This way the chart helper methods are separated from review_mapping_helper where they are out of place and difficult for any developer to find. &amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Issue6.jpg]]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Issue6.2.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #7:''' Several methods for feedback_response_maps, check docs to manage this confusion&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Methods involved:''' &amp;lt;code&amp;gt; feedback_response_for_author()&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Previous Code:''' previous code had an ambiguous variable name&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Problem:''' The purpose of the variable was unclear.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Solution:''' Rename the variable to enhance its clarity and provide comments to explain its purpose clearly.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Issue7.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
This project involves refactoring, meaning that the original functionality should remain unchanged. Tasks included adding comments to existing code, altering variable names, and similar adjustments that didn't affect the test cases. When method names were modified or moved to different files, corresponding changes were made in the relevant RSpec files. All test cases passed successfully, indicating that the refactoring didn't break the existing functionality.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As part of this project, the following actions were taken to ensure '''test accuracy and full functionality''':&lt;br /&gt;
* RSpec files were updated to reflect the new service class structure.&lt;br /&gt;
* The test suite was run after each change to confirm that behavior remained consistent across helper and service files.&lt;br /&gt;
* New service classes were fully tested, achieving '''100% test coverage'''.&lt;br /&gt;
* The `ReviewMappingHelper` was thoroughly reviewed and maintained a high coverage rate of '''87.85%''', confirming strong existing test quality.&lt;br /&gt;
* All helper methods dependent on parameters like `@assignment` were validated to ensure they functioned correctly after being decoupled from instance variables.&lt;br /&gt;
* No failing or broken tests were introduced during or after the refactor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The image below shows the test cases are passing as well as most of the code climate issues were resolved.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Wiki5.jpg]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
! File&lt;br /&gt;
! % Covered&lt;br /&gt;
! Lines&lt;br /&gt;
! Relevant Lines&lt;br /&gt;
! Lines Covered&lt;br /&gt;
! Lines Missed&lt;br /&gt;
! Avg. Hits/Line&lt;br /&gt;
|-&lt;br /&gt;
| app/helpers/review_mapping_helper.rb&lt;br /&gt;
| 87.85%&lt;br /&gt;
| 319&lt;br /&gt;
| 181&lt;br /&gt;
| 159&lt;br /&gt;
| 22&lt;br /&gt;
| 3.5&lt;br /&gt;
|-&lt;br /&gt;
| app/services/chart_data_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 112&lt;br /&gt;
| 30&lt;br /&gt;
| 30&lt;br /&gt;
| 0&lt;br /&gt;
| 3.9&lt;br /&gt;
|-&lt;br /&gt;
| app/services/chart_initialization_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 34&lt;br /&gt;
| 22&lt;br /&gt;
| 22&lt;br /&gt;
| 0&lt;br /&gt;
| 243.4&lt;br /&gt;
|-&lt;br /&gt;
| app/services/review_report_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 53&lt;br /&gt;
| 26&lt;br /&gt;
| 26&lt;br /&gt;
| 0&lt;br /&gt;
| 11.9&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Spatel68</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2501:_Refactor_review_mapping_helper.rb&amp;diff=162099</id>
		<title>CSC/ECE 517 Spring 2025 - E2501: Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2501:_Refactor_review_mapping_helper.rb&amp;diff=162099"/>
		<updated>2025-03-23T21:29:46Z</updated>

		<summary type="html">&lt;p&gt;Spatel68: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team ==&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Janice Uwujaren &lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Katerina Vilkomir (evilkom)&lt;br /&gt;
* Smit Patel (spatel68)&lt;br /&gt;
* Kenil Patel (kpatel47)&lt;br /&gt;
&lt;br /&gt;
=== Relevant Links ===&lt;br /&gt;
* '''Link to Expertiza Repository:''' https://github.com/expertiza/expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Link to Forked Repository: ''' https://github.com/Kii4ka/expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* ''' Link to Pull Request: ''' &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Expertiza Background==&lt;br /&gt;
Expertiza is a Ruby on Rails framework-based open-source web application. It is kept up by NC State University employees and students. With the help of this program, instructors can fully manage the assignments and responsibilities assigned in their classes. Expertiza provides many strong features, such as subject addition, group creation, and peer review administration. It is a flexible platform that can manage many kinds of tasks. Users can consult the Expertiza wiki to get more in-depth details about the many capabilities that Expertiza offers.&lt;br /&gt;
&lt;br /&gt;
== About Helper ==&lt;br /&gt;
The review_mapping_helper is integral to the peer review process, handling tasks such as calculating review scores, managing submission statuses, generating reports, and displaying review metrics. However, the module is complex because it depends on numerous instance variables, like @assignment and @review_scores, and mixes business logic with view logic.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The tight coupling and unclear separation of concerns make the code difficult to understand, test, and manage. To improve the overall quality of the codebase, the goal of this project is to refactor to ensure that the required info is passed as parameters and to separate business logic from view-related logic.&lt;br /&gt;
&lt;br /&gt;
== What Needs To Be Done == &lt;br /&gt;
*''' Separation of Business Logic and Helpers.'''&lt;br /&gt;
** The get_data_for_review_report method in the ReviewMappingHelper module contains business logic. To improve separation of concerns, create a dedicated Review Report Service to handle calculations, allowing the helper class to focus on view-related logic.&lt;br /&gt;
** Similarly, the display_volume_metric_chart method includes business logic for generating chart data. A Chart Data Service should be introduced to manage these calculations, leaving the helper responsible for rendering.&lt;br /&gt;
** The Charts Module is tightly coupled with the helper class due to its reliance on initialize_chart_elements. To enhance modularity, a separate service object should handle chart initialization.&lt;br /&gt;
&lt;br /&gt;
*'''Improving Method Clarity and Consistency'''&lt;br /&gt;
**Some methods use inconsistent naming conventions (determine, get, obtain). Align method names with Ruby conventions—&amp;quot;get&amp;quot; is generally preferred.&lt;br /&gt;
**Methods like get_data_for_review_report rely on instance variables such as @assignment, assuming they are set beforehand. To improve clarity and reduce potential errors, pass these variables as parameters instead of assuming their existence.&lt;br /&gt;
&lt;br /&gt;
*'''Reducing Unnecessary Comments and Inline Styles'''&lt;br /&gt;
**Replace redundant comments with meaningful explanations that provide insight rather than restating what the code does.&lt;br /&gt;
**Remove these comments from _review_rounds.html.erb. They add no value. Also, remove any hardcoded values.&lt;br /&gt;
*** &amp;amp;lt;!-- Hard-coded Dr.Kidd's question to display link. --&amp;amp;gt;&lt;br /&gt;
*** &amp;amp;lt;!-- Later, we can create a hyperlink question type to deal with this situation. --&amp;amp;gt;&lt;br /&gt;
**The image_tag in _grade_and_comments_form.html.erb uses inline styles; these should be moved to a CSS stylesheet for better maintainability.&lt;br /&gt;
**The _reviewer_info.html.erb view also contains inline styles that should be extracted into a stylesheet.&lt;br /&gt;
&lt;br /&gt;
*'''Removing Unused and Inefficient Code'''&lt;br /&gt;
**The ReviewMappingHelper class contains commented-out code. If this code is no longer needed, delete it.&lt;br /&gt;
**Identify opportunities to use guard clauses to break out of methods early, reducing unnecessary nesting and improving readability.&lt;br /&gt;
*'''Efficient Database Queries'''&lt;br /&gt;
**Several views, such as _response_maps.html.erb and _review_rounds.html.erb, execute database queries directly within the view, making multiple database calls. This logic should be moved to the model, with the Controller passing pre-fetched data to the view.&lt;br /&gt;
**The _reviewer_info.html.erb view accesses session data directly, which should instead be retrieved from the Controller to uphold the Separation of Concerns principle.&lt;br /&gt;
*'''Testing and Code Validation'''&lt;br /&gt;
**Ensure all new Service Classes created for report calculations, chart data, and database queries are thoroughly tested.&lt;br /&gt;
**Review existing tests and fix any failing tests to ensure correctness.&lt;br /&gt;
**Ensure full test coverage for all helper methods.&lt;br /&gt;
*'''Clarify Hardcoded Logic'''&lt;br /&gt;
**The _reviewer_info.html.erb view references reviewer.id == 1, but the significance of this ID is unclear. Either document its importance or store it in a constant that makes sense for better readability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
The Refactoring pattern is essential to enhance code readability, maintainability, and adherence to best practices. By systematically restructuring code components, eliminating redundancies, and applying standard conventions, the Refactoring pattern ensures improved code quality and easier future modifications.&lt;br /&gt;
&lt;br /&gt;
==Plan of work==&lt;br /&gt;
&lt;br /&gt;
We began our work by examining the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file to understand its connection to the rest of the codebase. We then had detailed discussions with our mentor about the project's flow and structure. We organized our project requirements by difficulty levels, assigned tasks among the team, and began refactoring existing methods and creating new files as needed. We made sure to preserve the integrity of existing test cases while adding new ones where needed.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
&lt;br /&gt;
'''Issue #22:''' Removed redundant comments from &amp;lt;code&amp;gt;_review_rounds.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*'''Solution:'''The solution involved cleaning up the code by removing redundant and outdated comments that were no longer necessary or too specific, such as references to team name handling and hard-coded logic for a particular instructor. The code was also slightly refactored for better readability, including consistent use of quotes in HTML attributes and ERB tags. Additionally, the hard-coded check for a specific instructor and question ID was replaced with a more general conditional using a &amp;lt;code&amp;gt;hyperlink_question_id&amp;lt;/code&amp;gt; variable, making the code more maintainable and reusable without changing its original functionality. &amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Remove_redundant_comments.jpg]] &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #5:''' The method &amp;lt;code&amp;gt;sort_reviewer_by_review_volume_desc&amp;lt;/code&amp;gt; should be generalized so that it can sort by any metric, not just review volume. Other metrics might include number of suggestions, or number of suggestions + number of problems detected. This method should not be counting the number of review rounds! Since other places in the code will need to know the number of review rounds, it should be calculated somewhere else in the system.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Methods involved:''' &amp;lt;code&amp;gt;sort_reviewer_by_review_volume_desc&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Problem:''' The current function, sort_reviewer_by_review_volume_desc, arranges reviewers in descending order based solely on review volume. This limited approach means it can't be applied to sorting by other metrics.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Solution:'''The idea is to create a more versatile approach by changing the name of &amp;lt;code&amp;gt;sort_reviewer_by_review_volume_desc&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;sort_reviewer_desc&amp;lt;/code&amp;gt; and allowing a metric argument for sorting reviewers, as demonstrated below. This modification was also applied to the &amp;lt;code&amp;gt;review_report&amp;lt;/code&amp;gt; section where it was originally used.&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:5_1.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Issue_Metrics5.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #6:''' make a separate file for for chart related elements in &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Methods involved:''' &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;br&amp;gt;&lt;br /&gt;
*'''Previous Code:''' The methods mentioned used to be included in the review_mapping_helper.rb file, but they should have been in their own helper file.&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Problem:''' These techniques carry out comparable functions in creating graphs and can be implemented as either distinct modules or mixins. Additionally, each method contains more than 30 lines, making them excessively lengthy.&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Solution:''' Created new module named 'Charts' withinthe same file. This way the chart helper methods are separated from review_mapping_helper where they are out of place and difficult for any developer to find. &amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Issue6.jpg]]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Issue6.2.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #7:''' Several methods for feedback_response_maps, check docs to manage this confusion&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Methods involved:''' &amp;lt;code&amp;gt; feedback_response_for_author()&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Previous Code:''' previous code had an ambiguous variable name&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Problem:''' The purpose of the variable was unclear.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Solution:''' Rename the variable to enhance its clarity and provide comments to explain its purpose clearly.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Issue7.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
This project involves refactoring, meaning that the original functionality should remain unchanged. Tasks included adding comments to existing code, altering variable names, and similar adjustments that didn't affect the test cases. When method names were modified or moved to different files, corresponding changes were made in the relevant RSpec files. All test cases passed successfully, indicating that the refactoring didn't break the existing functionality.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As part of this project, the following actions were taken to ensure '''test accuracy and full functionality''':&lt;br /&gt;
* RSpec files were updated to reflect the new service class structure.&lt;br /&gt;
* The test suite was run after each change to confirm that behavior remained consistent across helper and service files.&lt;br /&gt;
* New service classes were fully tested, achieving '''100% test coverage'''.&lt;br /&gt;
* The `ReviewMappingHelper` was thoroughly reviewed and maintained a high coverage rate of '''87.85%''', confirming strong existing test quality.&lt;br /&gt;
* All helper methods dependent on parameters like `@assignment` were validated to ensure they functioned correctly after being decoupled from instance variables.&lt;br /&gt;
* No failing or broken tests were introduced during or after the refactor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The image below shows the test cases are passing as well as most of the code climate issues were resolved.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Wiki5.jpg]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
! File&lt;br /&gt;
! % Covered&lt;br /&gt;
! Lines&lt;br /&gt;
! Relevant Lines&lt;br /&gt;
! Lines Covered&lt;br /&gt;
! Lines Missed&lt;br /&gt;
! Avg. Hits/Line&lt;br /&gt;
|-&lt;br /&gt;
| app/helpers/review_mapping_helper.rb&lt;br /&gt;
| 87.85%&lt;br /&gt;
| 319&lt;br /&gt;
| 181&lt;br /&gt;
| 159&lt;br /&gt;
| 22&lt;br /&gt;
| 3.5&lt;br /&gt;
|-&lt;br /&gt;
| app/services/chart_data_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 112&lt;br /&gt;
| 30&lt;br /&gt;
| 30&lt;br /&gt;
| 0&lt;br /&gt;
| 3.9&lt;br /&gt;
|-&lt;br /&gt;
| app/services/chart_initialization_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 34&lt;br /&gt;
| 22&lt;br /&gt;
| 22&lt;br /&gt;
| 0&lt;br /&gt;
| 243.4&lt;br /&gt;
|-&lt;br /&gt;
| app/services/review_report_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 53&lt;br /&gt;
| 26&lt;br /&gt;
| 26&lt;br /&gt;
| 0&lt;br /&gt;
| 11.9&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Spatel68</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Removed_redundant_comments.jpg&amp;diff=162098</id>
		<title>File:Removed redundant comments.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Removed_redundant_comments.jpg&amp;diff=162098"/>
		<updated>2025-03-23T21:28:36Z</updated>

		<summary type="html">&lt;p&gt;Spatel68: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Spatel68</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2501:_Refactor_review_mapping_helper.rb&amp;diff=162097</id>
		<title>CSC/ECE 517 Spring 2025 - E2501: Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2501:_Refactor_review_mapping_helper.rb&amp;diff=162097"/>
		<updated>2025-03-23T21:27:42Z</updated>

		<summary type="html">&lt;p&gt;Spatel68: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team ==&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Janice Uwujaren &lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Katerina Vilkomir (evilkom)&lt;br /&gt;
* Smit Patel (spatel68)&lt;br /&gt;
* Kenil Patel (kpatel47)&lt;br /&gt;
&lt;br /&gt;
=== Relevant Links ===&lt;br /&gt;
* '''Link to Expertiza Repository:''' https://github.com/expertiza/expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Link to Forked Repository: ''' https://github.com/Kii4ka/expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* ''' Link to Pull Request: ''' &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Expertiza Background==&lt;br /&gt;
Expertiza is a Ruby on Rails framework-based open-source web application. It is kept up by NC State University employees and students. With the help of this program, instructors can fully manage the assignments and responsibilities assigned in their classes. Expertiza provides many strong features, such as subject addition, group creation, and peer review administration. It is a flexible platform that can manage many kinds of tasks. Users can consult the Expertiza wiki to get more in-depth details about the many capabilities that Expertiza offers.&lt;br /&gt;
&lt;br /&gt;
== About Helper ==&lt;br /&gt;
The review_mapping_helper is integral to the peer review process, handling tasks such as calculating review scores, managing submission statuses, generating reports, and displaying review metrics. However, the module is complex because it depends on numerous instance variables, like @assignment and @review_scores, and mixes business logic with view logic.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The tight coupling and unclear separation of concerns make the code difficult to understand, test, and manage. To improve the overall quality of the codebase, the goal of this project is to refactor to ensure that the required info is passed as parameters and to separate business logic from view-related logic.&lt;br /&gt;
&lt;br /&gt;
== What Needs To Be Done == &lt;br /&gt;
*''' Separation of Business Logic and Helpers.'''&lt;br /&gt;
** The get_data_for_review_report method in the ReviewMappingHelper module contains business logic. To improve separation of concerns, create a dedicated Review Report Service to handle calculations, allowing the helper class to focus on view-related logic.&lt;br /&gt;
** Similarly, the display_volume_metric_chart method includes business logic for generating chart data. A Chart Data Service should be introduced to manage these calculations, leaving the helper responsible for rendering.&lt;br /&gt;
** The Charts Module is tightly coupled with the helper class due to its reliance on initialize_chart_elements. To enhance modularity, a separate service object should handle chart initialization.&lt;br /&gt;
&lt;br /&gt;
*'''Improving Method Clarity and Consistency'''&lt;br /&gt;
**Some methods use inconsistent naming conventions (determine, get, obtain). Align method names with Ruby conventions—&amp;quot;get&amp;quot; is generally preferred.&lt;br /&gt;
**Methods like get_data_for_review_report rely on instance variables such as @assignment, assuming they are set beforehand. To improve clarity and reduce potential errors, pass these variables as parameters instead of assuming their existence.&lt;br /&gt;
&lt;br /&gt;
*'''Reducing Unnecessary Comments and Inline Styles'''&lt;br /&gt;
**Replace redundant comments with meaningful explanations that provide insight rather than restating what the code does.&lt;br /&gt;
**Remove these comments from _review_rounds.html.erb. They add no value. Also, remove any hardcoded values.&lt;br /&gt;
*** &amp;amp;lt;!-- Hard-coded Dr.Kidd's question to display link. --&amp;amp;gt;&lt;br /&gt;
*** &amp;amp;lt;!-- Later, we can create a hyperlink question type to deal with this situation. --&amp;amp;gt;&lt;br /&gt;
**The image_tag in _grade_and_comments_form.html.erb uses inline styles; these should be moved to a CSS stylesheet for better maintainability.&lt;br /&gt;
**The _reviewer_info.html.erb view also contains inline styles that should be extracted into a stylesheet.&lt;br /&gt;
&lt;br /&gt;
*'''Removing Unused and Inefficient Code'''&lt;br /&gt;
**The ReviewMappingHelper class contains commented-out code. If this code is no longer needed, delete it.&lt;br /&gt;
**Identify opportunities to use guard clauses to break out of methods early, reducing unnecessary nesting and improving readability.&lt;br /&gt;
*'''Efficient Database Queries'''&lt;br /&gt;
**Several views, such as _response_maps.html.erb and _review_rounds.html.erb, execute database queries directly within the view, making multiple database calls. This logic should be moved to the model, with the Controller passing pre-fetched data to the view.&lt;br /&gt;
**The _reviewer_info.html.erb view accesses session data directly, which should instead be retrieved from the Controller to uphold the Separation of Concerns principle.&lt;br /&gt;
*'''Testing and Code Validation'''&lt;br /&gt;
**Ensure all new Service Classes created for report calculations, chart data, and database queries are thoroughly tested.&lt;br /&gt;
**Review existing tests and fix any failing tests to ensure correctness.&lt;br /&gt;
**Ensure full test coverage for all helper methods.&lt;br /&gt;
*'''Clarify Hardcoded Logic'''&lt;br /&gt;
**The _reviewer_info.html.erb view references reviewer.id == 1, but the significance of this ID is unclear. Either document its importance or store it in a constant that makes sense for better readability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
The Refactoring pattern is essential to enhance code readability, maintainability, and adherence to best practices. By systematically restructuring code components, eliminating redundancies, and applying standard conventions, the Refactoring pattern ensures improved code quality and easier future modifications.&lt;br /&gt;
&lt;br /&gt;
==Plan of work==&lt;br /&gt;
&lt;br /&gt;
We began our work by examining the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file to understand its connection to the rest of the codebase. We then had detailed discussions with our mentor about the project's flow and structure. We organized our project requirements by difficulty levels, assigned tasks among the team, and began refactoring existing methods and creating new files as needed. We made sure to preserve the integrity of existing test cases while adding new ones where needed.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
&lt;br /&gt;
'''Issue #22:''' Removed redundant comments from &amp;lt;code&amp;gt;_review_rounds.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
*'''Solution:'''The solution involved cleaning up the code by removing redundant and outdated comments that were no longer necessary or too specific, such as references to team name handling and hard-coded logic for a particular instructor. The code was also slightly refactored for better readability, including consistent use of quotes in HTML attributes and ERB tags. Additionally, the hard-coded check for a specific instructor and question ID was replaced with a more general conditional using a &amp;lt;code&amp;gt;hyperlink_question_id&amp;lt;/code&amp;gt; variable, making the code more maintainable and reusable without changing its original functionality. &amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Issue4.jpg]] &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #5:''' The method &amp;lt;code&amp;gt;sort_reviewer_by_review_volume_desc&amp;lt;/code&amp;gt; should be generalized so that it can sort by any metric, not just review volume. Other metrics might include number of suggestions, or number of suggestions + number of problems detected. This method should not be counting the number of review rounds! Since other places in the code will need to know the number of review rounds, it should be calculated somewhere else in the system.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Methods involved:''' &amp;lt;code&amp;gt;sort_reviewer_by_review_volume_desc&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Problem:''' The current function, sort_reviewer_by_review_volume_desc, arranges reviewers in descending order based solely on review volume. This limited approach means it can't be applied to sorting by other metrics.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Solution:'''The idea is to create a more versatile approach by changing the name of &amp;lt;code&amp;gt;sort_reviewer_by_review_volume_desc&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;sort_reviewer_desc&amp;lt;/code&amp;gt; and allowing a metric argument for sorting reviewers, as demonstrated below. This modification was also applied to the &amp;lt;code&amp;gt;review_report&amp;lt;/code&amp;gt; section where it was originally used.&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:5_1.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Issue_Metrics5.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #6:''' make a separate file for for chart related elements in &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Methods involved:''' &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;br&amp;gt;&lt;br /&gt;
*'''Previous Code:''' The methods mentioned used to be included in the review_mapping_helper.rb file, but they should have been in their own helper file.&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Problem:''' These techniques carry out comparable functions in creating graphs and can be implemented as either distinct modules or mixins. Additionally, each method contains more than 30 lines, making them excessively lengthy.&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Solution:''' Created new module named 'Charts' withinthe same file. This way the chart helper methods are separated from review_mapping_helper where they are out of place and difficult for any developer to find. &amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Issue6.jpg]]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Issue6.2.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #7:''' Several methods for feedback_response_maps, check docs to manage this confusion&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Methods involved:''' &amp;lt;code&amp;gt; feedback_response_for_author()&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Previous Code:''' previous code had an ambiguous variable name&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Problem:''' The purpose of the variable was unclear.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Solution:''' Rename the variable to enhance its clarity and provide comments to explain its purpose clearly.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Issue7.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
This project involves refactoring, meaning that the original functionality should remain unchanged. Tasks included adding comments to existing code, altering variable names, and similar adjustments that didn't affect the test cases. When method names were modified or moved to different files, corresponding changes were made in the relevant RSpec files. All test cases passed successfully, indicating that the refactoring didn't break the existing functionality.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As part of this project, the following actions were taken to ensure '''test accuracy and full functionality''':&lt;br /&gt;
* RSpec files were updated to reflect the new service class structure.&lt;br /&gt;
* The test suite was run after each change to confirm that behavior remained consistent across helper and service files.&lt;br /&gt;
* New service classes were fully tested, achieving '''100% test coverage'''.&lt;br /&gt;
* The `ReviewMappingHelper` was thoroughly reviewed and maintained a high coverage rate of '''87.85%''', confirming strong existing test quality.&lt;br /&gt;
* All helper methods dependent on parameters like `@assignment` were validated to ensure they functioned correctly after being decoupled from instance variables.&lt;br /&gt;
* No failing or broken tests were introduced during or after the refactor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The image below shows the test cases are passing as well as most of the code climate issues were resolved.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Wiki5.jpg]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
! File&lt;br /&gt;
! % Covered&lt;br /&gt;
! Lines&lt;br /&gt;
! Relevant Lines&lt;br /&gt;
! Lines Covered&lt;br /&gt;
! Lines Missed&lt;br /&gt;
! Avg. Hits/Line&lt;br /&gt;
|-&lt;br /&gt;
| app/helpers/review_mapping_helper.rb&lt;br /&gt;
| 87.85%&lt;br /&gt;
| 319&lt;br /&gt;
| 181&lt;br /&gt;
| 159&lt;br /&gt;
| 22&lt;br /&gt;
| 3.5&lt;br /&gt;
|-&lt;br /&gt;
| app/services/chart_data_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 112&lt;br /&gt;
| 30&lt;br /&gt;
| 30&lt;br /&gt;
| 0&lt;br /&gt;
| 3.9&lt;br /&gt;
|-&lt;br /&gt;
| app/services/chart_initialization_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 34&lt;br /&gt;
| 22&lt;br /&gt;
| 22&lt;br /&gt;
| 0&lt;br /&gt;
| 243.4&lt;br /&gt;
|-&lt;br /&gt;
| app/services/review_report_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 53&lt;br /&gt;
| 26&lt;br /&gt;
| 26&lt;br /&gt;
| 0&lt;br /&gt;
| 11.9&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Spatel68</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2501:_Refactor_review_mapping_helper.rb&amp;diff=162081</id>
		<title>CSC/ECE 517 Spring 2025 - E2501: Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2501:_Refactor_review_mapping_helper.rb&amp;diff=162081"/>
		<updated>2025-03-23T20:59:11Z</updated>

		<summary type="html">&lt;p&gt;Spatel68: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team ==&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Janice Uwujaren &lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Katerina Vilkomir (evilkom)&lt;br /&gt;
* Smit Patel (spatel68)&lt;br /&gt;
* Kenil Patel (kpatel47)&lt;br /&gt;
&lt;br /&gt;
=== Relevant Links ===&lt;br /&gt;
* '''Link to Expertiza Repository:''' https://github.com/expertiza/expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Link to Forked Repository: ''' https://github.com/Kii4ka/expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* ''' Link to Pull Request: ''' &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Expertiza Background==&lt;br /&gt;
Expertiza is a Ruby on Rails framework-based open-source web application. It is kept up by NC State University employees and students. With the help of this program, instructors can fully manage the assignments and responsibilities assigned in their classes. Expertiza provides many strong features, such as subject addition, group creation, and peer review administration. It is a flexible platform that can manage many kinds of tasks. Users can consult the Expertiza wiki to get more in-depth details about the many capabilities that Expertiza offers.&lt;br /&gt;
&lt;br /&gt;
== About Helper ==&lt;br /&gt;
The review_mapping_helper is integral to the peer review process, handling tasks such as calculating review scores, managing submission statuses, generating reports, and displaying review metrics. However, the module is complex because it depends on numerous instance variables, like @assignment and @review_scores, and mixes business logic with view logic.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The tight coupling and unclear separation of concerns make the code difficult to understand, test, and manage. To improve the overall quality of the codebase, the goal of this project is to refactor to ensure that the required info is passed as parameters and to separate business logic from view-related logic.&lt;br /&gt;
&lt;br /&gt;
== What Needs To Be Done == &lt;br /&gt;
*''' Separation of Business Logic and Helpers.'''&lt;br /&gt;
** The get_data_for_review_report method in the ReviewMappingHelper module contains business logic. To improve separation of concerns, create a dedicated Review Report Service to handle calculations, allowing the helper class to focus on view-related logic.&lt;br /&gt;
** Similarly, the display_volume_metric_chart method includes business logic for generating chart data. A Chart Data Service should be introduced to manage these calculations, leaving the helper responsible for rendering.&lt;br /&gt;
** The Charts Module is tightly coupled with the helper class due to its reliance on initialize_chart_elements. To enhance modularity, a separate service object should handle chart initialization.&lt;br /&gt;
&lt;br /&gt;
*'''Improving Method Clarity and Consistency'''&lt;br /&gt;
**Some methods use inconsistent naming conventions (determine, get, obtain). Align method names with Ruby conventions—&amp;quot;get&amp;quot; is generally preferred.&lt;br /&gt;
**Methods like get_data_for_review_report rely on instance variables such as @assignment, assuming they are set beforehand. To improve clarity and reduce potential errors, pass these variables as parameters instead of assuming their existence.&lt;br /&gt;
&lt;br /&gt;
*'''Reducing Unnecessary Comments and Inline Styles'''&lt;br /&gt;
**Replace redundant comments with meaningful explanations that provide insight rather than restating what the code does.&lt;br /&gt;
**Remove these comments from _review_rounds.html.erb. They add no value. Also, remove any hardcoded values.&lt;br /&gt;
*** &amp;amp;lt;!-- Hard-coded Dr.Kidd's question to display link. --&amp;amp;gt;&lt;br /&gt;
*** &amp;amp;lt;!-- Later, we can create a hyperlink question type to deal with this situation. --&amp;amp;gt;&lt;br /&gt;
**The image_tag in _grade_and_comments_form.html.erb uses inline styles; these should be moved to a CSS stylesheet for better maintainability.&lt;br /&gt;
**The _reviewer_info.html.erb view also contains inline styles that should be extracted into a stylesheet.&lt;br /&gt;
&lt;br /&gt;
*'''Removing Unused and Inefficient Code'''&lt;br /&gt;
**The ReviewMappingHelper class contains commented-out code. If this code is no longer needed, delete it.&lt;br /&gt;
**Identify opportunities to use guard clauses to break out of methods early, reducing unnecessary nesting and improving readability.&lt;br /&gt;
*'''Efficient Database Queries'''&lt;br /&gt;
**Several views, such as _response_maps.html.erb and _review_rounds.html.erb, execute database queries directly within the view, making multiple database calls. This logic should be moved to the model, with the Controller passing pre-fetched data to the view.&lt;br /&gt;
**The _reviewer_info.html.erb view accesses session data directly, which should instead be retrieved from the Controller to uphold the Separation of Concerns principle.&lt;br /&gt;
*Testing and Code Validation&lt;br /&gt;
**Ensure all new Service Classes created for report calculations, chart data, and database queries are thoroughly tested.&lt;br /&gt;
**Review existing tests and fix any failing tests to ensure correctness.&lt;br /&gt;
**Ensure full test coverage for all helper methods.&lt;br /&gt;
*'''Clarify Hardcoded Logic'''&lt;br /&gt;
**The _reviewer_info.html.erb view references reviewer.id == 1, but the significance of this ID is unclear. Either document its importance or store it in a constant that makes sense for better readability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== Phase 1 ===&lt;br /&gt;
&lt;br /&gt;
==== Refactor the &amp;lt;code&amp;gt;`get_data_for_review_report`&amp;lt;/code&amp;gt; method ====&lt;br /&gt;
[[File:t1.jpg|750px]]&lt;br /&gt;
&lt;br /&gt;
==== Refactor the &amp;lt;code&amp;gt;`color-related`&amp;lt;/code&amp;gt; methods ====&lt;br /&gt;
[[File:t2.jpg|750px]]&lt;br /&gt;
&lt;br /&gt;
==== Rename methods starting with &amp;lt;code&amp;gt;`get`&amp;lt;/code&amp;gt; to adhere to Ruby conventions methods ====&lt;br /&gt;
[[File:t3.jpg|750px]]&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
The Refactoring pattern is essential to enhance code readability, maintainability, and adherence to best practices. By systematically restructuring code components, eliminating redundancies, and applying standard conventions, the Refactoring pattern ensures improved code quality and easier future modifications.&lt;br /&gt;
&lt;br /&gt;
==Plan of work==&lt;br /&gt;
&lt;br /&gt;
We began our work by examining the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file to understand its connection to the rest of the codebase. We then had detailed discussions with our mentor about the project's flow and structure. We organized our project requirements by difficulty levels, assigned tasks among the team, and began refactoring existing methods and creating new files as needed. We made sure to preserve the integrity of existing test cases while adding new ones where needed.&lt;br /&gt;
&lt;br /&gt;
=='''Project 4 - DESIGN DOC'''==&lt;br /&gt;
We have been assigned below-cited changes to do after project 3&lt;br /&gt;
&lt;br /&gt;
===4. Refactoring get_awarded_review_score Method:===&lt;br /&gt;
* Standardize the score-calculation logic to ensure consistency and readability.&amp;lt;br/&amp;gt;&lt;br /&gt;
* Break down complex calculations into smaller, more understandable components.&amp;lt;br/&amp;gt;&lt;br /&gt;
* Improve method documentation and clarity to enhance understanding.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===5. Generalizing sort_reviewer_by_review_volume_desc:===&lt;br /&gt;
* Modify the method to accept flexible sorting metrics, enabling customization based on various criteria.&amp;lt;br/&amp;gt;&lt;br /&gt;
* Update method documentation to reflect the changes and provide usage guidelines.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===6. Code Organization Enhancements:===&lt;br /&gt;
* Extract chart-generating methods into separate modules or classes for better organization and reusability.&amp;lt;br/&amp;gt;&lt;br /&gt;
* Evaluate the necessity of list_review_submissions method based on insights from the Expertiza wiki and refactor accordingly.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===7. Documentation and Clarity Improvements:===&lt;br /&gt;
* Review methods related to feedback_response_maps and add comments or refactor small classes to enhance clarity and documentation.&amp;lt;br/&amp;gt;&lt;br /&gt;
* Ensure consistent naming conventions and adherence to coding standards throughout the codebase.&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''This section contains changes and contributions to Project 4'''&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #4:''' Method &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; needs to be refactored&lt;br /&gt;
*'''Methods involved:''' &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Solution:'''After addressing Issue 2, the method was renamed to &amp;lt;code&amp;gt;determine_awarded_review_score&amp;lt;/code&amp;gt; to align with Ruby conventions. Additionally, redundant instance variable settings were moved inside the loop to streamline the code. The explicit nil or -1.0 checks were eliminated and integrated into the &amp;lt;code&amp;gt;instance_variable_set&amp;lt;/code&amp;gt; line. &amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Issue4.jpg]] &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #5:''' The method &amp;lt;code&amp;gt;sort_reviewer_by_review_volume_desc&amp;lt;/code&amp;gt; should be generalized so that it can sort by any metric, not just review volume. Other metrics might include number of suggestions, or number of suggestions + number of problems detected. This method should not be counting the number of review rounds! Since other places in the code will need to know the number of review rounds, it should be calculated somewhere else in the system.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Methods involved:''' &amp;lt;code&amp;gt;sort_reviewer_by_review_volume_desc&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Problem:''' The current function, sort_reviewer_by_review_volume_desc, arranges reviewers in descending order based solely on review volume. This limited approach means it can't be applied to sorting by other metrics.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Solution:'''The idea is to create a more versatile approach by changing the name of &amp;lt;code&amp;gt;sort_reviewer_by_review_volume_desc&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;sort_reviewer_desc&amp;lt;/code&amp;gt; and allowing a metric argument for sorting reviewers, as demonstrated below. This modification was also applied to the &amp;lt;code&amp;gt;review_report&amp;lt;/code&amp;gt; section where it was originally used.&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:5_1.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Issue_Metrics5.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #6:''' make a separate file for for chart related elements in &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Methods involved:''' &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;br&amp;gt;&lt;br /&gt;
*'''Previous Code:''' The methods mentioned used to be included in the review_mapping_helper.rb file, but they should have been in their own helper file.&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Problem:''' These techniques carry out comparable functions in creating graphs and can be implemented as either distinct modules or mixins. Additionally, each method contains more than 30 lines, making them excessively lengthy.&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Solution:''' Created new module named 'Charts' withinthe same file. This way the chart helper methods are separated from review_mapping_helper where they are out of place and difficult for any developer to find. &amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Issue6.jpg]]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Issue6.2.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #7:''' Several methods for feedback_response_maps, check docs to manage this confusion&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Methods involved:''' &amp;lt;code&amp;gt; feedback_response_for_author()&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Previous Code:''' previous code had an ambiguous variable name&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Problem:''' The purpose of the variable was unclear.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Solution:''' Rename the variable to enhance its clarity and provide comments to explain its purpose clearly.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Issue7.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
This project involves refactoring, meaning that the original functionality should remain unchanged. Tasks included adding comments to existing code, altering variable names, and similar adjustments that didn't affect the test cases. When method names were modified or moved to different files, corresponding changes were made in the relevant RSpec files. All test cases passed successfully, indicating that the refactoring didn't break the existing functionality.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As part of this project, the following actions were taken to ensure '''test accuracy and full functionality''':&lt;br /&gt;
* RSpec files were updated to reflect the new service class structure.&lt;br /&gt;
* The test suite was run after each change to confirm that behavior remained consistent across helper and service files.&lt;br /&gt;
* New service classes were fully tested, achieving '''100% test coverage'''.&lt;br /&gt;
* The `ReviewMappingHelper` was thoroughly reviewed and maintained a high coverage rate of '''87.85%''', confirming strong existing test quality.&lt;br /&gt;
* All helper methods dependent on parameters like `@assignment` were validated to ensure they functioned correctly after being decoupled from instance variables.&lt;br /&gt;
* No failing or broken tests were introduced during or after the refactor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The image below shows the test cases are passing as well as most of the code climate issues were resolved.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Wiki5.jpg]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
! File&lt;br /&gt;
! % Covered&lt;br /&gt;
! Lines&lt;br /&gt;
! Relevant Lines&lt;br /&gt;
! Lines Covered&lt;br /&gt;
! Lines Missed&lt;br /&gt;
! Avg. Hits/Line&lt;br /&gt;
|-&lt;br /&gt;
| app/helpers/review_mapping_helper.rb&lt;br /&gt;
| 87.85%&lt;br /&gt;
| 319&lt;br /&gt;
| 181&lt;br /&gt;
| 159&lt;br /&gt;
| 22&lt;br /&gt;
| 3.5&lt;br /&gt;
|-&lt;br /&gt;
| app/services/chart_data_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 112&lt;br /&gt;
| 30&lt;br /&gt;
| 30&lt;br /&gt;
| 0&lt;br /&gt;
| 3.9&lt;br /&gt;
|-&lt;br /&gt;
| app/services/chart_initialization_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 34&lt;br /&gt;
| 22&lt;br /&gt;
| 22&lt;br /&gt;
| 0&lt;br /&gt;
| 243.4&lt;br /&gt;
|-&lt;br /&gt;
| app/services/review_report_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 53&lt;br /&gt;
| 26&lt;br /&gt;
| 26&lt;br /&gt;
| 0&lt;br /&gt;
| 11.9&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Spatel68</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2501:_Refactor_review_mapping_helper.rb&amp;diff=162079</id>
		<title>CSC/ECE 517 Spring 2025 - E2501: Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2501:_Refactor_review_mapping_helper.rb&amp;diff=162079"/>
		<updated>2025-03-23T20:57:57Z</updated>

		<summary type="html">&lt;p&gt;Spatel68: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team ==&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Janice Uwujaren &lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Katerina Vilkomir (evilkom)&lt;br /&gt;
* Smit Patel (spatel68)&lt;br /&gt;
* Kenil Patel (kpatel47)&lt;br /&gt;
&lt;br /&gt;
=== Relevant Links ===&lt;br /&gt;
* '''Link to Expertiza Repository:''' https://github.com/expertiza/expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Link to Forked Repository: ''' https://github.com/Kii4ka/expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* ''' Link to Pull Request: ''' &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Expertiza Background==&lt;br /&gt;
Expertiza is a Ruby on Rails framework-based open-source web application. It is kept up by NC State University employees and students. With the help of this program, instructors can fully manage the assignments and responsibilities assigned in their classes. Expertiza provides many strong features, such as subject addition, group creation, and peer review administration. It is a flexible platform that can manage many kinds of tasks. Users can consult the Expertiza wiki to get more in-depth details about the many capabilities that Expertiza offers.&lt;br /&gt;
&lt;br /&gt;
== About Helper ==&lt;br /&gt;
The review_mapping_helper is integral to the peer review process, handling tasks such as calculating review scores, managing submission statuses, generating reports, and displaying review metrics. However, the module is complex because it depends on numerous instance variables, like @assignment and @review_scores, and mixes business logic with view logic.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The tight coupling and unclear separation of concerns make the code difficult to understand, test, and manage. To improve the overall quality of the codebase, the goal of this project is to refactor to ensure that the required info is passed as parameters and to separate business logic from view-related logic.&lt;br /&gt;
&lt;br /&gt;
== What Needs To Be Done == &lt;br /&gt;
* Separation of Business Logic and Helpers.&lt;br /&gt;
** The get_data_for_review_report method in the ReviewMappingHelper module contains business logic. To improve separation of concerns, create a dedicated Review Report Service to handle calculations, allowing the helper class to focus on view-related logic.&lt;br /&gt;
** Similarly, the display_volume_metric_chart method includes business logic for generating chart data. A Chart Data Service should be introduced to manage these calculations, leaving the helper responsible for rendering.&lt;br /&gt;
** The Charts Module is tightly coupled with the helper class due to its reliance on initialize_chart_elements. To enhance modularity, a separate service object should handle chart initialization.&lt;br /&gt;
&lt;br /&gt;
*Improving Method Clarity and Consistency&lt;br /&gt;
**Some methods use inconsistent naming conventions (determine, get, obtain). Align method names with Ruby conventions—&amp;quot;get&amp;quot; is generally preferred.&lt;br /&gt;
**Methods like get_data_for_review_report rely on instance variables such as @assignment, assuming they are set beforehand. To improve clarity and reduce potential errors, pass these variables as parameters instead of assuming their existence.&lt;br /&gt;
&lt;br /&gt;
*Reducing Unnecessary Comments and Inline Styles&lt;br /&gt;
**Replace redundant comments with meaningful explanations that provide insight rather than restating what the code does.&lt;br /&gt;
**Remove these comments from _review_rounds.html.erb. They add no value. Also, remove any hardcoded values.&lt;br /&gt;
*** &amp;amp;lt;!-- Hard-coded Dr.Kidd's question to display link. --&amp;amp;gt;&lt;br /&gt;
*** &amp;amp;lt;!-- Later, we can create a hyperlink question type to deal with this situation. --&amp;amp;gt;&lt;br /&gt;
**The image_tag in _grade_and_comments_form.html.erb uses inline styles; these should be moved to a CSS stylesheet for better maintainability.&lt;br /&gt;
**The _reviewer_info.html.erb view also contains inline styles that should be extracted into a stylesheet.&lt;br /&gt;
*Removing Unused and Inefficient Code&lt;br /&gt;
**The ReviewMappingHelper class contains commented-out code. If this code is no longer needed, delete it.&lt;br /&gt;
**Identify opportunities to use guard clauses to break out of methods early, reducing unnecessary nesting and improving readability.&lt;br /&gt;
Efficient Database Queries&lt;br /&gt;
**Several views, such as _response_maps.html.erb and _review_rounds.html.erb, execute database queries directly within the view, making multiple database calls. This logic should be moved to the model, with the Controller passing pre-fetched data to the view.&lt;br /&gt;
**The _reviewer_info.html.erb view accesses session data directly, which should instead be retrieved from the Controller to uphold the Separation of Concerns principle.&lt;br /&gt;
*Testing and Code Validation&lt;br /&gt;
**Ensure all new Service Classes created for report calculations, chart data, and database queries are thoroughly tested.&lt;br /&gt;
**Review existing tests and fix any failing tests to ensure correctness.&lt;br /&gt;
**Ensure full test coverage for all helper methods.&lt;br /&gt;
*Clarify Hardcoded Logic&lt;br /&gt;
**The _reviewer_info.html.erb view references reviewer.id == 1, but the significance of this ID is unclear. Either document its importance or store it in a constant that makes sense for better readability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== Phase 1 ===&lt;br /&gt;
&lt;br /&gt;
==== Refactor the &amp;lt;code&amp;gt;`get_data_for_review_report`&amp;lt;/code&amp;gt; method ====&lt;br /&gt;
[[File:t1.jpg|750px]]&lt;br /&gt;
&lt;br /&gt;
==== Refactor the &amp;lt;code&amp;gt;`color-related`&amp;lt;/code&amp;gt; methods ====&lt;br /&gt;
[[File:t2.jpg|750px]]&lt;br /&gt;
&lt;br /&gt;
==== Rename methods starting with &amp;lt;code&amp;gt;`get`&amp;lt;/code&amp;gt; to adhere to Ruby conventions methods ====&lt;br /&gt;
[[File:t3.jpg|750px]]&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
The Refactoring pattern is essential to enhance code readability, maintainability, and adherence to best practices. By systematically restructuring code components, eliminating redundancies, and applying standard conventions, the Refactoring pattern ensures improved code quality and easier future modifications.&lt;br /&gt;
&lt;br /&gt;
==Plan of work==&lt;br /&gt;
&lt;br /&gt;
We began our work by examining the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file to understand its connection to the rest of the codebase. We then had detailed discussions with our mentor about the project's flow and structure. We organized our project requirements by difficulty levels, assigned tasks among the team, and began refactoring existing methods and creating new files as needed. We made sure to preserve the integrity of existing test cases while adding new ones where needed.&lt;br /&gt;
&lt;br /&gt;
=='''Project 4 - DESIGN DOC'''==&lt;br /&gt;
We have been assigned below-cited changes to do after project 3&lt;br /&gt;
&lt;br /&gt;
===4. Refactoring get_awarded_review_score Method:===&lt;br /&gt;
* Standardize the score-calculation logic to ensure consistency and readability.&amp;lt;br/&amp;gt;&lt;br /&gt;
* Break down complex calculations into smaller, more understandable components.&amp;lt;br/&amp;gt;&lt;br /&gt;
* Improve method documentation and clarity to enhance understanding.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===5. Generalizing sort_reviewer_by_review_volume_desc:===&lt;br /&gt;
* Modify the method to accept flexible sorting metrics, enabling customization based on various criteria.&amp;lt;br/&amp;gt;&lt;br /&gt;
* Update method documentation to reflect the changes and provide usage guidelines.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===6. Code Organization Enhancements:===&lt;br /&gt;
* Extract chart-generating methods into separate modules or classes for better organization and reusability.&amp;lt;br/&amp;gt;&lt;br /&gt;
* Evaluate the necessity of list_review_submissions method based on insights from the Expertiza wiki and refactor accordingly.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===7. Documentation and Clarity Improvements:===&lt;br /&gt;
* Review methods related to feedback_response_maps and add comments or refactor small classes to enhance clarity and documentation.&amp;lt;br/&amp;gt;&lt;br /&gt;
* Ensure consistent naming conventions and adherence to coding standards throughout the codebase.&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''This section contains changes and contributions to Project 4'''&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #4:''' Method &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; needs to be refactored&lt;br /&gt;
*'''Methods involved:''' &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Solution:'''After addressing Issue 2, the method was renamed to &amp;lt;code&amp;gt;determine_awarded_review_score&amp;lt;/code&amp;gt; to align with Ruby conventions. Additionally, redundant instance variable settings were moved inside the loop to streamline the code. The explicit nil or -1.0 checks were eliminated and integrated into the &amp;lt;code&amp;gt;instance_variable_set&amp;lt;/code&amp;gt; line. &amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Issue4.jpg]] &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #5:''' The method &amp;lt;code&amp;gt;sort_reviewer_by_review_volume_desc&amp;lt;/code&amp;gt; should be generalized so that it can sort by any metric, not just review volume. Other metrics might include number of suggestions, or number of suggestions + number of problems detected. This method should not be counting the number of review rounds! Since other places in the code will need to know the number of review rounds, it should be calculated somewhere else in the system.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Methods involved:''' &amp;lt;code&amp;gt;sort_reviewer_by_review_volume_desc&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Problem:''' The current function, sort_reviewer_by_review_volume_desc, arranges reviewers in descending order based solely on review volume. This limited approach means it can't be applied to sorting by other metrics.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Solution:'''The idea is to create a more versatile approach by changing the name of &amp;lt;code&amp;gt;sort_reviewer_by_review_volume_desc&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;sort_reviewer_desc&amp;lt;/code&amp;gt; and allowing a metric argument for sorting reviewers, as demonstrated below. This modification was also applied to the &amp;lt;code&amp;gt;review_report&amp;lt;/code&amp;gt; section where it was originally used.&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:5_1.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Issue_Metrics5.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #6:''' make a separate file for for chart related elements in &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Methods involved:''' &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;br&amp;gt;&lt;br /&gt;
*'''Previous Code:''' The methods mentioned used to be included in the review_mapping_helper.rb file, but they should have been in their own helper file.&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Problem:''' These techniques carry out comparable functions in creating graphs and can be implemented as either distinct modules or mixins. Additionally, each method contains more than 30 lines, making them excessively lengthy.&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Solution:''' Created new module named 'Charts' withinthe same file. This way the chart helper methods are separated from review_mapping_helper where they are out of place and difficult for any developer to find. &amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Issue6.jpg]]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Issue6.2.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #7:''' Several methods for feedback_response_maps, check docs to manage this confusion&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Methods involved:''' &amp;lt;code&amp;gt; feedback_response_for_author()&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Previous Code:''' previous code had an ambiguous variable name&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Problem:''' The purpose of the variable was unclear.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Solution:''' Rename the variable to enhance its clarity and provide comments to explain its purpose clearly.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Issue7.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
This project involves refactoring, meaning that the original functionality should remain unchanged. Tasks included adding comments to existing code, altering variable names, and similar adjustments that didn't affect the test cases. When method names were modified or moved to different files, corresponding changes were made in the relevant RSpec files. All test cases passed successfully, indicating that the refactoring didn't break the existing functionality.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As part of this project, the following actions were taken to ensure '''test accuracy and full functionality''':&lt;br /&gt;
* RSpec files were updated to reflect the new service class structure.&lt;br /&gt;
* The test suite was run after each change to confirm that behavior remained consistent across helper and service files.&lt;br /&gt;
* New service classes were fully tested, achieving '''100% test coverage'''.&lt;br /&gt;
* The `ReviewMappingHelper` was thoroughly reviewed and maintained a high coverage rate of '''87.85%''', confirming strong existing test quality.&lt;br /&gt;
* All helper methods dependent on parameters like `@assignment` were validated to ensure they functioned correctly after being decoupled from instance variables.&lt;br /&gt;
* No failing or broken tests were introduced during or after the refactor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The image below shows the test cases are passing as well as most of the code climate issues were resolved.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Wiki5.jpg]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
! File&lt;br /&gt;
! % Covered&lt;br /&gt;
! Lines&lt;br /&gt;
! Relevant Lines&lt;br /&gt;
! Lines Covered&lt;br /&gt;
! Lines Missed&lt;br /&gt;
! Avg. Hits/Line&lt;br /&gt;
|-&lt;br /&gt;
| app/helpers/review_mapping_helper.rb&lt;br /&gt;
| 87.85%&lt;br /&gt;
| 319&lt;br /&gt;
| 181&lt;br /&gt;
| 159&lt;br /&gt;
| 22&lt;br /&gt;
| 3.5&lt;br /&gt;
|-&lt;br /&gt;
| app/services/chart_data_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 112&lt;br /&gt;
| 30&lt;br /&gt;
| 30&lt;br /&gt;
| 0&lt;br /&gt;
| 3.9&lt;br /&gt;
|-&lt;br /&gt;
| app/services/chart_initialization_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 34&lt;br /&gt;
| 22&lt;br /&gt;
| 22&lt;br /&gt;
| 0&lt;br /&gt;
| 243.4&lt;br /&gt;
|-&lt;br /&gt;
| app/services/review_report_service.rb&lt;br /&gt;
| 100.00%&lt;br /&gt;
| 53&lt;br /&gt;
| 26&lt;br /&gt;
| 26&lt;br /&gt;
| 0&lt;br /&gt;
| 11.9&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Spatel68</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2501:_Refactor_review_mapping_helper.rb&amp;diff=161612</id>
		<title>CSC/ECE 517 Spring 2025 - E2501: Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2501:_Refactor_review_mapping_helper.rb&amp;diff=161612"/>
		<updated>2025-03-23T00:41:04Z</updated>

		<summary type="html">&lt;p&gt;Spatel68: Created page with &amp;quot;== Team == === Mentor === * Janice Uwujaren   === Team Members === * katerina Vilkomir () * Smit Patel (spatel68) * Kenil Patel ()  === Relevant Links === * '''Link to Expertiza Repository:''' https://github.com/expertiza/expertiza &amp;lt;br&amp;gt;  * '''Link to Forked Repository: ''' https://github.com/Kii4ka/expertiza &amp;lt;br&amp;gt;  * ''' Link to Pull Request: ''' &amp;lt;br&amp;gt;  == Expertiza Background== Expertiza is a Ruby on Rails framework-based open-source web application. It is kept up by NC S...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Team ==&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Janice Uwujaren &lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* katerina Vilkomir ()&lt;br /&gt;
* Smit Patel (spatel68)&lt;br /&gt;
* Kenil Patel ()&lt;br /&gt;
&lt;br /&gt;
=== Relevant Links ===&lt;br /&gt;
* '''Link to Expertiza Repository:''' https://github.com/expertiza/expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Link to Forked Repository: ''' https://github.com/Kii4ka/expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* ''' Link to Pull Request: ''' &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Expertiza Background==&lt;br /&gt;
Expertiza is a Ruby on Rails framework-based open-source web application. It is kept up by NC State University employees and students. With the help of this program, instructors can fully manage the assignments and responsibilities assigned in their classes. Expertiza provides many strong features, such as subject addition, group creation, and peer review administration. It is a flexible platform that can manage many kinds of tasks. Users can consult the Expertiza wiki to get more in-depth details about the many capabilities that Expertiza offers.&lt;br /&gt;
&lt;br /&gt;
== About Helper ==&lt;br /&gt;
The review_mapping_helper is integral to the peer review process, handling tasks such as calculating review scores, managing submission statuses, generating reports, and displaying review metrics. However, the module is complex because it depends on numerous instance variables, like @assignment and @review_scores, and mixes business logic with view logic.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The tight coupling and unclear separation of concerns make the code difficult to understand, test, and manage. To improve the overall quality of the codebase, the goal of this project is to refactor to ensure that the required info is passed as parameters and to separate business logic from view-related logic.&lt;br /&gt;
&lt;br /&gt;
== What Needs To Be Done == &lt;br /&gt;
* Separation of Business Logic and Helpers.&lt;br /&gt;
** The get_data_for_review_report method in the ReviewMappingHelper module contains business logic. To improve separation of concerns, create a dedicated Review Report Service to handle calculations, allowing the helper class to focus on view-related logic.&lt;br /&gt;
** Similarly, the display_volume_metric_chart method includes business logic for generating chart data. A Chart Data Service should be introduced to manage these calculations, leaving the helper responsible for rendering.&lt;br /&gt;
** The Charts Module is tightly coupled with the helper class due to its reliance on initialize_chart_elements. To enhance modularity, a separate service object should handle chart initialization.&lt;br /&gt;
&lt;br /&gt;
*Improving Method Clarity and Consistency&lt;br /&gt;
**Some methods use inconsistent naming conventions (determine, get, obtain). Align method names with Ruby conventions—&amp;quot;get&amp;quot; is generally preferred.&lt;br /&gt;
**Methods like get_data_for_review_report rely on instance variables such as @assignment, assuming they are set beforehand. To improve clarity and reduce potential errors, pass these variables as parameters instead of assuming their existence.&lt;br /&gt;
&lt;br /&gt;
*Reducing Unnecessary Comments and Inline Styles&lt;br /&gt;
**Replace redundant comments with meaningful explanations that provide insight rather than restating what the code does.&lt;br /&gt;
**Remove these comments from _review_rounds.html.erb. They add no value. Also, remove any hardcoded values.&lt;br /&gt;
***&amp;lt;!-- Hard-coded Dr.Kidd's question to display link. --&amp;gt;&lt;br /&gt;
***&amp;lt;!-- Later, we can create a hyperlink question type to deal with this situation. &lt;br /&gt;
***The image_tag in _grade_and_comments_form.html.erb uses inline styles; these should be moved to a CSS stylesheet for better maintainability.&lt;br /&gt;
***The _reviewer_info.html.erb view also contains inline styles that should be extracted into a stylesheet.&lt;br /&gt;
*Removing Unused and Inefficient Code&lt;br /&gt;
The ReviewMappingHelper class contains commented-out code. If this code is no longer needed, delete it.&lt;br /&gt;
Identify opportunities to use guard clauses to break out of methods early, reducing unnecessary nesting and improving readability.&lt;br /&gt;
Efficient Database Queries&lt;br /&gt;
Several views, such as _response_maps.html.erb and _review_rounds.html.erb, execute database queries directly within the view, making multiple database calls. This logic should be moved to the model, with the Controller passing pre-fetched data to the view.&lt;br /&gt;
The _reviewer_info.html.erb view accesses session data directly, which should instead be retrieved from the Controller to uphold the Separation of Concerns principle.&lt;br /&gt;
Testing and Code Validation&lt;br /&gt;
Ensure all new Service Classes created for report calculations, chart data, and database queries are thoroughly tested.&lt;br /&gt;
Review existing tests and fix any failing tests to ensure correctness.&lt;br /&gt;
Ensure full test coverage for all helper methods.&lt;br /&gt;
Clarify Hardcoded Logic&lt;br /&gt;
The _reviewer_info.html.erb view references reviewer.id == 1, but the significance of this ID is unclear. Either document its importance or store it in a constant that makes sense for better readability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== Phase 1 ===&lt;br /&gt;
&lt;br /&gt;
==== Refactor the &amp;lt;code&amp;gt;`get_data_for_review_report`&amp;lt;/code&amp;gt; method ====&lt;br /&gt;
[[File:t1.jpg|750px]]&lt;br /&gt;
&lt;br /&gt;
==== Refactor the &amp;lt;code&amp;gt;`color-related`&amp;lt;/code&amp;gt; methods ====&lt;br /&gt;
[[File:t2.jpg|750px]]&lt;br /&gt;
&lt;br /&gt;
==== Rename methods starting with &amp;lt;code&amp;gt;`get`&amp;lt;/code&amp;gt; to adhere to Ruby conventions methods ====&lt;br /&gt;
[[File:t3.jpg|750px]]&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
The Refactoring pattern is essential to enhance code readability, maintainability, and adherence to best practices. By systematically restructuring code components, eliminating redundancies, and applying standard conventions, the Refactoring pattern ensures improved code quality and easier future modifications.&lt;br /&gt;
&lt;br /&gt;
==Plan of work==&lt;br /&gt;
&lt;br /&gt;
We began our work by examining the &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt; file to understand its connection to the rest of the codebase. We then had detailed discussions with our mentor about the project's flow and structure. We organized our project requirements by difficulty levels, assigned tasks among the team, and began refactoring existing methods and creating new files as needed. We made sure to preserve the integrity of existing test cases while adding new ones where needed.&lt;br /&gt;
&lt;br /&gt;
=='''Project 4 - DESIGN DOC'''==&lt;br /&gt;
We have been assigned below-cited changes to do after project 3&lt;br /&gt;
&lt;br /&gt;
===4. Refactoring get_awarded_review_score Method:===&lt;br /&gt;
* Standardize the score-calculation logic to ensure consistency and readability.&amp;lt;br/&amp;gt;&lt;br /&gt;
* Break down complex calculations into smaller, more understandable components.&amp;lt;br/&amp;gt;&lt;br /&gt;
* Improve method documentation and clarity to enhance understanding.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===5. Generalizing sort_reviewer_by_review_volume_desc:===&lt;br /&gt;
* Modify the method to accept flexible sorting metrics, enabling customization based on various criteria.&amp;lt;br/&amp;gt;&lt;br /&gt;
* Update method documentation to reflect the changes and provide usage guidelines.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===6. Code Organization Enhancements:===&lt;br /&gt;
* Extract chart-generating methods into separate modules or classes for better organization and reusability.&amp;lt;br/&amp;gt;&lt;br /&gt;
* Evaluate the necessity of list_review_submissions method based on insights from the Expertiza wiki and refactor accordingly.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===7. Documentation and Clarity Improvements:===&lt;br /&gt;
* Review methods related to feedback_response_maps and add comments or refactor small classes to enhance clarity and documentation.&amp;lt;br/&amp;gt;&lt;br /&gt;
* Ensure consistent naming conventions and adherence to coding standards throughout the codebase.&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''This section contains changes and contributions to Project 4'''&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #4:''' Method &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt; needs to be refactored&lt;br /&gt;
*'''Methods involved:''' &amp;lt;code&amp;gt;get_awarded_review_score&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Solution:'''After addressing Issue 2, the method was renamed to &amp;lt;code&amp;gt;determine_awarded_review_score&amp;lt;/code&amp;gt; to align with Ruby conventions. Additionally, redundant instance variable settings were moved inside the loop to streamline the code. The explicit nil or -1.0 checks were eliminated and integrated into the &amp;lt;code&amp;gt;instance_variable_set&amp;lt;/code&amp;gt; line. &amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Issue4.jpg]] &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #5:''' The method &amp;lt;code&amp;gt;sort_reviewer_by_review_volume_desc&amp;lt;/code&amp;gt; should be generalized so that it can sort by any metric, not just review volume. Other metrics might include number of suggestions, or number of suggestions + number of problems detected. This method should not be counting the number of review rounds! Since other places in the code will need to know the number of review rounds, it should be calculated somewhere else in the system.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Methods involved:''' &amp;lt;code&amp;gt;sort_reviewer_by_review_volume_desc&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Problem:''' The current function, sort_reviewer_by_review_volume_desc, arranges reviewers in descending order based solely on review volume. This limited approach means it can't be applied to sorting by other metrics.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Solution:'''The idea is to create a more versatile approach by changing the name of &amp;lt;code&amp;gt;sort_reviewer_by_review_volume_desc&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;sort_reviewer_desc&amp;lt;/code&amp;gt; and allowing a metric argument for sorting reviewers, as demonstrated below. This modification was also applied to the &amp;lt;code&amp;gt;review_report&amp;lt;/code&amp;gt; section where it was originally used.&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:5_1.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Issue_Metrics5.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #6:''' make a separate file for for chart related elements in &amp;lt;code&amp;gt;review_mapping_helper.rb&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Methods involved:''' &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;br&amp;gt;&lt;br /&gt;
*'''Previous Code:''' The methods mentioned used to be included in the review_mapping_helper.rb file, but they should have been in their own helper file.&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Problem:''' These techniques carry out comparable functions in creating graphs and can be implemented as either distinct modules or mixins. Additionally, each method contains more than 30 lines, making them excessively lengthy.&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Solution:''' Created new module named 'Charts' withinthe same file. This way the chart helper methods are separated from review_mapping_helper where they are out of place and difficult for any developer to find. &amp;lt;br&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Issue6.jpg]]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Issue6.2.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Issue #7:''' Several methods for feedback_response_maps, check docs to manage this confusion&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Methods involved:''' &amp;lt;code&amp;gt; feedback_response_for_author()&amp;lt;/code&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Previous Code:''' previous code had an ambiguous variable name&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Problem:''' The purpose of the variable was unclear.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Solution:''' Rename the variable to enhance its clarity and provide comments to explain its purpose clearly.&amp;lt;br/&amp;gt;&lt;br /&gt;
*'''Changes'''&lt;br /&gt;
[[File:Issue7.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
This project involves refactoring, meaning that the original functionality should remain unchanged. Tasks included adding comments to existing code, altering variable names, and similar adjustments that didn't affect the test cases. When method names were modified or moved to different files, corresponding changes were made in the relevant RSpec files. All test cases passed successfully, indicating that the refactoring didn't break the existing functionality.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;The image below shows the test cases are passing as well as most of the code climate issues were resolved.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Wiki5.jpg]]&lt;/div&gt;</summary>
		<author><name>Spatel68</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025&amp;diff=161593</id>
		<title>CSC/ECE 517 Spring 2025</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025&amp;diff=161593"/>
		<updated>2025-03-23T00:20:38Z</updated>

		<summary type="html">&lt;p&gt;Spatel68: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[CSC/ECE 517 Spring 2025 - E2504. Mentor-meeting management]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2505. Testing Answer Tagging]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2508. Reimplement bidding-algorithm web service]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2519. Implement view for results of bidding]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2522. Enhancing UI Consistency in Expertiza 1]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2520. Reimplement heatgrid UI for reviews]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2517. Reimplement internationalization (frontend + backend)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2523: Enhancing UI Consistency in Expertiza 2]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2515:  Reimplement student_teams_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2501:  Refactor review_mapping_helper.rb]]&lt;/div&gt;</summary>
		<author><name>Spatel68</name></author>
	</entry>
</feed>