CSC/ECE 517 Spring 2022 - E2224: Refactor review mapping controller

From Expertiza_Wiki
Revision as of 22:30, 21 March 2022 by Sbomman (talk | contribs)
Jump to navigation Jump to search

This wiki page is for the description of changes made under E2224 OSS assignment for Spring 2022, CSC/ECE 517.

Expertiza Background

Expertiza is an open source project which is developed and maintained by NCSU faculty and students. It is based on Ruby on Rails framework and has many features supporting instructor-student activities. Instructors can create assignments and review student's work. Students can form groups, submit assignments and review peer's work.

Description of the project

The project aims to refactor a controller - review_mapping_controller. It is a long and a complex file and most of the methods do not include comments. The goal is to better re-structure it without modifying its original functionality and improving readability by using meaningful variable names and adding more comments.

Link to the Pull Request Submitted
Link to the deployed project
Link to the Repository

Functionality of review_mapping_controller

The functionality of review_mapping_controller is to provide mapping for reviewer and assignment. Basically, the controller handles assignment of reviews to different teams or single student user, such as the event of peer review and self review. Also, this controller is responsible to respond student user request for extra bonus reviews based on assignment policy.

Problem Statement

The review_mapping_controller is a long and complex file. Most of the methods are sparsely commented on. Some methods are way too long to understand, please break them down into pieces for better understanding. Also, the few instances of code duplication that exist should also be removed.

Tasks

-Refactor the long methods in review_mapping_controller.rb
-Rename variable names such as student_review_num, submission_review_num, calibrated_artifacts_num, participants_hash to convey what they are actually used for
-Replace switch statements with subclasses methods
-Create models for the subclasses
-Remove hardcoded parameters

Design Pattern

Files modified/created in the current project

review_mapping_controller.rb

review_mapping_controller_spec.rb

Details of the changes made

review_mapping_controller.rb

This controller will map the submissions made by the teams to the students for facilitating peer-reviewing. The following methods which were originally long and complex were broken down into simpler methods. We have added comments for every new method that was added and updated existing comments where ever required.

peer_review_strategy:

The above method assigns reviews evenly among the participants for each team. It doesn't allow the a participant to review his/her own work. Initially, this method was almost 80 lines long containing multiple nested if statements and it was a conglomeration of various functionalities required to achieve the strategy. It was broken down meaningfully into 4 different functions to handle different functionalities. DRY principle is followed. peer_review_strategy() is divided into even_out_reviews_among_teams(), modify_selected_participants_to_review(), remove_students_with_enough_reviews(), get_random_participant_index() as the core functionality blocks. even_out_reviews_among_teams - This method is used to even out the # of reviews among teams for the specified assignment ID modify_selected_participants_to_review - This method is used to update the selected participants corresponding to a team to review remove_students_with_enough_reviews - This method is used to remove students who have already been assigned enough num of reviews out of participants array get_random_participant_index - This method is used to get random index to select a random participant for assigning a review


automatic_review_mapping:

assign_reviewer_dynamically:
add_reviewer :

The above method add a reviewer to a student's work. Initially the method checks whether the student is being assigned to review work of his/her teammates and displays an error. If not, student is assigned to review work of students from a different team. The logic which handles assignment of work from an another team is moved to a separate method named as 'add_reviewer_to_another_team'.

review_mapping_controller_spec.rb

Updated following params variable names for better readability:
max_team_size num_reviews_per_student
num_reviews_per_submission
num_calibrated_artifacts
num_uncalibrated_artifacts

Test Plan

Manual UI Testing

Rspec Unit Tests

Refactoring changes did not break any functionality. All the existing test cases passed successfully.

Capybara Integration and Functional Tests

Code Coverage

Project Mentor

Naman Shrimali (nshrima@ncsu.edu)

Team Members

Harini Bharata (hbharat@ncsu.edu)

Sravanth Reddy Bommana (sbomman@ncsu.edu)

Sri Pallavi Damuluri (sdamulu@ncsu.edu)