CSC/ECE 517 Fall 2022 - E2281. Reimplement Waitlists

From Expertiza_Wiki
Jump to navigation Jump to search

Topic Overview & Prior Work

Feature Overview

E2240 contains detailed information on the previous team's work with this feature.

A summary of the desired functionality is presented below:

Any instructor or TA can sign students up for a topic. Students are able to sign themselves up for a topic. If the topic is full then the team will be put on a queue or "waitlist" for the topic. If the current team holding that topic drops the topic, then the team at the top of the waitlist will be assigned the topic.

Our Concerns with Current Functionality

  • What if a team is currently assigned a different topic and waitlisted for a topic that is now available? Currently assigned a topic, drop from all other waitlists
  • How many topics can a student be waitlisted for? As many as needed
  • How are students notified that they were assigned a new topic? Currently no functionality exists in expertiza

Comments on why E2240, was not merged

  1. The code for the waitlist is distributed all over the application, which is something could have been placed into a single controller and called through other files
  2. Although manual testing looked solid, there were not enough automated test cases to back their functionality.
  3. Too many class methods.
  4. The code does not follow ruby style design.
  5. Lack of descriptive code comments

Files Modified By Previous Team

  • signed_up_team.rb
  • waitlist.rb
  • sign_up_sheet_controller.rb
  • sign_up_sheet.rb
  • sign_up_topic.rb
  • suggestion_controller.rb
  • invitation.rb

Current Instructor View

The current instructor view is clean and readable. We see no need to alter the view.

Current Student View

The current student view is clean and readable. We see no need to alter the view.

Planned Work

This Project is a total reimplementation of the Waitlists functionality because the previous implementation failed to be merged for reasons stated above. As such we have a number of things to complete in order for it to be operational. Our plan to accomplish this task is to create a new class for Waitlists that inherits from Ruby's Queue class. Within this class we will have a model, and controller that will house all of the functionality relating to Waitlists. The further implementation explanation will be below including diagrams.

Use Case Diagram

Flow Chart for Adding Team

This is our desired flow for adding a team to a topic

Flow Chart for Removing Team

This is our desired flow for removing a team to a topic

Functions to Implement

Functionalities for Team

  • Adding Team to Waitlist
  • Removing Team from Waitlist
  • Removing Team from all Waitlists
  • Checking if Team is on any Waitlists
  • List all Waitlists a Team is on

Functionalities for Topic

  • Checking if Topic has any teams on Waitlist
  • Listing all Teams on Topics Waitlist
  • Locate First Team on Waitlist
  • Convert WaitListTeam into SignedUpTeam

Our Work

Model Methods

add_team_to_topic_waitlist
How to create a WaitlistTeam instance for a topic, using team's team_id

  def self.add_team_to_topic_waitlist(team_id, topic_id, user_id)
    new_waitlist = WaitlistTeam.new
    new_waitlist.topic_id = topic_id
    new_waitlist.team_id = team_id
    if new_waitlist.valid?
      WaitlistTeam.create(topic_id: topic_id, team_id: team_id)
    else
      ExpertizaLogger.info LoggerMessage.new('WaitlistTeam', user_id, "Team #{team_id} cannot be added to waitlist for the topic #{topic_id}")
      ExpertizaLogger.info LoggerMessage.new('WaitlistTeam', user_id, new_waitlist.errors.full_messages.join(" "))
      return false
    end
    return true
  end

remove_team_from_topic_waitlist
How to remove a WaitlistTeam instance from a topic

  def self.remove_team_from_topic_waitlist(team_id, topic_id, user_id)
    waitlisted_team_for_topic = WaitlistTeam.find_by(topic_id: topic_id, team_id: team_id)
    unless waitlisted_team_for_topic.nil?
      waitlisted_team_for_topic.destroy
    else
      ExpertizaLogger.info LoggerMessage.new('WaitlistTeam', user_id, "Cannot find Team #{team_id} in waitlist for the topic #{topic_id} to be deleted.")
    end
    return true
  end

cancel_all_waitlists
How to remove a WaitlistTeam instance from all topics for a specific team

  def self.cancel_all_waitlists(team_id, assignment_id)
    waitlisted_topics = SignUpTopic.find_waitlisted_topics(assignment_id, team_id)
    unless waitlisted_topics.nil?
      waitlisted_topics.each do |waitlisted_topic|
        entry = SignedUpTeam.find_by(topic_id: waitlisted_topic.id)
        next if entry.nil?

        entry.destroy
      end
    end
  end

