CSC/ECE 517 Fall 2015/ossE1558BGJ

From Expertiza_Wiki
Revision as of 20:02, 26 October 2015 by Kmjos (talk | contribs) (Created page with "= Introduction = This page provides a description of the modifications and improvements made to the Expertiza project’s source code as part of an Expertiza based Open Source S...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Introduction

This page provides a description of the modifications and improvements made to the Expertiza project’s source code as part of an Expertiza based Open Source Software project. Expertiza is a web based application which allows students to submit and peer-review classmates’ work, including written articles and development projects. The specific changes made during the course of this project were to the ReviewResponseMap.rb file, with additional changes made to other related files in support of refactoring ReviewResponseMap.rb.


Problem Statement

ReviewResponseMap.rb is the model class used to manage the relationship between contributors, reviewers, and assignments. The intent of the changes were to refactor the code for better readability and adherence to Ruby coding standards and best practices. Primarily these changes involved the refactoring of overly complex methods, renaming methods for better readability, and the addition of missing unit tests.


Changes

Refactoring of import method

Code Climate reports showed the import method to be overly complex, with a number of checks being included in the import method itself. The resolution for this problem was to refactor the import method, creating private methods to perform the null checks and throw import errors.

Prior to refactoring, all null checks were performed in line:



After refactoring the import method adheres to the single responsibility principle, performing only key import tasks while making calls to private methods for any necessary validation:


Private methods added:




Refactoring of get_assessments_round_for method

The get_assessments_round_for method’s name failed to provide a clear idea of the method’s purpose and functionality. Additionally, there was a private variable, team_id, introduced in the method that was unnecessary and could be replaced by using the id property of the team parameter directly.


Following the refactoring, the name of the method provides a clearer idea of its purpose:


The change in method name also required changes to the following files that referenced it:

/app/models/assignment.rb:436:


./app/models/assignment_participant.rb:268:



Refactor metareview_response_maps

The metareview_response_maps method was unnecessarily complex, introducing unneeded private variables and an additional iteration inside the main loop.


After refactoring:



Addition of code comments and unit tests

2. CodeClimate says “Use find_by instead of where(..).first . -> Not always the best solution: https://github.com/bbatsov/rubocop/issues/1938


Manual Test Cases

In order to test the changes made to the ReviewResponseMap, bring up Expertiza and log in as an administrator. Once logged in, proceed with the following steps:

  1. Create at least three users to perform the tests.
  2. Create an assignment for only the users you just created. Ensure that the assignment is only available for your new users. It’s important to follow this step exactly so that you will not confuse your new users with the preexisting users.
  3. Sign out.
  4. Log in to Expertiza as User1 and submit the assignment.
  5. Open two new Chrome Incognito windows and log in as the other two users and select that submission for review. It’s best to keep these in multiple incognito tabs so that you won’t have to log out and log back in as another user during each step.
  6. Check from User1’s “Your scores” page whether the page is loading correctly prior to the reviews being performed.
  7. Review the assignment from User2’s login.
  8. Ensure that reviews show up on User1’s page.
  9. Repeat steps 6 and 7 for User3.
  10. While logged in as User1, give feedback to User2 and User3.
  11. Change the deadline so that you are able to switch into the “Metareview Phase”.
  12. Repeat the above steps.
  13. Perform the review as User2 (or User3) and ensure that the metareviews are correctly displayed on User1’s page.