CSC/ECE 517 Fall 2022 - E2279. Further refactoring and improvement of signup sheet controller: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
Line 22: Line 22:
==Prior Work section with last years and last projects background==
==Prior Work section with last years and last projects background==
* [[CSC/ECE 517 Fall 2022 - E2259. Refactor signup_sheet_controller]]
* [[CSC/ECE 517 Fall 2022 - E2259. Refactor signup_sheet_controller]]
** We ( @sswetha08 @weichic-ncsu @juanbenavid ) have performed the following refactoring to fix the issues specified for this refactoring project:
Renamed "sign_up" to be "signup" when it is used as adjective or noun for variable/method/controller name.
Update method refactored by removing explicit update of every attribute of topic and instead performing this task through update_attributes function provided by rails. Further, update_max_choosers method changed to update_waitlist to support this.
Removed add_signup_topics_staggered() and replaced it with add_signup_topics() since it does nothing but call add_signup_topics().
Removed load_add_signup_topics() since it does nothing for add_signup_topics().
Removed the feature to sign up for a topic as an instructor as there seems to be no way to access this feature from the views.
List method was too long and has been refactored.
We have also added two new test cases for the controller:
Destroy signup_sheet when there are other topics in the assignment
General test case added for rendering list view
* [[CSC/ECE 517 Spring 2022 - E2223. Refactor sign up sheet controller.rb]]
* [[CSC/ECE 517 Spring 2022 - E2223. Refactor sign up sheet controller.rb]]



Revision as of 23:25, 14 November 2022

Team

Mentor

  • Ed Gehringer (efg)

Team Members

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

Problem Statement

  • Provide extensive comments for all the code you view/refactor/modify.
  • Ensure that any code changes do not break any functionality. Refactoring method names might cause cascaded updates in other files.
  • 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] [Not clear that this has been addressed and tested.]
  • 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.] [Has this been fixed?]

  • There are nine checks for @assignment.is_intelligent. This method is atrociously named. It simply checks for whether bidding is being used to assign topics.

Rename the method. Figure out some way to remove all or almost all of those checks, which are a gross violation of the Single-Responsibility Principle (as well as cohesion).

  • Also see Code Climate issues. To reduce the size of the file, you could move some methods to sign_up_sheet_helper.rb [Has this been done?.]

Prior Work section with last years and last projects background

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

Update method refactored by removing explicit update of every attribute of topic and instead performing this task through update_attributes function provided by rails. Further, update_max_choosers method changed to update_waitlist to support this.

Removed add_signup_topics_staggered() and replaced it with add_signup_topics() since it does nothing but call add_signup_topics().

Removed load_add_signup_topics() since it does nothing for add_signup_topics().

Removed the feature to sign up for a topic as an instructor as there seems to be no way to access this feature from the views.

List method was too long and has been refactored.

We have also added two new test cases for the controller:

Destroy signup_sheet when there are other topics in the assignment General test case added for rendering list view

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.

General Design Goals

Plan and List of Work done (specific tasks planned)

  • assignment is intelligent? (Swetha)
  • participants variable (Juan)
  • topics staggered ( Wei-Chi)

Test Plan

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.
  5. Create signup_sheet when sign_up_topic cannot be found.
  6. Destroy signup_sheet when other topics with the same assignment exists.

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

We also ran the rspecs for signup_sheet model and helper just to make sure no functionality was broken.

rspec spec/helpers/signup_sheet_helper_spec.rb
rspec spec/models/signup_sheet_spec.rb
New test cases
Destroy signup_sheet when there are other topics in the assignment
New, more general test case added for rendering list view, as we noticed that some functionalities we broke while refactoring did not result in failed test cases.

Mandatory

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. Add New Topic or Delete topic using links in the form below


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.
  • New Tests

Modifications (probably after working on them)

Relevant Links