Controller Methods

Design Strategy

Ruby Style Guide Basics

Previous teams were not merged due to failure of following the Ruby Style Guide, so our intent is to ensure we follow all Ruby Style Guidelines. Below we have highlighted which we believe are the most important.

  • Indentation: Each indentation level should be marked using two spaces.
  • Line Length: Each line should contain a maximum of 80 characters.
  • End of Line: Each line should have no trailing whitespace and should use UNIX Style line endings (CRLF).
  • Expression: Each line should only contain one expression.

DRY Principle

The principle simply means "Don't Repeat Yourself". Which aims to reduce repetition and redundancy in favor of abstraction.

Current/Past Implementation of the WaitLists has failed to follow this principle by having similar versions of the same code within all classes that need the waitlist functionality. Our Intent is to take the functionalities of WaitLists and contain them in a centralized WaitLists class. From there all classes that need a waitlist can just call from the WaitLists controller.

Testing

Planned Test Cases

  • Waitlist
Scenario: Student leaves a waitlisted team 
 Given: Logged in as an Student
  When: Student leaves a team
   Then: Student should be removed from all waitlisted topics associated with that team

Scenario: Instructor/TA Removes Student from Class 
 Given: Logged in as an Instructor/Admin and Student is on a team by themselves
  When: Student is dropped from class
   Then: Team should be removed from all waitlists

Scenario: Student accepts new team invitation 
 Given: Logged in as an Student
  When: Student accepted invitation to join team on a waitlist
   Then: Student should join team on waitlist

Scenario: Instructor/TA Removes a topic
 Given: Logged in as an Student
  When: Instructor/TA removes a topic containing a waitlist
   Then: The waitlist should be deleted

Scenario: Team is Assigned a Topic
 Given: Team is enrolled in multiple waitlists
  When: Team is assigned topic
   Then: Team should be dropped from all other waitlists within that project

Scenario: Team Attempts to Join Unavailable Topic
 Given: Topic is Full and Waitlist is Disabled
  When: A Team attempts to enroll in the topic
   Then: Error to raise explaining that "The Topic is Full and Waitlist is Disabled" 

Scenario: Instructor Views Waitlist for a Topic
 Given: A Topic has a waitlist filled with teams
  When: An Instructor attempted to view the waitlist
   Then: A List of the Waitlisted teams in order on queue should be returned

Scenario: Instructor Views Topics Waitlist by a Team
 Given: A Team is Waitlisted for multiple topics for a project
  When: An Instructor attempted to view which topics
   Then: A List of the Waitlisted topics should be returned

RSPEC Test Cases

Tests will be added once they've been implemented

Manual UI Testing

Currently the Manual Testing is Broken
Testing as Student

  1. Login as Student
  2. Click on Assignments
  3. Find an Assignment with a Signup Sheet (ex. Final project (and design doc))
  4. Click Signup Sheet
  5. Click the Green Check Mark under the Actions Column to add a topic (for testing choose an available topic)
  6. Ensure when Student is added to Topic that the Available Slots decrements
  7. To ensure the Waitlist works, login as another student (Follow steps 1-5). For step 5 choose the same topic that you chose with the other student
  8. Ensure this student should now be added to the waitlist
  9. Now log back in as the original student and navigate back to the signup sheet
  10. Now drop your topic. This should cause the available slots to remain the same and only the waitlist to decrement, because the student on the waitlist should've been added to the topic
  11. Now log back in a the second student an ensure you are assigned the topic

Testing as Instructor

  1. Login as Instructor
  2. Click on Assignments
  3. Find an Assignment with a Signup Sheet (ex. Final project (and design doc))
  4. Click Signup Sheet
  5. Begin by adding a Student (we will call them Student A) to an open topic
  6. Then add another Student (we will call them Student B) to the same topic. Student B should've been added to the waitlist
  7. Now remove Student A from the topic. Student B should now be assigned the topic and the waitlist should've decremented

Conclusion

While most of the functionalities will be inherited from the queue class, a few important functionalities must still be added. The implementation, while rather simple, will still require a good bit of work in order to ensure that is will be ready to be merged. Our intent is to fully test functionalities not inherited from the queue class, in order to properly ensure that the waitlist can be reimplemented.

Useful Links

Our Github Forked Repo

Contributors

Students

  • Nick Aydt (naydt)
  • Nagaraj Madamshetti (nmadams)
  • Rohan Shiveshwarkar (rsshives)
  • Gun Ju Im (gim)

Mentor

  • Naman Shrimali (nshrima)