E1913 refactor review mapping helper: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
(Created page with "== '''Refactor ''review_mapping_helper.rb''''' == This page gives a description of the changes made for the ''review_mapping helper.rb'' of Expertiza based OSS project. ==Exper...")
 
mNo edit summary
Line 4: Line 4:


==Expertiza Background ==
==Expertiza Background ==
Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and grade the assignments submitted by students to Expertiza. Students can be assigned in teams based on their selection of the topics.  
Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and grade the assignments submitted by students to Expertiza. Students can be assigned in teams based on their selection of the topics. It has functionalities such as peer reviews in which students can provide feedback on other's work which helps peer in better developing the project. It is managed by the National Science Foundation.


== Problem Statement: ==
== Problem Statement: ==
Line 39: Line 39:
'''After:'''
'''After:'''


   TO-DO
   get_review_report_team_color




Line 49: Line 49:
'''After:'''
'''After:'''


   TO-DO
   get_curr_round_review_report




Line 59: Line 59:
'''After:'''
'''After:'''


   TO-DO
   get_review_score




Line 69: Line 69:
'''After:'''
'''After:'''


   TO-DO
   get_review_metrics





Revision as of 02:04, 25 March 2019

Refactor review_mapping_helper.rb

This page gives a description of the changes made for the review_mapping helper.rb of Expertiza based OSS project.

Expertiza Background

Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and grade the assignments submitted by students to Expertiza. Students can be assigned in teams based on their selection of the topics. It has functionalities such as peer reviews in which students can provide feedback on other's work which helps peer in better developing the project. It is managed by the National Science Foundation.

Problem Statement:

The review_mapping_helper.rb has multiple functions with a wrong naming convention, they are classic examples of bad function names. These functions are to be refactored accordingly. Few of the variables names used in the method must also be refactored to make it more relevant and understandable. In addition, some function's code is to be optimized to ensure that it follows DRY principle. Tests must be written for the functions which are modified. Also, comments must be added to all functions of the file. The create_report_table_header function contains HTML code which should be ideally placed in the view as partials, which will allow to easily reuse the code in Rails application.

Refactored method names

All the method names that are refactored are mentioned below-

Before:

 get_each_round_review_and_feedback_response_map_for_feedback_report

After:

 TO-DO


Before:

 get_certain_round_review_and_feedback_response_map_for_feedback_report

After:

 TO-DO


Before:

 get_team_name_color_in_review_report

After:

 get_review_report_team_color


Before:

 get_current_round_for_review_report

After:

 get_curr_round_review_report


Before:

 get_each_round_score_awarded_for_review_report

After:

 get_review_score


Before:

 get_min_max_avg_value_for_review_report

After:

 get_review_metrics


Function placed in the view as partials

The following function has been removed from the review_mapping_helper.rb and added to the views as partials:

  def create_report_table_header(headers = {})
    table_header = "<div class = 'reviewreport'>\
                    <table width='100% cellspacing='0' cellpadding='2' border='0' class='table table-striped'>\
                    <tr bgcolor='#CCCCCC'>"
    headers.each do |header, percentage|
      table_header += if percentage
                        "<th width = #{percentage}>\
                        #{header.humanize}\
                                        </th>"
                      else
                        "<th>\
                        #{header.humanize}\
                                        </th>"
                      end
    end
    table_header += "</tr>"
    table_header.html_safe
  end

Tests for the modified functions

Given below are the tests which are written for the functions that are modified: