IndependentStudy Visualizations

From Expertiza_Wiki
Jump to navigation Jump to search

Introduction

This project fixes the way graphs are represented in the review report. Expertiza interprets metrics in the form of a graph in the review report. This Project also refractors review_mapping_helper.rb.

Problem Statement

  • Currently, the bars in the graphs overlap and they are not positioned properly.
  • The legends (vol. and avg vol.) are present in every cell in the metrics column.
  • The current code assumes that there are no more than three rounds.
  • Refactored review_mapping_helper.rb.
  • Add comments to methods.

Files modified

app/assets/stylesheets/legend.css app/helpers/charts_helper.rb app/helpers/review_mapping_helper.rb app/views/reports/_calibration_report.html.erb app/views/reports/_feedback_report.html.erb app/views/reports/_review_report.html.erb app/views/reports/_team_score.html.erb

Solution

1. Currently, the bars in the graphs overlap and they are not positioned properly and the legends (vol. and avg vol.) are present in every cell in the metrics column. This change is present in the files - app/views/reports/_review_report.html.erb and app/helpers/review_mapping_helper.rb

Before


After


2. The current code assumes that there are no more than three rounds. Changes can be found in app/helpers/review_mapping_helper.rb

Before

 def initialize_chart_elements(reviewer)
   round = 0
   labels = []
   reviewer_data = []
   all_reviewers_data = []
   if @all_reviewers_avg_vol_in_round_1 > 0
     round += 1
     labels.push '1st'
     reviewer_data.push reviewer.avg_vol_in_round_1
     all_reviewers_data.push @all_reviewers_avg_vol_in_round_1
   end
   if @all_reviewers_avg_vol_in_round_2 > 0
     round += 1
     labels.push '2nd'
     reviewer_data.push reviewer.avg_vol_in_round_2
     all_reviewers_data.push @all_reviewers_avg_vol_in_round_2
   end
   if @all_reviewers_avg_vol_in_round_3 > 0
     round += 1
     labels.push '3rd'
     reviewer_data.push reviewer.avg_vol_in_round_3
     all_reviewers_data.push @all_reviewers_avg_vol_in_round_3
   end
   labels.push 'Total'
   reviewer_data.push reviewer.overall_avg_vol
   all_reviewers_data.push @all_reviewers_overall_avg_vol
   [labels, reviewer_data, all_reviewers_data]
 end

After

def initialize_chart_elements(reviewer)
   #round = 0
   labels = []
   reviewer_data = []
   all_reviewers_data = []
  
   (1..@assignment.num_review_rounds).each do |round_num|
     #round += 1
     labels.push round_num.to_s
     reviewer_data.push eval("reviewer.avg_vol_in_round_#{round_num}")
     all_reviewers_data.push instance_variable_get("@all_reviewers_avg_vol_in_round_#{round_num}")
   end
   labels.push 'Total'
   reviewer_data.push reviewer.overall_avg_vol
   all_reviewers_data.push @all_reviewers_overall_avg_vol
   [labels, reviewer_data, all_reviewers_data]
 end

3. Refractored review_mapping_helper.rb. Refactored review_mapping_helper.rb. Few of the changes are reducing the length of method names, adding comments, removing redundant code, adding string interpolation.

please see the pull request for detailed code. [1]