CSC/ECE 517 Fall 2019 - E1945. Refactor users controller.rb

From Expertiza_Wiki
Revision as of 03:12, 29 October 2019 by Bjfisher (talk | contribs) (Initial)
Jump to navigation Jump to search

CSC/ECE 517 Fall 2019 - E1945. Refactor Users_controller.rb

Contents:

About Expertiza Users Controller Problem Statement Documentation of methods Refactoring Methods to Account Controller Making AccountRequest Model What We did Refactoring Users controller Refactoring Tests



About Expertiza: Expertiza is an open-source project based on Ruby on Rails framework. It allows the instructor to create new assignments and customize new or existing assignments. The instructor is allowed to create a list of topics for the students to which they can sign up for. For working on different projects and assignments the students can form teams in Expertiza. Peer review is another feature where students can review other students' submissions. This feature is available in Expertiza. Furthermore, Expertiza supports submission across various document types, including URLs and wiki pages.

Abstract The UserController is a controller used for managing the creation, modification, and destruction of users in the Expertiza system. Instructor users must be added by creating a request for a new account. A key part of our team’s work was moving methods associated with managing a new account request from the UserController to a new controller named AccountRequestController. This removed coupling between account requests and user objects. Furthermore, it allowed an account request to be properly associated with its own controller, model, and view. Additionally, the team refactored and documented some methods in the UserController.

Problem Statement: The following tasks were accomplished in the project by our team:

Moved the following methods from UserController to AccountRequestController Methods affected: created_approved_user list_pending_requested request_new created_requested_user_record roles_for_request_sign_up Requested_user_params All the above mentioned methods have been moved to a new file named account_request_controller.rb The RequestedUser model has been renamed to AccountRequest. And is now managed by the AccountRequestController The form that is currently displayed when the “Request Account” button is clicked from the Expertiza login page has been edited with the following changes Only instructor accounts can be created, so the dropdown has been removed All form labels are now bold-faced The “Self Introduction” label has been re-named to “Self-Introduction” The textbox for the self-introduction field now includes some hint (“Please include a link to your website”) This is the current page after fixing the issues that gets loaded after the “request Account” button is clicked


Comments were written or renamed for the following methods to get a clear understanding of the working of the methods and to reflect their actual behaviour. get_role - The method was renamed to role, a comment was added explaining that it finds the role of a given user object show_selection - The method was renamed to show_if_authorized, as this method should only display the users if the current user is authorized. Also changed it from a GET to a POST request since it more accurately reflects its working. foreign - A comment was added for this method, explaining that it stores all roles possible and that it gets role id of the session’s user.


Invoked the paginate_list method at the correct location(in the list method) so that it paginates the users list correctly. The number of users per-page has currently been set to 100, which was showing all users in a single page by default. Also added a section at the bottom of the list.html.erb page for navigating between the paginated list of users.


Tests for UserController were updated to account for the fact that some methods now use the AccountRequestController. The tests for the methods that were moved to AccountRequestController were moved to a new spec in the file account_request_spec.rb. The team did this because it made sense to make a new spec for a new controller. Nevertheless, most test functionalities remained the same. The tests were also updated to not select the user role from the “User Role” dropdown. This was done because the dropdown was removed from the UI since only instructor accounts can be created.

Github Repo: https://github.com/deepayanbardhan/expertiza


Project Mentor: Ramya Vijayakumar

Project Members: Benjamin Fisher Deepayan Bardhan Sanket Pai