CSC/ECE 517 Spring 2024 - E2410 Reimplement View for results of bidding: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
== Expertiza ==
== Introduction ==
[http://expertiza.ncsu.edu/ Expertiza] is an open-source web application built on Ruby on Rails that enables instructors to create customized assignments with topic lists for students to choose from. It facilitates team formation, allowing students to collaborate on assignments and projects. Expertiza supports peer review processes where students can provide feedback on each other's submissions across various document formats, including URLs and wiki pages. This freely available platform provides a flexible and comprehensive solution for managing assignments, teamwork, and peer evaluations.
The [http://expertiza.ncsu.edu/ Expertiza] project is a dynamic collaboration between students and faculty at NC State University, built on the Ruby on Rails platform. It serves as a hub for fostering cooperative learning and academic collaboration, offering a suite of tools for efficient course and assignment management.
 
Expertiza empowers instructors with comprehensive control over the learning process, providing insights into various academic facets such as user profiles, courses, assignments, questionnaires, and reviews. With its user-friendly interface and innovative features, Expertiza revolutionizes collaborative learning, facilitating seamless topic creation, group formation, and peer review. Join us in embracing the transformative potential of digital collaboration to redefine the educational experience.
 
== Test Login Credentials ==
<li>UserId: instructor6</li>
<li>Password: password</li>
 
== Problem Statement: ==
===Current Problem===
*Instructors using Expertiza lack comprehensive visibility into the bidding process, impeding their ability to discern the most sought-after topics by teams and the prioritization of choices, leading to inefficient allocation of projects.
 
===Key Deficiencies===
*The absence of essential details, such as which teams have bid on specific topics and the percentage of teams assigning their top-choice projects, results in instructors resorting to cumbersome workarounds, hindering effective management and allocation of projects.
 
===Proposed Solution===
*Enhancing Expertiza's interface with a dedicated view for instructors to access detailed statistics on topic bids, including priority rankings, team names, total bids, and the percentage of teams selecting each topic as their top choice. This solution aims to streamline workflow, empower instructors with valuable insights, and facilitate fair and efficient project allocation.
 
== Previous Implementations ==
#[https://github.com/Shreshth-Malik/expertiza E2360 Github Repository]
#[https://github.com/expertiza/expertiza/pull/2659 E2360 Pull Request]
#[https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding E2360 Wiki Page]
#[https://www.youtube.com/watch?v=pGmHyqLj7PM Demo Video]
 
#[https://github.com/dnguyenv/expertiza/tree/beta E2245 Github Repository]
#[https://github.com/expertiza/expertiza/pull/2392 E2245 Pull Request]
#[https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2245:_View_for_results_of_bidding E2245 Wiki Page]
#[https://www.youtube.com/watch?v=OTSRqRihahQ Demo Video]
 
=== E2410 Current Implementation ===
#[https://github.com/saisanthoshG/expertiza Github Repository]
#[https://github.com/expertiza/expertiza/pull/2768 E2410 Pull Request]
#[https://youtu.be/g9DzKE5otSU Demo Video]
 
=== Issues With Previous Implementation ===
# Functions directly fetch and process bids in the controller, which could be better managed through model methods for improved organization.
# The use of instance variables for bid counts is not scalable and can become problematic with changes in the bidding process.
# The current approach of fetching topics and iterating for bids may result in inefficient N+1 queries.
# There's a risk of repeating logic related to bidding across different parts of the application.
# UI elements and logic are intertwined within the controller, which is not ideal for MVC patterns.
# The views have repetitive non-zero checks for bid counts, which could be streamlined.
# CSS styles are hard-coded in views, which should be abstracted to CSS files.
# Missing error handling could cause unhandled exceptions for nonexistent bids or topics.
# Tests might not cover all scenarios, such as incorrect bid priorities or unrepresented teams.
# The UI lacks dynamic feedback mechanisms like AJAX updates for user interactions.
 
== Proposed Solution ==
The design presented in this iteration of the project is very similar to the high-level design proposed last year in [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding Fall 2023 Design]. Since this pull request was not merged, we have included the proposed changes that are credible. Below is a comparable explanation of the previously offered remedy, as well as some new design decisions to improve upon the previous iteration of this issue.
 
We've significantly improved the bidding system in Expertiza by enhancing the visibility and handling of bids for topics. Key improvements include detailed bidding data presentation, with distinct columns for each bid priority and clear team bid information. This offers users, both instructors and students, a transparent view into the bidding outcomes. Additionally, our refined logic more accurately calculates teams' preferred choice percentages, aiding better decision-making in topic assignments. This has also been moved to a separate page, to improve user-experience.
 
== Design ==
 
=== Sequence Diagram for Bidding Process ===
 
[[File:Sequence Diagramb.jpeg|frameless|upright=3]]
 
=== Current Flow ===


== Introduction ==
* Go to the assignments section, we have created a dummy a assignment, "Test OODD", click edit icon next to it.
The project focuses on decluttering the bidding view interface to offer a more intuitive user experience. This will not only improve readability and maintainability but also ensure the code adheres to design principles such as the Single Responsibility Principle. The initiative promises to reduce redundancy and elevate the overall functionality of the platform, paving the way for a more robust and user-centric application.
[[File:2410 1.jpeg|frameless|upright=3]]
 
* Now make sure the "has topics" checkbox is selected.
[[File:24104.jpeg|frameless|upright=3]]
* Now go to Topics section and click "Show bids by priority" button.
[[File:Topics_bid_button.jpg|frameless|upright=3]]
 
* Here you will be able to view various stats of the bidding,like the topics with their IDs, their respective topic names, number of teams that have put that specific topic as their 1st 2nd and 3rd priority bid, along with the names of those teams, the total number of bids and finally the percentage of teams that put the specific topic as their first bid.
[[File:Bidding_sum_view.jpg|frameless|upright=3]]
 
=== Flow of the Bidding Process ===
The instructor will login as an instructor, and access the assignments page. Next they will select the assignment from the assignment list and open it for editing. Check the "has topics" checkbox to activate the topics tab and visit it. Now instructor can add a new topic by filling the new topic form. Submit the form and update the topic list. Now the students can start bidding on the topics (assigning their 1st, 2nd and 3rd priorities.  Now the instructor can check the bidding details by clicking "show bids by priority" button on the topics page.
 
== Implementation Details ==
=== Files Modified During the implementation ===
 
* assignments_controller.rb
* lottery_controller.rb
* assignment.rb
* bid.rb
* team.rb
* assignment_helper.rb
* _topics.html.erb
* bidding_details.html.erb
* _bid_summary_partial.html.erb
 
=== New functions that are implemented ===
====1. Display bidding summary based on priority details ====
==== [https://github.com/expertiza/expertiza/commit/92a7f87eaa07853678c0c922ce147a5e71c20661 Method for bidding analysis] ====
File : <code> app/controllers/lottery_controller.rb </code>
 
Functionality:
 
* Added `calculate_bidding_summary_based_on_priority` method to `lottery_controller` for aggregating bid data per topic.
* Prepares data for displaying the bidding details for each topic within an assignment.
* It calculates the number of bids for each priority (1, 2, 3) per topic and also computes
* The overall percentages of teams that received their first, second, and third choice.
* This method is responsible for calculating the bidding table data for an assignment.
* Computes the count of assigned teams for each priority level (1, 2, 3) across all topics.
* It checks each team associated with a topic and determines if the team's bid matches
 
[[File:1_lottery_code.jpg|frameless|upright=3]]
 
===2. Background Color according to percentage===
====[https://github.com/expertiza/expertiza/commit/f111f8cc4edd9ebb904237fad185ab86eb4a4a86 Method for background color] ====
 
File : <code> app/helpers/lottery_helper.rb </code>
 
Functionality:
* Light red for low percentages
* Light orange for medium percentages
* Light green for high percentages
* No background if outside range
[[File:2_color.jpg|frameless|upright=3]]
 
===3. Button to show bids by priority===
==== [https://github.com/expertiza/expertiza/commit/11f7b788f6f8bca8dbbfb9477873db07823fc8e9 Button view] ====
File : <code> app/views/assignments/edit/_topics.html.erb </code>
 
Functionality:
 
*  ⁠Button to visit the seperate page to view the results of bidding
[[File:3_button.jpg|frameless|upright=3]]
 
===4. Bidding Summary Table ===
==== [https://github.com/expertiza/expertiza/commit/b798b78c8c6b649caa139044635b05ecd446a62e Summary Table] ====
File : <code> app/views/lottery/calculate_bidding_summary_based_on_priority.html.erb </code>
 
Functionality:
 
* View topics with their IDs,
* View topic names
* View number of teams that have bid on that specific topic as their 1st 2nd and 3rd priority bid,
* View the names of those teams
* View the total number of bids and finally the percentage of teams that put the specific topic as their first bid.
* View the percentage of first bids with tooltip and custom background
[[File:App-models-bid.rb.jpg|frameless|upright=3]]
 
== Accomplishment ==
This project has added a "Bid Summary", which allows the instructor to see all topics with their IDs, their respective topic names, number of teams that have put that specific topic as their 1st 2nd and 3rd priority bid, along with the names of those teams, the total number of bids and finally the percentage of teams that put the specific topic as their first bid. This information will allow us to see which topic is most trending, ie, what is the topic most students want to work on, and which topics are not doing so well. This enables the instructor to get this information without having to login to the student view and figure this out manually.
[[File:Bidding_sum_view.jpg|frameless|upright=3]]
 
== Test Plan ==
 
=== Manual Testing ===


==Problem Statement==
Follow these instructions to manually test the below functionality:
The reimplementation project entails:
*Enhance the user interface of the bidding view to make it less cluttered and more user-friendly.
*Refactor the assignment_controller.rb by extracting the bidding logic into a separate controller, bidding_logic_controller.rb, to adhere to SRP.
*Improve the readability and maintainability of the codebase by implementing meaningful method names and adhering to design principles.
*Reduce redundancy in the code and promote reusability across different models within the platform and add meaningful comments where necessary.


==Plan for Reimplementation of GradesController==
* Navigate to the assignments page and click on the pencil icon next to the 'Test OODD' assignment.
* Confirm that the 'Has Topics' checkbox is selected on the general assignment settings page.
* Move to the 'Topics' tab and check the 'Enable bidding for topics' option.
* Add a new topic for students to bid on by clicking the 'New Topic' button and entering relevant details.
* Log in as a student and bid on the new topic, choosing the priority level for the bid.
* Return to the 'Topics' tab as an instructor to view the updated bidding table with bids and priorities listed.
* Confirm that the total number of bids and the number of #1, #2, and #3 bids are displayed correctly for each topic.
* Check the background color coding (green, yellow, red) in the bidding table that reflects the intensity of bids for visual verification.


====Refactoring assignment Controller:====
===RSpec Testing===
File: <code>app/controllers/assignment_controller.rb </code>
Refactor the bidding_details method to a more clear method nameEnhancing code clarity. Separate the bidding logic from the assignment controller to adhere to the Single Responsibility Principle (SRP).


====Improving Bidding View:====
The assignment_controller_spec.rb has existing automated rspec tests in place. Furthermore following tests were added to the code to ensure the functionality is working as expected and thereby increasing code coverage:-
Files: <code>app/views/assignments/edit/_topics.html.erb</code> ⁠, ⁠<code>app/views/assignments/n</code> , <code>bidding_details.html.erb</code>
Consolidate the bidding details summary view into a single table for improved clarity and organization. Implement interactive features such as modals or tooltips to provide additional context or information.


====Meaningful Method Names:====
* lottery_controller_spec.rb
Files: <code>app/controllers/assignment_controller.rb</code> ⁠, <code>app/models/assignment.rb</code> ⁠, ⁠ <code>app/models/team.rb</code> ⁠, ⁠ <code>app/models/bid.rb</code> ⁠
*tests for calculate_bidding_summary_based_on_priority in lottery_controller
Review existing method names and replace generic or unclear names with descriptive ones that accurately reflect their purpose and functionality ensuring consistency.
<pre>describe '#calculate_bidding_summary_based_on_priority' do
    it 'calculates and returns bidding summary data for topics' do
      # Setup test data
      assignment = create(:assignment)
      topic = create(:topic, assignment: assignment)
      team = create(:team, assignment: assignment)
      bid = create(:bid, topic: topic, team: team, priority: 1)
      team_name = create(:team_name, team: team)


====Adherence to Design Principles:====
      allow(Assignment).to receive(:find).with(assignment.id).and_return(assignment)
Files: <code>app/controllers/assignment_controller.rb</code> ⁠, ⁠ <code>app/models/assignment.rb</code> ⁠, ⁠ <code>app/models/team.rb</code> ⁠, ⁠ app/models/bid.rb </code>⁠
      allow(assignment).to receive(:sign_up_topics).and_return([topic])
Refactor code segments to eliminate redundancy and promote code reusability. Stick to the design principles listed below.  
      allow(topic).to receive_message_chain(:bids, :includes).and_return([bid])
      allow(bid).to receive_message_chain(:team, :name).and_return(team_name)


== Design Principles ==
      # Mock params
      params = { id: assignment.id }
      allow(controller).to receive(:params).and_return(params)


==== Single Responsibility Principle (SRP): ====
      # Expected data structure from calculate_bidding_summary_based_on_priority
*Each action in the GradesController will be responsible for a specific task related to managing grades.
      expected_topic_data = [
*Actions will be refactored to separate concerns such as data retrieval, computation, and view rendering.
        {
*For example, the `view` action will focus solely on retrieving grading data and rendering the grading report.
          id: topic.id,
          name: topic.topic_name,
          first_bids: 1,
          second_bids: 0,
          third_bids: 0,
          total_bids: 1,
          percentage_first: 100.0,
          bidding_teams: [team_name]
        }
      ]


==== Don't Repeat Yourself Principle (DRY): ====
      # Call the method
*Code duplication in the GradesController will be eliminated by extracting common functionality into helper methods or modules.
      controller.instance_variable_set(:@assignment, assignment)
*Repetitive logic, such as retrieving questions or calculating penalties, will be refactored to promote code reusability and maintainability.
      expect(controller.calculate_bidding_summary_based_on_priority).to eq(expected_topic_data)
    end
  end
</pre>


==== Dependency Inversion Principle (DIP): ====
*tests for background color helper method
*The GradesController will depend on abstractions, interfaces, or higher-level modules instead of concrete implementations.
<pre>
*Dependency injection or inversion of control will be used to decouple the controller from specific database or service implementations.


  # Assuming your helper module is in the helpers folder
  RSpec.describe LotteryHelper, type: :helper do
  # Test for low percentage range
  describe '#background_color_by_percentage' do
    it 'returns light red for low percentages' do
      expect(helper.background_color_by_percentage(10)).to eq('background-color: #ffcccc;')
    end


==RSpec Testing==
    # Test for medium percentage range
    it 'returns light orange for medium percentages' do
      expect(helper.background_color_by_percentage(50)).to eq('background-color: #ffcc99;')
    end


===Files for RSpec Testing ===
    # Test for high percentage range
*assignment_controller_spec.rb: Tests `AssignmentController` actions for bidding details.  
    it 'returns light green for high percentages' do
*assignment_spec.rb: Tests `Assignment` model methods for bidding calculations.
      expect(helper.background_color_by_percentage(80)).to eq('background-color: #ccffcc;')
    end


===RSpec Testing Actions===
    # Test for percentage out of range
*assignment_controller_spec.rb: Tests `bidding_details` and `bidding_details_for_topic` actions.
    it 'returns no background for percentages out of range' do
*assignment_spec.rb : Tests `calculate_percentage_of_teams_getting_choices`, `teams_bidding_for_each_topic`, `bidding_info_by_topic`, and `assigned_teams_for_topics` methods.
      expect(helper.background_color_by_percentage(101)).to eq('background-color: none;')
      expect(helper.background_color_by_percentage(-1)).to eq('background-color: none;')
    end
  end
end
</pre>


===Purpose===
*Ensures individual components and model methods behave as expected. Validates interaction between components for seamless functionality.


===Tools===
*Utilizes RSpec for automated testing. Optionally Capybara for integration testing.


*Execution: Run tests via `rspec` command. Address any failures promptly to maintain code quality.
== Demo Video ==
You can watch this [https://youtu.be/g9DzKE5otSU Demonstration Video]for a detailed demonstration of the project.


== Team ==
== Team ==
'''Mentor:'''
===Mentor:===
*Anvitha Reddy Gutha (agutha@ncsu.edu)
*Anvitha Reddy Gutha (agutha@ncsu.edu)


'''Members: '''
===Members: ===
*Shiva Vara Prasad Kandhagatla (skandha@ncsu.edu)
*Shiva Vara Prasad Kandhagatla (skandha@ncsu.edu)
*Sai Santhosh Garlapati (sgarlap@ncsu.edu)
*Sai Santhosh Garlapati (sgarlap@ncsu.edu)
*Chinmay Walinjkar (cpwalinj@ncsu.edu)
*Chinmay Walinjkar (cpwalinj@ncsu.edu)
===References===
*https://github.com/expertiza/expertiza
*http://expertiza.ncsu.edu/
*http://wiki.expertiza.ncsu.edu/index.php/Expertiza_documentation

Revision as of 17:45, 23 April 2024

Introduction

The Expertiza project is a dynamic collaboration between students and faculty at NC State University, built on the Ruby on Rails platform. It serves as a hub for fostering cooperative learning and academic collaboration, offering a suite of tools for efficient course and assignment management.

Expertiza empowers instructors with comprehensive control over the learning process, providing insights into various academic facets such as user profiles, courses, assignments, questionnaires, and reviews. With its user-friendly interface and innovative features, Expertiza revolutionizes collaborative learning, facilitating seamless topic creation, group formation, and peer review. Join us in embracing the transformative potential of digital collaboration to redefine the educational experience.

Test Login Credentials

  • UserId: instructor6
  • Password: password
  • Problem Statement:

    Current Problem

    • Instructors using Expertiza lack comprehensive visibility into the bidding process, impeding their ability to discern the most sought-after topics by teams and the prioritization of choices, leading to inefficient allocation of projects.

    Key Deficiencies

    • The absence of essential details, such as which teams have bid on specific topics and the percentage of teams assigning their top-choice projects, results in instructors resorting to cumbersome workarounds, hindering effective management and allocation of projects.

    Proposed Solution

    • Enhancing Expertiza's interface with a dedicated view for instructors to access detailed statistics on topic bids, including priority rankings, team names, total bids, and the percentage of teams selecting each topic as their top choice. This solution aims to streamline workflow, empower instructors with valuable insights, and facilitate fair and efficient project allocation.

    Previous Implementations

    1. E2360 Github Repository
    2. E2360 Pull Request
    3. E2360 Wiki Page
    4. Demo Video
    1. E2245 Github Repository
    2. E2245 Pull Request
    3. E2245 Wiki Page
    4. Demo Video

    E2410 Current Implementation

    1. Github Repository
    2. E2410 Pull Request
    3. Demo Video

    Issues With Previous Implementation

    1. Functions directly fetch and process bids in the controller, which could be better managed through model methods for improved organization.
    2. The use of instance variables for bid counts is not scalable and can become problematic with changes in the bidding process.
    3. The current approach of fetching topics and iterating for bids may result in inefficient N+1 queries.
    4. There's a risk of repeating logic related to bidding across different parts of the application.
    5. UI elements and logic are intertwined within the controller, which is not ideal for MVC patterns.
    6. The views have repetitive non-zero checks for bid counts, which could be streamlined.
    7. CSS styles are hard-coded in views, which should be abstracted to CSS files.
    8. Missing error handling could cause unhandled exceptions for nonexistent bids or topics.
    9. Tests might not cover all scenarios, such as incorrect bid priorities or unrepresented teams.
    10. The UI lacks dynamic feedback mechanisms like AJAX updates for user interactions.

    Proposed Solution

    The design presented in this iteration of the project is very similar to the high-level design proposed last year in Fall 2023 Design. Since this pull request was not merged, we have included the proposed changes that are credible. Below is a comparable explanation of the previously offered remedy, as well as some new design decisions to improve upon the previous iteration of this issue.

    We've significantly improved the bidding system in Expertiza by enhancing the visibility and handling of bids for topics. Key improvements include detailed bidding data presentation, with distinct columns for each bid priority and clear team bid information. This offers users, both instructors and students, a transparent view into the bidding outcomes. Additionally, our refined logic more accurately calculates teams' preferred choice percentages, aiding better decision-making in topic assignments. This has also been moved to a separate page, to improve user-experience.

    Design

    Sequence Diagram for Bidding Process

    Current Flow

    • Go to the assignments section, we have created a dummy a assignment, "Test OODD", click edit icon next to it.

    • Now make sure the "has topics" checkbox is selected.

    • Now go to Topics section and click "Show bids by priority" button.

    • Here you will be able to view various stats of the bidding,like the topics with their IDs, their respective topic names, number of teams that have put that specific topic as their 1st 2nd and 3rd priority bid, along with the names of those teams, the total number of bids and finally the percentage of teams that put the specific topic as their first bid.

    Flow of the Bidding Process

    The instructor will login as an instructor, and access the assignments page. Next they will select the assignment from the assignment list and open it for editing. Check the "has topics" checkbox to activate the topics tab and visit it. Now instructor can add a new topic by filling the new topic form. Submit the form and update the topic list. Now the students can start bidding on the topics (assigning their 1st, 2nd and 3rd priorities. Now the instructor can check the bidding details by clicking "show bids by priority" button on the topics page.

    Implementation Details

    Files Modified During the implementation

    • assignments_controller.rb
    • lottery_controller.rb
    • assignment.rb
    • bid.rb
    • team.rb
    • assignment_helper.rb
    • _topics.html.erb
    • bidding_details.html.erb
    • _bid_summary_partial.html.erb

    New functions that are implemented

    1. Display bidding summary based on priority details

    Method for bidding analysis

    File : app/controllers/lottery_controller.rb

    Functionality:

    • Added `calculate_bidding_summary_based_on_priority` method to `lottery_controller` for aggregating bid data per topic.
    • Prepares data for displaying the bidding details for each topic within an assignment.
    • It calculates the number of bids for each priority (1, 2, 3) per topic and also computes
    • The overall percentages of teams that received their first, second, and third choice.
    • This method is responsible for calculating the bidding table data for an assignment.
    • Computes the count of assigned teams for each priority level (1, 2, 3) across all topics.
    • It checks each team associated with a topic and determines if the team's bid matches

    2. Background Color according to percentage

    Method for background color

    File : app/helpers/lottery_helper.rb

    Functionality:

    • Light red for low percentages
    • Light orange for medium percentages
    • Light green for high percentages
    • No background if outside range

    3. Button to show bids by priority

    Button view

    File : app/views/assignments/edit/_topics.html.erb

    Functionality:

    • ⁠Button to visit the seperate page to view the results of bidding

    4. Bidding Summary Table

    Summary Table

    File : app/views/lottery/calculate_bidding_summary_based_on_priority.html.erb

    Functionality:

    • View topics with their IDs,
    • View topic names
    • View number of teams that have bid on that specific topic as their 1st 2nd and 3rd priority bid,
    • View the names of those teams
    • View the total number of bids and finally the percentage of teams that put the specific topic as their first bid.
    • View the percentage of first bids with tooltip and custom background

    Accomplishment

    This project has added a "Bid Summary", which allows the instructor to see all topics with their IDs, their respective topic names, number of teams that have put that specific topic as their 1st 2nd and 3rd priority bid, along with the names of those teams, the total number of bids and finally the percentage of teams that put the specific topic as their first bid. This information will allow us to see which topic is most trending, ie, what is the topic most students want to work on, and which topics are not doing so well. This enables the instructor to get this information without having to login to the student view and figure this out manually.

    Test Plan

    Manual Testing

    Follow these instructions to manually test the below functionality:

    • Navigate to the assignments page and click on the pencil icon next to the 'Test OODD' assignment.
    • Confirm that the 'Has Topics' checkbox is selected on the general assignment settings page.
    • Move to the 'Topics' tab and check the 'Enable bidding for topics' option.
    • Add a new topic for students to bid on by clicking the 'New Topic' button and entering relevant details.
    • Log in as a student and bid on the new topic, choosing the priority level for the bid.
    • Return to the 'Topics' tab as an instructor to view the updated bidding table with bids and priorities listed.
    • Confirm that the total number of bids and the number of #1, #2, and #3 bids are displayed correctly for each topic.
    • Check the background color coding (green, yellow, red) in the bidding table that reflects the intensity of bids for visual verification.

    RSpec Testing

    The assignment_controller_spec.rb has existing automated rspec tests in place. Furthermore following tests were added to the code to ensure the functionality is working as expected and thereby increasing code coverage:-

    • lottery_controller_spec.rb
    • tests for calculate_bidding_summary_based_on_priority in lottery_controller
    describe '#calculate_bidding_summary_based_on_priority' do
        it 'calculates and returns bidding summary data for topics' do
          # Setup test data
          assignment = create(:assignment)
          topic = create(:topic, assignment: assignment)
          team = create(:team, assignment: assignment)
          bid = create(:bid, topic: topic, team: team, priority: 1)
          team_name = create(:team_name, team: team)
    
          allow(Assignment).to receive(:find).with(assignment.id).and_return(assignment)
          allow(assignment).to receive(:sign_up_topics).and_return([topic])
          allow(topic).to receive_message_chain(:bids, :includes).and_return([bid])
          allow(bid).to receive_message_chain(:team, :name).and_return(team_name)
    
          # Mock params
          params = { id: assignment.id }
          allow(controller).to receive(:params).and_return(params)
    
          # Expected data structure from calculate_bidding_summary_based_on_priority
          expected_topic_data = [
            {
              id: topic.id,
              name: topic.topic_name,
              first_bids: 1,
              second_bids: 0,
              third_bids: 0,
              total_bids: 1,
              percentage_first: 100.0,
              bidding_teams: [team_name]
            }
          ]
    
          # Call the method
          controller.instance_variable_set(:@assignment, assignment)
          expect(controller.calculate_bidding_summary_based_on_priority).to eq(expected_topic_data)
        end
      end
    
    • tests for background color helper method
    
      # Assuming your helper module is in the helpers folder
      RSpec.describe LotteryHelper, type: :helper do
      # Test for low percentage range
      describe '#background_color_by_percentage' do
        it 'returns light red for low percentages' do
          expect(helper.background_color_by_percentage(10)).to eq('background-color: #ffcccc;')
        end
    
        # Test for medium percentage range
        it 'returns light orange for medium percentages' do
          expect(helper.background_color_by_percentage(50)).to eq('background-color: #ffcc99;')
        end
    
        # Test for high percentage range
        it 'returns light green for high percentages' do
          expect(helper.background_color_by_percentage(80)).to eq('background-color: #ccffcc;')
        end
    
        # Test for percentage out of range
        it 'returns no background for percentages out of range' do
          expect(helper.background_color_by_percentage(101)).to eq('background-color: none;')
          expect(helper.background_color_by_percentage(-1)).to eq('background-color: none;')
        end
      end
    end
    


    Demo Video

    You can watch this Demonstration Videofor a detailed demonstration of the project.

    Team

    Mentor:

    • Anvitha Reddy Gutha (agutha@ncsu.edu)

    Members:

    • Shiva Vara Prasad Kandhagatla (skandha@ncsu.edu)
    • Sai Santhosh Garlapati (sgarlap@ncsu.edu)
    • Chinmay Walinjkar (cpwalinj@ncsu.edu)

    References