CSC/ECE 517 Fall 2022 - E2259. Refactor signup sheet controller

From Expertiza_Wiki
Revision as of 00:30, 26 October 2022 by Ssairam (talk | contribs) (→‎Solutions)
Jump to navigation Jump to search

This wiki page is for the information regarding the changes made for the E2259 OSS assignment for Fall 2022, CSC/ECE 517.

Team

Mentor

  • Ed Gehringer (efg)

Team Members

  • Juan Benavides (jdbenavi)
  • Wei-Chi Chen (wchen37)
  • Swetha Sairamakrishnan (ssairam)

Introduction

Expertiza is a open source project developed on Ruby on Rails. This web application is maintained by the student and faculty at NC State. This application gives complete control to the instructor to maintain the assignments in their class. With multiple functionalities such as adding topics, creating groups, and peer reviews, Expertiza is a well developed application that can handle all types of assignments. To learn more about the full functionality Expertiza has to offer, visit the Expertiza wiki.

Peer Review Information

For users intending to view the deployed Expertiza associated with this assignment, the details are below:

  • We have deployed the project -------------------
  • Instructor login: username -> instructor6, password -> password
  • Student login: username -> student5899, password -> password

About Controller

The sign up sheet controller performs the following functions:

  • Allows an instructor to add/remove topics to an assignment.
  • Allows an instructor to assign/remove students to topics (This has been removed as it is unused/impersonation of student is used instead)
  • Allows a student to see the list of available topics which can be bid on for given OSS assignment.

Issues

  • Naming is inconsistent. When used as a verb, “sign up” is two words. When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf. “sign_up_as_instructor”. Please make the naming consistent. Of course, this will result in changes in calling methods as well. [Mostly fixed by previous version of project.]
  • Update method has a plethora of instance variables defined before updating. These might not be necessary (e.g., look at update method of bookmarks_controller). Decide whether so many instance variables are really needed. Refactor the variables not needed out.
  • Add_signup_topics_staggered does not do anything different from add_signup_topics. Separate functions are needed, because add_signup_topics_staggered needs to make sure that the deadlines are set. [Assignment 1042 has staggered deadlines]
  • Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)
  • What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed. Provide comments as to what each method does.
  • The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.
  • Refactor participants variable in load_add_signup_topics

[In retrospect, the meaning of this is not clear. The @participants variable is used in a way that is very obscure, with code spread across several views, and no comments saying what it is doing. It used to be that participants (individual students) signed up for topics. Now, only teams can sign up for topics. So @participants does not make sense. Signup_as_instructor_action has if-else ladder. It can be made more elegant. [If it is worth keeping this method at all.]

  • Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle. delete_signup_as_instructor

Solutions

1. Rename "sign_up" to be "signup" when it is used as adjective or noun for variable/method/controller name.

https://github.com/weichic-ncsu/expertiza/commit/7fb2cceacbe459e5847141baea501bbd71952f12

https://github.com/weichic-ncsu/expertiza/commit/1152bac5c77cb9cf07f7de820e8677ba9a2a47ed

https://github.com/weichic-ncsu/expertiza/commit/3a5c6131c169812e455c20406809650a8a512646

https://github.com/weichic-ncsu/expertiza/commit/12f5e58ddb7782ec0ac7a4455489be8ecd167071

2. Update method has been refactored by removing explicit update of every attribute of topic and instead performing this task through update_attributes function provided by rails. To filter out topic specific params from the hash, topic_params method has been defined. Further, update_max_choosers method has been refactored so as to not set the value of max_choosers separately. It now simply checks whether the given value of max_choosers is valid and if yes, updates the waitlist accordingly. For instance, if max_choosers increase from 1 to 2, 1 team on the waitlist can be allotted the topic.The name of update_max_choosers has been changed to update_waitlist to reflect this change.

https://github.com/weichic-ncsu/expertiza/commit/aab4361285e53f440bff1818ee8acce8c8a33648

3. Remove add_signup_topics_staggered() and replace it with add_signup_topics() since it does nothing but call add_signup_topics().

https://github.com/weichic-ncsu/expertiza/commit/14059f8ee9b846bc4f9830d16b000c99d3f5c71c

4. Remove load_add_signup_topics() since it does nothing for add_signup_topics().

https://github.com/weichic-ncsu/expertiza/commit/e648df810a171a5b5b0756d91dd2c3c8d692b7cb

5. The feature to sign up for a topic as an instructor has been removed as it didn't appear to have been used in many years. More importantly, there seems to be no way to access this feature from the views. Hence sign_up_as_instructor, sign_up_as_instructor_action and delete_sign_up_as_instructor methods have been removed along with its associated views and tests in the controller spec for signup_sheet.

https://github.com/weichic-ncsu/expertiza/commit/7b3f68ad5da1bc24e1f58a4c815aeb5985156aa8

https://github.com/weichic-ncsu/expertiza/commit/4d3baceb5a7135c89fad7660fd342eb49b2a20df

Testing

RSpec
As such no functionality changed in any function, only refactoring done. All the refactoring was carefully verified by running rspec tests. To run the spec file, run:
rspec spec/controllers/signup_sheet_controller_spec.rb


Physical Testing
  1. edit this stuff:

Edge Cases and Pre-Conditions

  1. When dropping topic if submission already done.
  2. When deadline from dropping topic has passed.
  3. Deleting topic when topic cannot be found.
  4. Signup in case when user cannot be found.

Login as instructor

  1. Hover on Manage Tab
  2. Click on Assignments Tab
  3. Click on Edit Button for "OSS project & documentation" assignment
  4. Select the Topic Tab
  5. Click the Green Check for any topic
  6. Enter a student UnityID and click submit

Login as student

  1. Click on OSS project/Writing assignment 2
  2. Click on Signup sheet
  3. The list must be visible, which indicates functionality is as before after refactoring list function.