CSC/ECE 517 Spring 2022 - E2220: Refactor reputation web service controller

From Expertiza_Wiki
Revision as of 02:17, 22 March 2022 by Gkogant (talk | contribs)
Jump to navigation Jump to search

This page provides information about the refactoring work done on the reputation web service controller as part of the OSS project.

Team

Mentor

  • Naman Shrimali (nshrima)

Team Members (MissingSemicolon)

  • Eshwar Chandra Vidhyasagar Theda (ethedla)
  • Gokul Krishna Koganti (gkogant)
  • Krishna Saurabh Vankadaru (kvankad)

Expertiza

Expertiza is an assignment management portal. This portal can be used by instructors to create assignments . It can be used by students to submit their academic works and peer review others' works. Expertiza allows students to create, join and work in teams.

Background of reputation web service controller

Expertiza provides a way for students to peer review others' works. The motive of this provision is to encourage students to learn more while reviewing others' works and utilize the reviews to reflect on the grades. However, to depend on the peer reviews, the reviews' credibility has to be established. This credibility can be evaluated through reputation scores computed by reputation systems. These systems are deployed as web services and facilitate the calculation of past and present assignment scores for peer review research.

In the project's scope, we focus on the aspect of refactoring the file reputation_web_service_controller.rb. This is a controller file used for the calculation of reputation scores. This is measured based on how close the current review scores are to the other.

Issues identified

  1. Some methods are violating the single responsibility principle, i.e, some methods are doing more than one tasks. These methods must be broken down such that each method performs only one task.
  2. In send_post_request, references to specific assignments, such as 724, 735, and 756 are no longer relevant and must be removed.
  3. Password for a private key is place in the code. As this code is open-sourced, this causes security concerns and must be handled.
  4. Some method names followed bad naming convention. These method names are general and are in noun forms. Specific relevant names must be used as method names.
  5. Detailed method descriptions are needed to be inserted into the code as comments.
  6. Client is a bad method name and needs to be changed.
  7. There is a lot of unused/commented code, which should be removed.
  8. Some spelling mistakes are identified in the code.

Enhancements

Functionality Fixes

  1. The case of when a post request to reputation web service fails is not handled properly, resulting in a long error message on the view. This error has been handled to display formatted error on the page.
    Commit link: https://github.com/krishnasaurabh/expertiza/pull/15/commits/84c9f30f9ee29759b5a41c9d11cda53c298fe49b

  2. Commented out the part of encryption and decryption as the public key files are not available.
    Commit link: https://github.com/krishnasaurabh/expertiza/pull/15/commits/db83d497dd284cf0700d219f1b225f2d6c508ac8

  3. In send_post_request (old version, currently prepare_request_body), init_header has been removed and requested & response JSON has been displayed in the beautify JSON for the implemented algorithms. This is done by using constant objects instead of URL strings.
    Commit link: https://github.com/krishnasaurabh/expertiza/pull/17/commits/f343438383d56d577648ef4dd91de4fc3501449a

  4. When the control is redirected to the client, in the older versions, the data was being passed through the use of instance variables. Now, the parameters are being passed using flash.
    Commit link: https://github.com/krishnasaurabh/expertiza/pull/15/commits/bf2ab75eb7b25e6d0b79791610beb371383b6042

Refactoring

Introduced single responsibility principle to the functions

All the functions are modified in a way to concur with the single responsibility principle i.e, each function performs only one considerable task.

The following functions violated SRP:

  1. The db_query method not only queries, but calculates sums.
  2. The json_generatormethod not only generates json, but also queries the database based on the ‘type’ it receives.
  3. The send_post_request not only sends a post request, but generates a body based on parameters received, encrypts the data, hits the post request, decrypts the response data, and updates participants.

Removed unnecessary references in the send_post_request body

In send_post_request, there are references to specific assignments, such as 724, 735, and 756. They were put in to gather data for a paper published in 2015. They are no longer relevant and are removed. Relevant tests are also removed.

Changed method names to be more meaningful

Function description

In the older version, controller's functions did not have function descriptions. In the current version, a detailed functional description has been added to each method. Additionally, descriptions include what parameters are accepted and what is returned.

Removed unnecessary code

Commented code blocks that are unused are found and deleted from the controller's body. RSA Encryption and Decryption are not being used for now. Such code is commented out for potential future use.

Corrected spelling mistakes

Only one instance of spelling error has been identified i.e, dimention. It has been corrected.

Manual Testing

Before sending the request, please assign values for assignment_id and round, choose an algorithm.

Testing via rspec

 rspec spec/controllers/reputation_web_service_controller_spec.rb 

Future Work

  1. Client view has checkboxes for choosing between the action to be performed. But only the first checked action is being considered. This has to be fixed by the use of radio buttons.
  2. Hamer and Lauw actions are not resulting in any functional implementations. These algorithms have to be implemented.

GitHub Repository and Pull Request links

Link to the Expertiza repository:
Link to the forked repository:
Link to the pull request: