<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Schen76</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Schen76"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Schen76"/>
	<updated>2026-05-16T14:19:32Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152929</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding (Phase2)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152929"/>
		<updated>2023-12-14T20:39:33Z</updated>

		<summary type="html">&lt;p&gt;Schen76: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Motivation ==&lt;br /&gt;
&lt;br /&gt;
The bidding view is needed because we don’t have a way of finding out whether the bidding algorithm is running correctly.  This project is to add a bidding view to show how the topics are assigned to those teams who bid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Work Plan ==&lt;br /&gt;
&lt;br /&gt;
Based on the project's objectives and feedback received from our mentor, we have identified specific areas for improvement:&lt;br /&gt;
&lt;br /&gt;
1) Refactor variable names within methods such as &amp;quot;bidding_details&amp;quot; and variables like &amp;quot;Topic name&amp;quot; and &amp;quot;Bidding teams&amp;quot; to enhance clarity and specificity.&lt;br /&gt;
&lt;br /&gt;
2) Adjust capitalization for certain components, ensuring that only the first word is capitalized for consistency.&lt;br /&gt;
&lt;br /&gt;
3) Introduce calculations to determine percentages based on additional data, such as the total number of teams and the number of teams for each priority, within the &amp;quot;lottery_controller.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4) Conduct thorough testing of the modified controller and view to ensure optimal functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Newfeature.jpg | 888px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To add functionality for showing the percentages of the number of teams that got their #1, #2, and #3 choices. We can follow these high-level steps:&lt;br /&gt;
&lt;br /&gt;
'''Lottery_Controller:'''&lt;br /&gt;
&lt;br /&gt;
i) Compute the Total Number of Teams: Before we can compute percentages, we need to know the total number of teams that participated in the bidding process. This will be our denominator in the percentage calculation.&lt;br /&gt;
&lt;br /&gt;
ii) Compute the Number of Teams for Each Priority: From our `bidding_details` method, we already have counts for how many teams bid on each topic as their #1, #2, and #3 choice (`@count1`, `@count2`, `@count3`). However, these counts are currently organized by topic. We would need to modify this to count how many teams got their #1, #2, and #3 choices as their assigned topic.&lt;br /&gt;
&lt;br /&gt;
iii) Compute Percentages: Once we have the number of teams that got their #1, #2, and #3 choices, we can compute the percentages by dividing these numbers by the total number of teams and multiplying by 100.&lt;br /&gt;
&lt;br /&gt;
'''Bidding_detail view:'''&lt;br /&gt;
&lt;br /&gt;
i) Update the View and Display Percentages: Above the table in our previous view, we can add a section to display these percentages.&lt;br /&gt;
&lt;br /&gt;
ii) Format the Display: We will use a bold heading for each percentage type and format the number to a fixed number of decimal places.&lt;br /&gt;
&lt;br /&gt;
iii) Ensure Responsiveness: Make sure the display of these percentages adjusts well to different screen sizes, maintaining readability and layout consistency.&lt;br /&gt;
&lt;br /&gt;
== Code Effort ==&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; app/controllers/lottery_controller.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 1: bidding_table_for_topics'''&lt;br /&gt;
&lt;br /&gt;
This method generates a bidding table for each topic within an assignment. It performs several operations to gather and organize data related to topics, bids, and teams. Here's a breakdown of what the code does:&lt;br /&gt;
&lt;br /&gt;
1. Fetch Assignment:&lt;br /&gt;
&lt;br /&gt;
*It retrieves the assignment with the specified params[:id] from the database and stores it in the @assignment instance variable.&lt;br /&gt;
&lt;br /&gt;
2. Fetch Topics:&lt;br /&gt;
&lt;br /&gt;
*It retrieves all sign-up topics associated with the assignment and stores them in the @topics instance variable.&lt;br /&gt;
&lt;br /&gt;
3. Fetch Bids and Assigned Teams:&lt;br /&gt;
&lt;br /&gt;
For each topic in @topics, it:&lt;br /&gt;
*Retrieves all bids associated with that topic and stores them in a hash, where the key is the topic's ID and the value is an array of bids with their associated teams and priorities.&lt;br /&gt;
*Retrieves teams that are not waitlisted for the topic and stores them in a hash, again using the topic's ID as the key and an array of teams as the value.&lt;br /&gt;
&lt;br /&gt;
4. Priority Count Calculation:&lt;br /&gt;
&lt;br /&gt;
*It dynamically computes and updates the counts for each bid priority level (1, 2, and 3) for each topic. These counts are stored in instance variables named @count1, @count2, and @count3. These instance variables are hashes where the keys are topic IDs, and the values are counts for each priority level.&lt;br /&gt;
&lt;br /&gt;
5. Computes Total Teams:&lt;br /&gt;
&lt;br /&gt;
*It determines the total number of teams across all topics in the assignment by counting distinct team IDs among all non-waitlisted teams for the specified topics.&lt;br /&gt;
&lt;br /&gt;
6. Computes Priority Counts and Percentages:&lt;br /&gt;
&lt;br /&gt;
*It calls two helper methods, compute_priority_counts and compute_percentages, to compute the total counts of teams at each priority level and the corresponding percentages. The results are stored in the @priority_counts and @percentages instance variables, respectively.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Prepares data for displaying the bidding details for each topic within an assignment.&lt;br /&gt;
  # It computes the number of bids for each priority (1, 2, 3) per topic and also computes&lt;br /&gt;
  # the overall percentages of teams that received their first, second, and third choice.&lt;br /&gt;
  def bidding_table_for_topics&lt;br /&gt;
    @assignment = Assignment.find(params[:id])&lt;br /&gt;
    # Fetch all topics for the assignment&lt;br /&gt;
    @topics = @assignment.sign_up_topics&lt;br /&gt;
    # Fetch all bids for these topics&lt;br /&gt;
    @bids_by_topic = {}&lt;br /&gt;
    @assigned_teams_by_topic = {} # This will store the assigned teams for each topic&lt;br /&gt;
    @topics.each do |topic|&lt;br /&gt;
      # Assuming bids are stored with a topic_id, and each bid has a team associated with it&lt;br /&gt;
      @bids_by_topic[topic.id] = Bid.where(topic_id: topic.id).map { |bid| { team: bid.team, priority: bid.priority } }&lt;br /&gt;
      # Fetch teams that are not waitlisted for this topic&lt;br /&gt;
      @assigned_teams_by_topic[topic.id] = SignedUpTeam.where(topic_id: topic.id, is_waitlisted: false).map(&amp;amp;:team)      &lt;br /&gt;
      # Dynamically initializing and updating @count1, @count2, and @count3&lt;br /&gt;
      (1..3).each do |priority|&lt;br /&gt;
        instance_variable_set(&amp;quot;@count#{priority}&amp;quot;, Hash.new(0)) unless instance_variable_defined?(&amp;quot;@count#{priority}&amp;quot;)&lt;br /&gt;
        instance_variable_get(&amp;quot;@count#{priority}&amp;quot;)[topic.id] = @bids_by_topic[topic.id].count { |bid| bid[:priority] == priority }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # Computes the total number of teams and percentages after fetching bid details&lt;br /&gt;
    topic_ids = SignUpTopic.where(assignment_id: @assignment.id).pluck(:id)&lt;br /&gt;
    @total_teams = SignedUpTeam.where(topic_id: topic_ids).distinct.count(:team_id)&lt;br /&gt;
    @priority_counts = compute_priority_counts(@assigned_teams_by_topic, @bids_by_topic)&lt;br /&gt;
    @percentages = compute_percentages(@priority_counts, @total_teams)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 2: compute_priority_counts'''&lt;br /&gt;
&lt;br /&gt;
1. Parameters&lt;br /&gt;
*assigned_teams_by_topic (Hash): A hash mapping each topic to an array of assigned teams.&lt;br /&gt;
*bids_by_topic (Hash): A hash mapping each topic to an array of bid objects, where each bid object is a hash containing team and priority information.&lt;br /&gt;
&lt;br /&gt;
2. Functionality&lt;br /&gt;
*Initial Setup: Initializes a hash priority_counts with keys 1, 2, and 3, each having an initial value of 0. These keys represent the priority levels, and their values count the number of teams assigned to each level.&lt;br /&gt;
&lt;br /&gt;
*Iterating Over Topics and Teams: Iterates over each topic and its associated teams found in assigned_teams_by_topic. For each team in a topic, the method searches bids_by_topic[topic_id] to find a bid made by the team.&lt;br /&gt;
&lt;br /&gt;
*Updating Priority Counts: If a bid is found, the method increments the count in priority_counts corresponding to the priority level in the bid. This process effectively tallies the number of teams assigned to each priority level.&lt;br /&gt;
&lt;br /&gt;
3. Returns&lt;br /&gt;
*priority_counts (Hash): A hash with keys 1, 2, and 3, where each key's value represents the count of teams assigned to that respective priority level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Computes the count of assigned teams for each priority level (1, 2, 3) across all topics.&lt;br /&gt;
  # It checks each team associated with a topic and determines if the team's bid matches&lt;br /&gt;
  # one of the priority levels, incrementing the respective count if so.&lt;br /&gt;
  def compute_priority_counts(assigned_teams_by_topic, bids_by_topic)&lt;br /&gt;
    priority_counts = { 1 =&amp;gt; 0, 2 =&amp;gt; 0, 3 =&amp;gt; 0 }&lt;br /&gt;
    assigned_teams_by_topic.each do |topic_id, teams|&lt;br /&gt;
      teams.each do |team|&lt;br /&gt;
        bid_info = bids_by_topic[topic_id].find { |bid| bid[:team] == team }&lt;br /&gt;
        priority_counts[bid_info[:priority]] += 1 if bid_info&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    priority_counts&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 3: compute_percentages'''&lt;br /&gt;
&lt;br /&gt;
* This method computes the percentages of teams that received their first, second, and third choice based on the counts of teams at each priority level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Computes the percentages of teams that received their first, second, and third choice&lt;br /&gt;
  # based on the counts of teams at each priority level.&lt;br /&gt;
  def compute_percentages(priority_counts, total_teams)&lt;br /&gt;
    priority_counts.transform_values { |count| (count.to_f / total_teams * 100).round(2) }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_topics.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:bidding_percentage.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Components:&lt;br /&gt;
&lt;br /&gt;
1. Percentage Display Section&lt;br /&gt;
&lt;br /&gt;
*This section is styled with a border, padding, and a background color to make it visually distinct.&lt;br /&gt;
*It contains a subtitle (h4) describing the content: &amp;quot;Percentage of Teams Getting Their Choices.&amp;quot;&lt;br /&gt;
*A list (ul) displays the percentages of teams that received their 1st, 2nd, and 3rd choice. These percentages are pulled dynamically from @percentages array.&lt;br /&gt;
*The colors of the percentage values vary based on the choice priority (green for #1, orange for #2, and red for #3).&lt;br /&gt;
Custom CSS Styles&lt;br /&gt;
&lt;br /&gt;
2. Bidding Details Table&lt;br /&gt;
&lt;br /&gt;
*A table with headers for Topic ID, Topic Name, Bidding Teams, and bids.&lt;br /&gt;
*The table body (&amp;lt;tbody&amp;gt;) dynamically generates rows for each topic using a loop (&amp;lt;% @topics.each do |topic| %&amp;gt;).&lt;br /&gt;
*For each topic, the table displays its name, ID, bidding teams, and the number of bids for each choice.&lt;br /&gt;
*Teams are marked with the .assigned-team class if they are assigned to the topic.&lt;br /&gt;
*Bid counts are displayed, with a placeholder (&amp;quot;–&amp;quot;) if the count is zero.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;table class=&amp;quot;table table-bordered table-hover&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;thead&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic id&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic name&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Bidding teams&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#1 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#2 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#3 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;/thead&amp;gt;&lt;br /&gt;
  &amp;lt;tbody&amp;gt;&lt;br /&gt;
    &amp;lt;% @topics.each do |topic| %&amp;gt;&lt;br /&gt;
      &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.id %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.topic_name %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;teams-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% @bids_by_topic[topic.id].each do |bid_info| %&amp;gt;&lt;br /&gt;
            &amp;lt;% team = bid_info[:team] %&amp;gt;&lt;br /&gt;
            &amp;lt;% assigned_team = @assigned_teams_by_topic[topic.id].include?(team) %&amp;gt;&lt;br /&gt;
            &amp;lt;span class=&amp;quot;&amp;lt;%= assigned_team ? 'assigned-team' : '' %&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;%= team.name %&amp;gt; (#&amp;lt;%= bid_info[:priority] %&amp;gt;)&lt;br /&gt;
            &amp;lt;/span&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count1[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count1[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count2[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count2[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count3[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count3[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
      &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;% end %&amp;gt;&lt;br /&gt;
  &amp;lt;/tbody&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
1. Test for Populating Bids and Assigned Teams:&lt;br /&gt;
*This test ensures that the bidding_table_for_each_topic method correctly populates bids and assigned teams for each topic.&lt;br /&gt;
*It checks if @bids_by_topic is populated correctly, verifying the length of bids for specific topics.&lt;br /&gt;
*It tests @assigned_teams_by_topic, ensuring it handles cases where topics have no teams.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    it 'populates bids and assigned teams for each topic, handling topics with no teams' do&lt;br /&gt;
        controller.bidding_table_for_each_topic&lt;br /&gt;
        # Check if @bids_by_topic is populated correctly&lt;br /&gt;
        expect(controller.instance_variable_get(:@bids_by_topic)[topic1.id].length).to eq(1)&lt;br /&gt;
        expect(controller.instance_variable_get(:@bids_by_topic)[topic2.id].length).to eq(1)&lt;br /&gt;
        # Check if @assigned_teams_by_topic is populated correctly, allowing for no teams&lt;br /&gt;
        assigned_teams_topic1 = controller.instance_variable_get(:@assigned_teams_by_topic)[topic1.id]&lt;br /&gt;
        if assigned_teams_topic1&lt;br /&gt;
            expect(assigned_teams_topic1.length).to(satisfy { |value| (value == 0) || (value == 1) })&lt;br /&gt;
        else&lt;br /&gt;
            expect(assigned_teams_topic1).to be_nil&lt;br /&gt;
        end&lt;br /&gt;
        # Check the counts of bids for each priority level&lt;br /&gt;
        # Ensure to adjust these based on what is set up in your test data&lt;br /&gt;
        expect(controller.instance_variable_get(:@count1)[topic1.id]).to eq(1)&lt;br /&gt;
        # assuming there is one bid with priority 1 for topic1&lt;br /&gt;
        expect(controller.instance_variable_get(:@count2)[topic1.id]).to eq(0)&lt;br /&gt;
        # assuming there are no bids with priority 2 for topic1&lt;br /&gt;
        expect(controller.instance_variable_get(:@count3)[topic1.id]).to eq(0)&lt;br /&gt;
        # assuming there are no bids with priority 3 for topic1&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Test for Fetching All Topics:&lt;br /&gt;
*This test verifies that all topics for the assignment are fetched and stored in @topics.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    it 'fetches all topics for the assignment' do&lt;br /&gt;
        controller.bidding_table_for_each_topic&lt;br /&gt;
        expect(controller.instance_variable_get(:@topics)).to match_array([topic1, topic2, topic3, topic4])&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Test for Computing Priority Counts:&lt;br /&gt;
*This test checks the calculation of priority counts for each topic.&lt;br /&gt;
*It compares the computed priority counts against an expected set of values.&lt;br /&gt;
*It verifies the priority count is computing the values precisely for topics.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    it 'correctly calculates priority counts for each topic' do&lt;br /&gt;
        controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
        # Assuming you have a way to know the expected counts for each priority&lt;br /&gt;
        expected_priority_counts = { 1 =&amp;gt; 0, &lt;br /&gt;
                                     2 =&amp;gt; 0, &lt;br /&gt;
                                     3 =&amp;gt; 0 }&lt;br /&gt;
  &lt;br /&gt;
        priority_counts = controller.instance_variable_get(:@priority_counts)&lt;br /&gt;
        expect(priority_counts).to eq(expected_priority_counts)&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Test for Computing Percentages for Teams Getting Their Choices:&lt;br /&gt;
*This test ensures that the method correctly computes the percentages of teams getting their preferred choices.&lt;br /&gt;
*It handles special cases where the expected percentages are not a number (NaN).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    it 'correctly calculates percentages for teams getting their choices' do&lt;br /&gt;
        controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
        # Assuming you have a way to know the expected percentages&lt;br /&gt;
        expected_percentages = { 1 =&amp;gt; Float::NAN, &lt;br /&gt;
                                 2 =&amp;gt; Float::NAN, &lt;br /&gt;
                                 3 =&amp;gt; Float::NAN }&lt;br /&gt;
  &lt;br /&gt;
        percentages = controller.instance_variable_get(:@percentages)&lt;br /&gt;
        expect(percentages[1].nan?).to be true if expected_percentages[1].nan?&lt;br /&gt;
        expect(percentages[2].nan?).to be true if expected_percentages[2].nan?&lt;br /&gt;
        expect(percentages[3].nan?).to be true if expected_percentages[3].nan?&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rspec Testing &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_each_topic.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
&lt;br /&gt;
'''Github Repository: ''' https://github.com/Shreshth-Malik/expertiza&lt;br /&gt;
&lt;br /&gt;
'''Demo Video:''' https://www.youtube.com/watch?v=pGmHyqLj7PM&lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/expertiza/pull/2659&lt;br /&gt;
&lt;br /&gt;
== Testing Credentials ==&lt;br /&gt;
&lt;br /&gt;
username: instructor6&lt;br /&gt;
&lt;br /&gt;
password: password&lt;br /&gt;
&lt;br /&gt;
== Team == &lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Edward F. Gehringer (efg@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
'''Members'''&lt;br /&gt;
&lt;br /&gt;
Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shreshth Malik (smalik4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shuai Chen (schen76@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152928</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding (Phase2)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152928"/>
		<updated>2023-12-14T20:38:34Z</updated>

		<summary type="html">&lt;p&gt;Schen76: /* Work Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Motivation ==&lt;br /&gt;
&lt;br /&gt;
The bidding view is needed because we don’t have a way of finding out whether the bidding algorithm is running correctly.  This project is to add a bidding view to show how the topics are assigned to those teams who bid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Work Plan ==&lt;br /&gt;
&lt;br /&gt;
Based on the project's objectives and feedback received from our mentor, we have identified specific areas for improvement:&lt;br /&gt;
&lt;br /&gt;
1) Refactor variable names within methods such as &amp;quot;bidding_details&amp;quot; and variables like &amp;quot;Topic name&amp;quot; and &amp;quot;Bidding teams&amp;quot; to enhance clarity and specificity.&lt;br /&gt;
&lt;br /&gt;
2) Adjust capitalization for certain components, ensuring that only the first word is capitalized for consistency.&lt;br /&gt;
&lt;br /&gt;
3) Introduce calculations to determine percentages based on additional data, such as the total number of teams and the number of teams for each priority, within the &amp;quot;lottery_controller.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4) Conduct thorough testing of the modified controller and view to ensure optimal functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Newfeature.jpg | 888px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To add functionality for showing the percentages of the number of teams that got their #1, #2, and #3 choices. We can follow these high-level steps:&lt;br /&gt;
&lt;br /&gt;
'''Lottery_Controller:'''&lt;br /&gt;
&lt;br /&gt;
i) Compute the Total Number of Teams: Before we can compute percentages, we need to know the total number of teams that participated in the bidding process. This will be our denominator in the percentage calculation.&lt;br /&gt;
&lt;br /&gt;
ii) Compute the Number of Teams for Each Priority: From our `bidding_details` method, we already have counts for how many teams bid on each topic as their #1, #2, and #3 choice (`@count1`, `@count2`, `@count3`). However, these counts are currently organized by topic. We would need to modify this to count how many teams got their #1, #2, and #3 choices as their assigned topic.&lt;br /&gt;
&lt;br /&gt;
iii) Compute Percentages: Once we have the number of teams that got their #1, #2, and #3 choices, we can compute the percentages by dividing these numbers by the total number of teams and multiplying by 100.&lt;br /&gt;
&lt;br /&gt;
'''Bidding_detail view:'''&lt;br /&gt;
&lt;br /&gt;
i) Update the View and Display Percentages: Above the table in our previous view, we can add a section to display these percentages.&lt;br /&gt;
&lt;br /&gt;
ii) Format the Display: We will use a bold heading for each percentage type and format the number to a fixed number of decimal places.&lt;br /&gt;
&lt;br /&gt;
iii) Ensure Responsiveness: Make sure the display of these percentages adjusts well to different screen sizes, maintaining readability and layout consistency.&lt;br /&gt;
&lt;br /&gt;
== Code Effort ==&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; app/controllers/lottery_controller.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 1: bidding_table_for_topics'''&lt;br /&gt;
&lt;br /&gt;
This method generates a bidding table for each topic within an assignment. It performs several operations to gather and organize data related to topics, bids, and teams. Here's a breakdown of what the code does:&lt;br /&gt;
&lt;br /&gt;
1. Fetch Assignment:&lt;br /&gt;
&lt;br /&gt;
*It retrieves the assignment with the specified params[:id] from the database and stores it in the @assignment instance variable.&lt;br /&gt;
&lt;br /&gt;
2. Fetch Topics:&lt;br /&gt;
&lt;br /&gt;
*It retrieves all sign-up topics associated with the assignment and stores them in the @topics instance variable.&lt;br /&gt;
&lt;br /&gt;
3. Fetch Bids and Assigned Teams:&lt;br /&gt;
&lt;br /&gt;
For each topic in @topics, it:&lt;br /&gt;
*Retrieves all bids associated with that topic and stores them in a hash, where the key is the topic's ID and the value is an array of bids with their associated teams and priorities.&lt;br /&gt;
*Retrieves teams that are not waitlisted for the topic and stores them in a hash, again using the topic's ID as the key and an array of teams as the value.&lt;br /&gt;
&lt;br /&gt;
4. Priority Count Calculation:&lt;br /&gt;
&lt;br /&gt;
*It dynamically computes and updates the counts for each bid priority level (1, 2, and 3) for each topic. These counts are stored in instance variables named @count1, @count2, and @count3. These instance variables are hashes where the keys are topic IDs, and the values are counts for each priority level.&lt;br /&gt;
&lt;br /&gt;
5. Computes Total Teams:&lt;br /&gt;
&lt;br /&gt;
*It determines the total number of teams across all topics in the assignment by counting distinct team IDs among all non-waitlisted teams for the specified topics.&lt;br /&gt;
&lt;br /&gt;
6. Computes Priority Counts and Percentages:&lt;br /&gt;
&lt;br /&gt;
*It calls two helper methods, compute_priority_counts and compute_percentages, to compute the total counts of teams at each priority level and the corresponding percentages. The results are stored in the @priority_counts and @percentages instance variables, respectively.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Prepares data for displaying the bidding details for each topic within an assignment.&lt;br /&gt;
  # It computes the number of bids for each priority (1, 2, 3) per topic and also computes&lt;br /&gt;
  # the overall percentages of teams that received their first, second, and third choice.&lt;br /&gt;
  def bidding_table_for_topics&lt;br /&gt;
    @assignment = Assignment.find(params[:id])&lt;br /&gt;
    # Fetch all topics for the assignment&lt;br /&gt;
    @topics = @assignment.sign_up_topics&lt;br /&gt;
    # Fetch all bids for these topics&lt;br /&gt;
    @bids_by_topic = {}&lt;br /&gt;
    @assigned_teams_by_topic = {} # This will store the assigned teams for each topic&lt;br /&gt;
    @topics.each do |topic|&lt;br /&gt;
      # Assuming bids are stored with a topic_id, and each bid has a team associated with it&lt;br /&gt;
      @bids_by_topic[topic.id] = Bid.where(topic_id: topic.id).map { |bid| { team: bid.team, priority: bid.priority } }&lt;br /&gt;
      # Fetch teams that are not waitlisted for this topic&lt;br /&gt;
      @assigned_teams_by_topic[topic.id] = SignedUpTeam.where(topic_id: topic.id, is_waitlisted: false).map(&amp;amp;:team)      &lt;br /&gt;
      # Dynamically initializing and updating @count1, @count2, and @count3&lt;br /&gt;
      (1..3).each do |priority|&lt;br /&gt;
        instance_variable_set(&amp;quot;@count#{priority}&amp;quot;, Hash.new(0)) unless instance_variable_defined?(&amp;quot;@count#{priority}&amp;quot;)&lt;br /&gt;
        instance_variable_get(&amp;quot;@count#{priority}&amp;quot;)[topic.id] = @bids_by_topic[topic.id].count { |bid| bid[:priority] == priority }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # Computes the total number of teams and percentages after fetching bid details&lt;br /&gt;
    topic_ids = SignUpTopic.where(assignment_id: @assignment.id).pluck(:id)&lt;br /&gt;
    @total_teams = SignedUpTeam.where(topic_id: topic_ids).distinct.count(:team_id)&lt;br /&gt;
    @priority_counts = compute_priority_counts(@assigned_teams_by_topic, @bids_by_topic)&lt;br /&gt;
    @percentages = compute_percentages(@priority_counts, @total_teams)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 2: compute_priority_counts'''&lt;br /&gt;
&lt;br /&gt;
1. Parameters&lt;br /&gt;
*assigned_teams_by_topic (Hash): A hash mapping each topic to an array of assigned teams.&lt;br /&gt;
*bids_by_topic (Hash): A hash mapping each topic to an array of bid objects, where each bid object is a hash containing team and priority information.&lt;br /&gt;
&lt;br /&gt;
2. Functionality&lt;br /&gt;
*Initial Setup: Initializes a hash priority_counts with keys 1, 2, and 3, each having an initial value of 0. These keys represent the priority levels, and their values count the number of teams assigned to each level.&lt;br /&gt;
&lt;br /&gt;
*Iterating Over Topics and Teams: Iterates over each topic and its associated teams found in assigned_teams_by_topic. For each team in a topic, the method searches bids_by_topic[topic_id] to find a bid made by the team.&lt;br /&gt;
&lt;br /&gt;
*Updating Priority Counts: If a bid is found, the method increments the count in priority_counts corresponding to the priority level in the bid. This process effectively tallies the number of teams assigned to each priority level.&lt;br /&gt;
&lt;br /&gt;
3. Returns&lt;br /&gt;
*priority_counts (Hash): A hash with keys 1, 2, and 3, where each key's value represents the count of teams assigned to that respective priority level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Computes the count of assigned teams for each priority level (1, 2, 3) across all topics.&lt;br /&gt;
  # It checks each team associated with a topic and determines if the team's bid matches&lt;br /&gt;
  # one of the priority levels, incrementing the respective count if so.&lt;br /&gt;
  def compute_priority_counts(assigned_teams_by_topic, bids_by_topic)&lt;br /&gt;
    priority_counts = { 1 =&amp;gt; 0, 2 =&amp;gt; 0, 3 =&amp;gt; 0 }&lt;br /&gt;
    assigned_teams_by_topic.each do |topic_id, teams|&lt;br /&gt;
      teams.each do |team|&lt;br /&gt;
        bid_info = bids_by_topic[topic_id].find { |bid| bid[:team] == team }&lt;br /&gt;
        priority_counts[bid_info[:priority]] += 1 if bid_info&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    priority_counts&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 3: compute_percentages'''&lt;br /&gt;
&lt;br /&gt;
* This method computes the percentages of teams that received their first, second, and third choice based on the counts of teams at each priority level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Computes the percentages of teams that received their first, second, and third choice&lt;br /&gt;
  # based on the counts of teams at each priority level.&lt;br /&gt;
  def compute_percentages(priority_counts, total_teams)&lt;br /&gt;
    priority_counts.transform_values { |count| (count.to_f / total_teams * 100).round(2) }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_topics.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:bidding_percentage.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Components:&lt;br /&gt;
&lt;br /&gt;
1. Percentage Display Section&lt;br /&gt;
&lt;br /&gt;
*This section is styled with a border, padding, and a background color to make it visually distinct.&lt;br /&gt;
*It contains a subtitle (h4) describing the content: &amp;quot;Percentage of Teams Getting Their Choices.&amp;quot;&lt;br /&gt;
*A list (ul) displays the percentages of teams that received their 1st, 2nd, and 3rd choice. These percentages are pulled dynamically from @percentages array.&lt;br /&gt;
*The colors of the percentage values vary based on the choice priority (green for #1, orange for #2, and red for #3).&lt;br /&gt;
Custom CSS Styles&lt;br /&gt;
&lt;br /&gt;
2. Bidding Details Table&lt;br /&gt;
&lt;br /&gt;
*A table with headers for Topic ID, Topic Name, Bidding Teams, and bids.&lt;br /&gt;
*The table body (&amp;lt;tbody&amp;gt;) dynamically generates rows for each topic using a loop (&amp;lt;% @topics.each do |topic| %&amp;gt;).&lt;br /&gt;
*For each topic, the table displays its name, ID, bidding teams, and the number of bids for each choice.&lt;br /&gt;
*Teams are marked with the .assigned-team class if they are assigned to the topic.&lt;br /&gt;
*Bid counts are displayed, with a placeholder (&amp;quot;–&amp;quot;) if the count is zero.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;table class=&amp;quot;table table-bordered table-hover&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;thead&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic id&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic name&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Bidding teams&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#1 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#2 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#3 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;/thead&amp;gt;&lt;br /&gt;
  &amp;lt;tbody&amp;gt;&lt;br /&gt;
    &amp;lt;% @topics.each do |topic| %&amp;gt;&lt;br /&gt;
      &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.id %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.topic_name %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;teams-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% @bids_by_topic[topic.id].each do |bid_info| %&amp;gt;&lt;br /&gt;
            &amp;lt;% team = bid_info[:team] %&amp;gt;&lt;br /&gt;
            &amp;lt;% assigned_team = @assigned_teams_by_topic[topic.id].include?(team) %&amp;gt;&lt;br /&gt;
            &amp;lt;span class=&amp;quot;&amp;lt;%= assigned_team ? 'assigned-team' : '' %&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;%= team.name %&amp;gt; (#&amp;lt;%= bid_info[:priority] %&amp;gt;)&lt;br /&gt;
            &amp;lt;/span&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count1[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count1[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count2[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count2[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count3[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count3[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
      &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;% end %&amp;gt;&lt;br /&gt;
  &amp;lt;/tbody&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
1. Test for Populating Bids and Assigned Teams:&lt;br /&gt;
*This test ensures that the bidding_table_for_each_topic method correctly populates bids and assigned teams for each topic.&lt;br /&gt;
*It checks if @bids_by_topic is populated correctly, verifying the length of bids for specific topics.&lt;br /&gt;
*It tests @assigned_teams_by_topic, ensuring it handles cases where topics have no teams.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    it 'populates bids and assigned teams for each topic, handling topics with no teams' do&lt;br /&gt;
        controller.bidding_table_for_each_topic&lt;br /&gt;
        # Check if @bids_by_topic is populated correctly&lt;br /&gt;
        expect(controller.instance_variable_get(:@bids_by_topic)[topic1.id].length).to eq(1)&lt;br /&gt;
        expect(controller.instance_variable_get(:@bids_by_topic)[topic2.id].length).to eq(1)&lt;br /&gt;
        # Check if @assigned_teams_by_topic is populated correctly, allowing for no teams&lt;br /&gt;
        assigned_teams_topic1 = controller.instance_variable_get(:@assigned_teams_by_topic)[topic1.id]&lt;br /&gt;
        if assigned_teams_topic1&lt;br /&gt;
            expect(assigned_teams_topic1.length).to(satisfy { |value| (value == 0) || (value == 1) })&lt;br /&gt;
        else&lt;br /&gt;
            expect(assigned_teams_topic1).to be_nil&lt;br /&gt;
        end&lt;br /&gt;
        # Check the counts of bids for each priority level&lt;br /&gt;
        # Ensure to adjust these based on what is set up in your test data&lt;br /&gt;
        expect(controller.instance_variable_get(:@count1)[topic1.id]).to eq(1)&lt;br /&gt;
        # assuming there is one bid with priority 1 for topic1&lt;br /&gt;
        expect(controller.instance_variable_get(:@count2)[topic1.id]).to eq(0)&lt;br /&gt;
        # assuming there are no bids with priority 2 for topic1&lt;br /&gt;
        expect(controller.instance_variable_get(:@count3)[topic1.id]).to eq(0)&lt;br /&gt;
        # assuming there are no bids with priority 3 for topic1&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Test for Fetching All Topics:&lt;br /&gt;
*This test verifies that all topics for the assignment are fetched and stored in @topics.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    it 'fetches all topics for the assignment' do&lt;br /&gt;
        controller.bidding_table_for_each_topic&lt;br /&gt;
        expect(controller.instance_variable_get(:@topics)).to match_array([topic1, topic2, topic3, topic4])&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Test for Calculating Priority Counts:&lt;br /&gt;
*This test checks the calculation of priority counts for each topic.&lt;br /&gt;
*It compares the calculated priority counts against an expected set of values.&lt;br /&gt;
*It verifies the priority count is computing the values precisely for topics.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    it 'correctly calculates priority counts for each topic' do&lt;br /&gt;
        controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
        # Assuming you have a way to know the expected counts for each priority&lt;br /&gt;
        expected_priority_counts = { 1 =&amp;gt; 0, &lt;br /&gt;
                                     2 =&amp;gt; 0, &lt;br /&gt;
                                     3 =&amp;gt; 0 }&lt;br /&gt;
  &lt;br /&gt;
        priority_counts = controller.instance_variable_get(:@priority_counts)&lt;br /&gt;
        expect(priority_counts).to eq(expected_priority_counts)&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Test for Calculating Percentages for Teams Getting Their Choices:&lt;br /&gt;
*This test ensures that the method correctly calculates the percentages of teams getting their preferred choices.&lt;br /&gt;
*It handles special cases where the expected percentages are not a number (NaN).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    it 'correctly calculates percentages for teams getting their choices' do&lt;br /&gt;
        controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
        # Assuming you have a way to know the expected percentages&lt;br /&gt;
        expected_percentages = { 1 =&amp;gt; Float::NAN, &lt;br /&gt;
                                 2 =&amp;gt; Float::NAN, &lt;br /&gt;
                                 3 =&amp;gt; Float::NAN }&lt;br /&gt;
  &lt;br /&gt;
        percentages = controller.instance_variable_get(:@percentages)&lt;br /&gt;
        expect(percentages[1].nan?).to be true if expected_percentages[1].nan?&lt;br /&gt;
        expect(percentages[2].nan?).to be true if expected_percentages[2].nan?&lt;br /&gt;
        expect(percentages[3].nan?).to be true if expected_percentages[3].nan?&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rspec Testing &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_each_topic.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
&lt;br /&gt;
'''Github Repository: ''' https://github.com/Shreshth-Malik/expertiza&lt;br /&gt;
&lt;br /&gt;
'''Demo Video:''' https://www.youtube.com/watch?v=pGmHyqLj7PM&lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/expertiza/pull/2659&lt;br /&gt;
&lt;br /&gt;
== Testing Credentials ==&lt;br /&gt;
&lt;br /&gt;
username: instructor6&lt;br /&gt;
&lt;br /&gt;
password: password&lt;br /&gt;
&lt;br /&gt;
== Team == &lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Edward F. Gehringer (efg@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
'''Members'''&lt;br /&gt;
&lt;br /&gt;
Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shreshth Malik (smalik4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shuai Chen (schen76@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152927</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding (Phase2)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152927"/>
		<updated>2023-12-14T20:36:33Z</updated>

		<summary type="html">&lt;p&gt;Schen76: /* Code Effort */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Motivation ==&lt;br /&gt;
&lt;br /&gt;
The bidding view is needed because we don’t have a way of finding out whether the bidding algorithm is running correctly.  This project is to add a bidding view to show how the topics are assigned to those teams who bid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Work Plan ==&lt;br /&gt;
&lt;br /&gt;
Based on the project's objectives and feedback received from our mentor, we have identified specific areas for improvement:&lt;br /&gt;
&lt;br /&gt;
1) Refactor variable names within methods such as &amp;quot;bidding_details&amp;quot; and variables like &amp;quot;Topic name&amp;quot; and &amp;quot;Bidding teams&amp;quot; to enhance clarity and specificity.&lt;br /&gt;
&lt;br /&gt;
2) Adjust capitalization for certain components, ensuring that only the first word is capitalized for consistency.&lt;br /&gt;
&lt;br /&gt;
3) Introduce calculations to determine percentages based on additional data, such as the total number of teams and the number of teams for each priority, within the &amp;quot;lottery_controller.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4) Conduct thorough testing of the modified controller and view to ensure optimal functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Newfeature.jpg | 888px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To add functionality for showing the percentages of the number of teams that got their #1, #2, and #3 choices. We can follow these high-level steps:&lt;br /&gt;
&lt;br /&gt;
'''Lottery_Controller:'''&lt;br /&gt;
&lt;br /&gt;
i) Calculate the Total Number of Teams: Before we can calculate percentages, we need to know the total number of teams that participated in the bidding process. This will be our denominator in the percentage calculation.&lt;br /&gt;
&lt;br /&gt;
ii) Calculate the Number of Teams for Each Priority: From our `bidding_details` method, we already have counts for how many teams bid on each topic as their #1, #2, and #3 choice (`@count1`, `@count2`, `@count3`). However, these counts are currently organized by topic. We would need to modify this to count how many teams got their #1, #2, and #3 choices as their assigned topic.&lt;br /&gt;
&lt;br /&gt;
iii) Calculate Percentages: Once we have the number of teams that got their #1, #2, and #3 choices, we can calculate the percentages by dividing these numbers by the total number of teams and multiplying by 100.&lt;br /&gt;
&lt;br /&gt;
'''Bidding_detail view:'''&lt;br /&gt;
&lt;br /&gt;
i) Update the View and Display Percentages: Above the table in our previous view, we can add a section to display these percentages.&lt;br /&gt;
&lt;br /&gt;
ii) Format the Display: We will use a bold heading for each percentage type and format the number to a fixed number of decimal places.&lt;br /&gt;
&lt;br /&gt;
iii) Ensure Responsiveness: Make sure the display of these percentages adjusts well to different screen sizes, maintaining readability and layout consistency. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code Effort ==&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; app/controllers/lottery_controller.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 1: bidding_table_for_topics'''&lt;br /&gt;
&lt;br /&gt;
This method generates a bidding table for each topic within an assignment. It performs several operations to gather and organize data related to topics, bids, and teams. Here's a breakdown of what the code does:&lt;br /&gt;
&lt;br /&gt;
1. Fetch Assignment:&lt;br /&gt;
&lt;br /&gt;
*It retrieves the assignment with the specified params[:id] from the database and stores it in the @assignment instance variable.&lt;br /&gt;
&lt;br /&gt;
2. Fetch Topics:&lt;br /&gt;
&lt;br /&gt;
*It retrieves all sign-up topics associated with the assignment and stores them in the @topics instance variable.&lt;br /&gt;
&lt;br /&gt;
3. Fetch Bids and Assigned Teams:&lt;br /&gt;
&lt;br /&gt;
For each topic in @topics, it:&lt;br /&gt;
*Retrieves all bids associated with that topic and stores them in a hash, where the key is the topic's ID and the value is an array of bids with their associated teams and priorities.&lt;br /&gt;
*Retrieves teams that are not waitlisted for the topic and stores them in a hash, again using the topic's ID as the key and an array of teams as the value.&lt;br /&gt;
&lt;br /&gt;
4. Priority Count Calculation:&lt;br /&gt;
&lt;br /&gt;
*It dynamically computes and updates the counts for each bid priority level (1, 2, and 3) for each topic. These counts are stored in instance variables named @count1, @count2, and @count3. These instance variables are hashes where the keys are topic IDs, and the values are counts for each priority level.&lt;br /&gt;
&lt;br /&gt;
5. Computes Total Teams:&lt;br /&gt;
&lt;br /&gt;
*It determines the total number of teams across all topics in the assignment by counting distinct team IDs among all non-waitlisted teams for the specified topics.&lt;br /&gt;
&lt;br /&gt;
6. Computes Priority Counts and Percentages:&lt;br /&gt;
&lt;br /&gt;
*It calls two helper methods, compute_priority_counts and compute_percentages, to compute the total counts of teams at each priority level and the corresponding percentages. The results are stored in the @priority_counts and @percentages instance variables, respectively.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Prepares data for displaying the bidding details for each topic within an assignment.&lt;br /&gt;
  # It computes the number of bids for each priority (1, 2, 3) per topic and also computes&lt;br /&gt;
  # the overall percentages of teams that received their first, second, and third choice.&lt;br /&gt;
  def bidding_table_for_topics&lt;br /&gt;
    @assignment = Assignment.find(params[:id])&lt;br /&gt;
    # Fetch all topics for the assignment&lt;br /&gt;
    @topics = @assignment.sign_up_topics&lt;br /&gt;
    # Fetch all bids for these topics&lt;br /&gt;
    @bids_by_topic = {}&lt;br /&gt;
    @assigned_teams_by_topic = {} # This will store the assigned teams for each topic&lt;br /&gt;
    @topics.each do |topic|&lt;br /&gt;
      # Assuming bids are stored with a topic_id, and each bid has a team associated with it&lt;br /&gt;
      @bids_by_topic[topic.id] = Bid.where(topic_id: topic.id).map { |bid| { team: bid.team, priority: bid.priority } }&lt;br /&gt;
      # Fetch teams that are not waitlisted for this topic&lt;br /&gt;
      @assigned_teams_by_topic[topic.id] = SignedUpTeam.where(topic_id: topic.id, is_waitlisted: false).map(&amp;amp;:team)      &lt;br /&gt;
      # Dynamically initializing and updating @count1, @count2, and @count3&lt;br /&gt;
      (1..3).each do |priority|&lt;br /&gt;
        instance_variable_set(&amp;quot;@count#{priority}&amp;quot;, Hash.new(0)) unless instance_variable_defined?(&amp;quot;@count#{priority}&amp;quot;)&lt;br /&gt;
        instance_variable_get(&amp;quot;@count#{priority}&amp;quot;)[topic.id] = @bids_by_topic[topic.id].count { |bid| bid[:priority] == priority }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # Computes the total number of teams and percentages after fetching bid details&lt;br /&gt;
    topic_ids = SignUpTopic.where(assignment_id: @assignment.id).pluck(:id)&lt;br /&gt;
    @total_teams = SignedUpTeam.where(topic_id: topic_ids).distinct.count(:team_id)&lt;br /&gt;
    @priority_counts = compute_priority_counts(@assigned_teams_by_topic, @bids_by_topic)&lt;br /&gt;
    @percentages = compute_percentages(@priority_counts, @total_teams)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 2: compute_priority_counts'''&lt;br /&gt;
&lt;br /&gt;
1. Parameters&lt;br /&gt;
*assigned_teams_by_topic (Hash): A hash mapping each topic to an array of assigned teams.&lt;br /&gt;
*bids_by_topic (Hash): A hash mapping each topic to an array of bid objects, where each bid object is a hash containing team and priority information.&lt;br /&gt;
&lt;br /&gt;
2. Functionality&lt;br /&gt;
*Initial Setup: Initializes a hash priority_counts with keys 1, 2, and 3, each having an initial value of 0. These keys represent the priority levels, and their values count the number of teams assigned to each level.&lt;br /&gt;
&lt;br /&gt;
*Iterating Over Topics and Teams: Iterates over each topic and its associated teams found in assigned_teams_by_topic. For each team in a topic, the method searches bids_by_topic[topic_id] to find a bid made by the team.&lt;br /&gt;
&lt;br /&gt;
*Updating Priority Counts: If a bid is found, the method increments the count in priority_counts corresponding to the priority level in the bid. This process effectively tallies the number of teams assigned to each priority level.&lt;br /&gt;
&lt;br /&gt;
3. Returns&lt;br /&gt;
*priority_counts (Hash): A hash with keys 1, 2, and 3, where each key's value represents the count of teams assigned to that respective priority level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Computes the count of assigned teams for each priority level (1, 2, 3) across all topics.&lt;br /&gt;
  # It checks each team associated with a topic and determines if the team's bid matches&lt;br /&gt;
  # one of the priority levels, incrementing the respective count if so.&lt;br /&gt;
  def compute_priority_counts(assigned_teams_by_topic, bids_by_topic)&lt;br /&gt;
    priority_counts = { 1 =&amp;gt; 0, 2 =&amp;gt; 0, 3 =&amp;gt; 0 }&lt;br /&gt;
    assigned_teams_by_topic.each do |topic_id, teams|&lt;br /&gt;
      teams.each do |team|&lt;br /&gt;
        bid_info = bids_by_topic[topic_id].find { |bid| bid[:team] == team }&lt;br /&gt;
        priority_counts[bid_info[:priority]] += 1 if bid_info&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    priority_counts&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 3: compute_percentages'''&lt;br /&gt;
&lt;br /&gt;
* This method computes the percentages of teams that received their first, second, and third choice based on the counts of teams at each priority level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Computes the percentages of teams that received their first, second, and third choice&lt;br /&gt;
  # based on the counts of teams at each priority level.&lt;br /&gt;
  def compute_percentages(priority_counts, total_teams)&lt;br /&gt;
    priority_counts.transform_values { |count| (count.to_f / total_teams * 100).round(2) }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_topics.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:bidding_percentage.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Components:&lt;br /&gt;
&lt;br /&gt;
1. Percentage Display Section&lt;br /&gt;
&lt;br /&gt;
*This section is styled with a border, padding, and a background color to make it visually distinct.&lt;br /&gt;
*It contains a subtitle (h4) describing the content: &amp;quot;Percentage of Teams Getting Their Choices.&amp;quot;&lt;br /&gt;
*A list (ul) displays the percentages of teams that received their 1st, 2nd, and 3rd choice. These percentages are pulled dynamically from @percentages array.&lt;br /&gt;
*The colors of the percentage values vary based on the choice priority (green for #1, orange for #2, and red for #3).&lt;br /&gt;
Custom CSS Styles&lt;br /&gt;
&lt;br /&gt;
2. Bidding Details Table&lt;br /&gt;
&lt;br /&gt;
*A table with headers for Topic ID, Topic Name, Bidding Teams, and bids.&lt;br /&gt;
*The table body (&amp;lt;tbody&amp;gt;) dynamically generates rows for each topic using a loop (&amp;lt;% @topics.each do |topic| %&amp;gt;).&lt;br /&gt;
*For each topic, the table displays its name, ID, bidding teams, and the number of bids for each choice.&lt;br /&gt;
*Teams are marked with the .assigned-team class if they are assigned to the topic.&lt;br /&gt;
*Bid counts are displayed, with a placeholder (&amp;quot;–&amp;quot;) if the count is zero.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;table class=&amp;quot;table table-bordered table-hover&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;thead&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic id&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic name&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Bidding teams&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#1 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#2 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#3 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;/thead&amp;gt;&lt;br /&gt;
  &amp;lt;tbody&amp;gt;&lt;br /&gt;
    &amp;lt;% @topics.each do |topic| %&amp;gt;&lt;br /&gt;
      &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.id %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.topic_name %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;teams-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% @bids_by_topic[topic.id].each do |bid_info| %&amp;gt;&lt;br /&gt;
            &amp;lt;% team = bid_info[:team] %&amp;gt;&lt;br /&gt;
            &amp;lt;% assigned_team = @assigned_teams_by_topic[topic.id].include?(team) %&amp;gt;&lt;br /&gt;
            &amp;lt;span class=&amp;quot;&amp;lt;%= assigned_team ? 'assigned-team' : '' %&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;%= team.name %&amp;gt; (#&amp;lt;%= bid_info[:priority] %&amp;gt;)&lt;br /&gt;
            &amp;lt;/span&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count1[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count1[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count2[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count2[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count3[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count3[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
      &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;% end %&amp;gt;&lt;br /&gt;
  &amp;lt;/tbody&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
1. Test for Populating Bids and Assigned Teams:&lt;br /&gt;
*This test ensures that the bidding_table_for_each_topic method correctly populates bids and assigned teams for each topic.&lt;br /&gt;
*It checks if @bids_by_topic is populated correctly, verifying the length of bids for specific topics.&lt;br /&gt;
*It tests @assigned_teams_by_topic, ensuring it handles cases where topics have no teams.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    it 'populates bids and assigned teams for each topic, handling topics with no teams' do&lt;br /&gt;
        controller.bidding_table_for_each_topic&lt;br /&gt;
        # Check if @bids_by_topic is populated correctly&lt;br /&gt;
        expect(controller.instance_variable_get(:@bids_by_topic)[topic1.id].length).to eq(1)&lt;br /&gt;
        expect(controller.instance_variable_get(:@bids_by_topic)[topic2.id].length).to eq(1)&lt;br /&gt;
        # Check if @assigned_teams_by_topic is populated correctly, allowing for no teams&lt;br /&gt;
        assigned_teams_topic1 = controller.instance_variable_get(:@assigned_teams_by_topic)[topic1.id]&lt;br /&gt;
        if assigned_teams_topic1&lt;br /&gt;
            expect(assigned_teams_topic1.length).to(satisfy { |value| (value == 0) || (value == 1) })&lt;br /&gt;
        else&lt;br /&gt;
            expect(assigned_teams_topic1).to be_nil&lt;br /&gt;
        end&lt;br /&gt;
        # Check the counts of bids for each priority level&lt;br /&gt;
        # Ensure to adjust these based on what is set up in your test data&lt;br /&gt;
        expect(controller.instance_variable_get(:@count1)[topic1.id]).to eq(1)&lt;br /&gt;
        # assuming there is one bid with priority 1 for topic1&lt;br /&gt;
        expect(controller.instance_variable_get(:@count2)[topic1.id]).to eq(0)&lt;br /&gt;
        # assuming there are no bids with priority 2 for topic1&lt;br /&gt;
        expect(controller.instance_variable_get(:@count3)[topic1.id]).to eq(0)&lt;br /&gt;
        # assuming there are no bids with priority 3 for topic1&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Test for Fetching All Topics:&lt;br /&gt;
*This test verifies that all topics for the assignment are fetched and stored in @topics.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    it 'fetches all topics for the assignment' do&lt;br /&gt;
        controller.bidding_table_for_each_topic&lt;br /&gt;
        expect(controller.instance_variable_get(:@topics)).to match_array([topic1, topic2, topic3, topic4])&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Test for Calculating Priority Counts:&lt;br /&gt;
*This test checks the calculation of priority counts for each topic.&lt;br /&gt;
*It compares the calculated priority counts against an expected set of values.&lt;br /&gt;
*It verifies the priority count is computing the values precisely for topics.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    it 'correctly calculates priority counts for each topic' do&lt;br /&gt;
        controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
        # Assuming you have a way to know the expected counts for each priority&lt;br /&gt;
        expected_priority_counts = { 1 =&amp;gt; 0, &lt;br /&gt;
                                     2 =&amp;gt; 0, &lt;br /&gt;
                                     3 =&amp;gt; 0 }&lt;br /&gt;
  &lt;br /&gt;
        priority_counts = controller.instance_variable_get(:@priority_counts)&lt;br /&gt;
        expect(priority_counts).to eq(expected_priority_counts)&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Test for Calculating Percentages for Teams Getting Their Choices:&lt;br /&gt;
*This test ensures that the method correctly calculates the percentages of teams getting their preferred choices.&lt;br /&gt;
*It handles special cases where the expected percentages are not a number (NaN).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    it 'correctly calculates percentages for teams getting their choices' do&lt;br /&gt;
        controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
        # Assuming you have a way to know the expected percentages&lt;br /&gt;
        expected_percentages = { 1 =&amp;gt; Float::NAN, &lt;br /&gt;
                                 2 =&amp;gt; Float::NAN, &lt;br /&gt;
                                 3 =&amp;gt; Float::NAN }&lt;br /&gt;
  &lt;br /&gt;
        percentages = controller.instance_variable_get(:@percentages)&lt;br /&gt;
        expect(percentages[1].nan?).to be true if expected_percentages[1].nan?&lt;br /&gt;
        expect(percentages[2].nan?).to be true if expected_percentages[2].nan?&lt;br /&gt;
        expect(percentages[3].nan?).to be true if expected_percentages[3].nan?&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rspec Testing &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_each_topic.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
&lt;br /&gt;
'''Github Repository: ''' https://github.com/Shreshth-Malik/expertiza&lt;br /&gt;
&lt;br /&gt;
'''Demo Video:''' https://www.youtube.com/watch?v=pGmHyqLj7PM&lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/expertiza/pull/2659&lt;br /&gt;
&lt;br /&gt;
== Testing Credentials ==&lt;br /&gt;
&lt;br /&gt;
username: instructor6&lt;br /&gt;
&lt;br /&gt;
password: password&lt;br /&gt;
&lt;br /&gt;
== Team == &lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Edward F. Gehringer (efg@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
'''Members'''&lt;br /&gt;
&lt;br /&gt;
Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shreshth Malik (smalik4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shuai Chen (schen76@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152926</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding (Phase2)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152926"/>
		<updated>2023-12-14T20:32:14Z</updated>

		<summary type="html">&lt;p&gt;Schen76: /* Code Effort */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Motivation ==&lt;br /&gt;
&lt;br /&gt;
The bidding view is needed because we don’t have a way of finding out whether the bidding algorithm is running correctly.  This project is to add a bidding view to show how the topics are assigned to those teams who bid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Work Plan ==&lt;br /&gt;
&lt;br /&gt;
Based on the project's objectives and feedback received from our mentor, we have identified specific areas for improvement:&lt;br /&gt;
&lt;br /&gt;
1) Refactor variable names within methods such as &amp;quot;bidding_details&amp;quot; and variables like &amp;quot;Topic name&amp;quot; and &amp;quot;Bidding teams&amp;quot; to enhance clarity and specificity.&lt;br /&gt;
&lt;br /&gt;
2) Adjust capitalization for certain components, ensuring that only the first word is capitalized for consistency.&lt;br /&gt;
&lt;br /&gt;
3) Introduce calculations to determine percentages based on additional data, such as the total number of teams and the number of teams for each priority, within the &amp;quot;lottery_controller.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4) Conduct thorough testing of the modified controller and view to ensure optimal functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Newfeature.jpg | 888px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To add functionality for showing the percentages of the number of teams that got their #1, #2, and #3 choices. We can follow these high-level steps:&lt;br /&gt;
&lt;br /&gt;
'''Lottery_Controller:'''&lt;br /&gt;
&lt;br /&gt;
i) Calculate the Total Number of Teams: Before we can calculate percentages, we need to know the total number of teams that participated in the bidding process. This will be our denominator in the percentage calculation.&lt;br /&gt;
&lt;br /&gt;
ii) Calculate the Number of Teams for Each Priority: From our `bidding_details` method, we already have counts for how many teams bid on each topic as their #1, #2, and #3 choice (`@count1`, `@count2`, `@count3`). However, these counts are currently organized by topic. We would need to modify this to count how many teams got their #1, #2, and #3 choices as their assigned topic.&lt;br /&gt;
&lt;br /&gt;
iii) Calculate Percentages: Once we have the number of teams that got their #1, #2, and #3 choices, we can calculate the percentages by dividing these numbers by the total number of teams and multiplying by 100.&lt;br /&gt;
&lt;br /&gt;
'''Bidding_detail view:'''&lt;br /&gt;
&lt;br /&gt;
i) Update the View and Display Percentages: Above the table in our previous view, we can add a section to display these percentages.&lt;br /&gt;
&lt;br /&gt;
ii) Format the Display: We will use a bold heading for each percentage type and format the number to a fixed number of decimal places.&lt;br /&gt;
&lt;br /&gt;
iii) Ensure Responsiveness: Make sure the display of these percentages adjusts well to different screen sizes, maintaining readability and layout consistency. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code Effort ==&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; app/controllers/lottery_controller.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 1: bidding_table_for_topics'''&lt;br /&gt;
&lt;br /&gt;
This method generates a bidding table for each topic within an assignment. It performs several operations to gather and organize data related to topics, bids, and teams. Here's a breakdown of what the code does:&lt;br /&gt;
&lt;br /&gt;
1. Fetch Assignment:&lt;br /&gt;
&lt;br /&gt;
*It retrieves the assignment with the specified params[:id] from the database and stores it in the @assignment instance variable.&lt;br /&gt;
&lt;br /&gt;
2. Fetch Topics:&lt;br /&gt;
&lt;br /&gt;
*It retrieves all sign-up topics associated with the assignment and stores them in the @topics instance variable.&lt;br /&gt;
&lt;br /&gt;
3. Fetch Bids and Assigned Teams:&lt;br /&gt;
&lt;br /&gt;
For each topic in @topics, it:&lt;br /&gt;
*Retrieves all bids associated with that topic and stores them in a hash, where the key is the topic's ID and the value is an array of bids with their associated teams and priorities.&lt;br /&gt;
*Retrieves teams that are not waitlisted for the topic and stores them in a hash, again using the topic's ID as the key and an array of teams as the value.&lt;br /&gt;
&lt;br /&gt;
4. Priority Count Calculation:&lt;br /&gt;
&lt;br /&gt;
*It dynamically computes and updates the counts for each bid priority level (1, 2, and 3) for each topic. These counts are stored in instance variables named @count1, @count2, and @count3. These instance variables are hashes where the keys are topic IDs, and the values are counts for each priority level.&lt;br /&gt;
&lt;br /&gt;
5. Computes Total Teams:&lt;br /&gt;
&lt;br /&gt;
*It determines the total number of teams across all topics in the assignment by counting distinct team IDs among all non-waitlisted teams for the specified topics.&lt;br /&gt;
&lt;br /&gt;
6. Computes Priority Counts and Percentages:&lt;br /&gt;
&lt;br /&gt;
*It calls two helper methods, compute_priority_counts and compute_percentages, to compute the total counts of teams at each priority level and the corresponding percentages. The results are stored in the @priority_counts and @percentages instance variables, respectively.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Prepares data for displaying the bidding details for each topic within an assignment.&lt;br /&gt;
  # It computes the number of bids for each priority (1, 2, 3) per topic and also computes&lt;br /&gt;
  # the overall percentages of teams that received their first, second, and third choice.&lt;br /&gt;
  def bidding_table_for_topics&lt;br /&gt;
    @assignment = Assignment.find(params[:id])&lt;br /&gt;
    # Fetch all topics for the assignment&lt;br /&gt;
    @topics = @assignment.sign_up_topics&lt;br /&gt;
    # Fetch all bids for these topics&lt;br /&gt;
    @bids_by_topic = {}&lt;br /&gt;
    @assigned_teams_by_topic = {} # This will store the assigned teams for each topic&lt;br /&gt;
    @topics.each do |topic|&lt;br /&gt;
      # Assuming bids are stored with a topic_id, and each bid has a team associated with it&lt;br /&gt;
      @bids_by_topic[topic.id] = Bid.where(topic_id: topic.id).map { |bid| { team: bid.team, priority: bid.priority } }&lt;br /&gt;
      # Fetch teams that are not waitlisted for this topic&lt;br /&gt;
      @assigned_teams_by_topic[topic.id] = SignedUpTeam.where(topic_id: topic.id, is_waitlisted: false).map(&amp;amp;:team)      &lt;br /&gt;
      # Dynamically initializing and updating @count1, @count2, and @count3&lt;br /&gt;
      (1..3).each do |priority|&lt;br /&gt;
        instance_variable_set(&amp;quot;@count#{priority}&amp;quot;, Hash.new(0)) unless instance_variable_defined?(&amp;quot;@count#{priority}&amp;quot;)&lt;br /&gt;
        instance_variable_get(&amp;quot;@count#{priority}&amp;quot;)[topic.id] = @bids_by_topic[topic.id].count { |bid| bid[:priority] == priority }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # Computes the total number of teams and percentages after fetching bid details&lt;br /&gt;
    topic_ids = SignUpTopic.where(assignment_id: @assignment.id).pluck(:id)&lt;br /&gt;
    @total_teams = SignedUpTeam.where(topic_id: topic_ids).distinct.count(:team_id)&lt;br /&gt;
    @priority_counts = compute_priority_counts(@assigned_teams_by_topic, @bids_by_topic)&lt;br /&gt;
    @percentages = compute_percentages(@priority_counts, @total_teams)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 2: compute_priority_counts'''&lt;br /&gt;
&lt;br /&gt;
1. Parameters&lt;br /&gt;
*assigned_teams_by_topic (Hash): A hash mapping each topic to an array of assigned teams.&lt;br /&gt;
*bids_by_topic (Hash): A hash mapping each topic to an array of bid objects, where each bid object is a hash containing team and priority information.&lt;br /&gt;
&lt;br /&gt;
2. Functionality&lt;br /&gt;
*Initial Setup: Initializes a hash priority_counts with keys 1, 2, and 3, each having an initial value of 0. These keys represent the priority levels, and their values count the number of teams assigned to each level.&lt;br /&gt;
&lt;br /&gt;
*Iterating Over Topics and Teams: Iterates over each topic and its associated teams found in assigned_teams_by_topic. For each team in a topic, the method searches bids_by_topic[topic_id] to find a bid made by the team.&lt;br /&gt;
&lt;br /&gt;
*Updating Priority Counts: If a bid is found, the method increments the count in priority_counts corresponding to the priority level in the bid. This process effectively tallies the number of teams assigned to each priority level.&lt;br /&gt;
&lt;br /&gt;
3. Returns&lt;br /&gt;
*priority_counts (Hash): A hash with keys 1, 2, and 3, where each key's value represents the count of teams assigned to that respective priority level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Computes the count of assigned teams for each priority level (1, 2, 3) across all topics.&lt;br /&gt;
  # It checks each team associated with a topic and determines if the team's bid matches&lt;br /&gt;
  # one of the priority levels, incrementing the respective count if so.&lt;br /&gt;
  def compute_priority_counts(assigned_teams_by_topic, bids_by_topic)&lt;br /&gt;
    priority_counts = { 1 =&amp;gt; 0, 2 =&amp;gt; 0, 3 =&amp;gt; 0 }&lt;br /&gt;
    assigned_teams_by_topic.each do |topic_id, teams|&lt;br /&gt;
      teams.each do |team|&lt;br /&gt;
        bid_info = bids_by_topic[topic_id].find { |bid| bid[:team] == team }&lt;br /&gt;
        priority_counts[bid_info[:priority]] += 1 if bid_info&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    priority_counts&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 3: compute_percentages'''&lt;br /&gt;
&lt;br /&gt;
* This method computes the percentages of teams that received their first, second, and third choice based on the counts of teams at each priority level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Computes the percentages of teams that received their first, second, and third choice&lt;br /&gt;
  # based on the counts of teams at each priority level.&lt;br /&gt;
  def compute_percentages(priority_counts, total_teams)&lt;br /&gt;
    priority_counts.transform_values { |count| (count.to_f / total_teams * 100).round(2) }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_each_topic.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:bidding_percentage.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Components:&lt;br /&gt;
&lt;br /&gt;
1. Percentage Display Section&lt;br /&gt;
&lt;br /&gt;
*This section is styled with a border, padding, and a background color to make it visually distinct.&lt;br /&gt;
*It contains a subtitle (h4) describing the content: &amp;quot;Percentage of Teams Getting Their Choices.&amp;quot;&lt;br /&gt;
*A list (ul) displays the percentages of teams that received their 1st, 2nd, and 3rd choice. These percentages are pulled dynamically from @percentages array.&lt;br /&gt;
*The colors of the percentage values vary based on the choice priority (green for #1, orange for #2, and red for #3).&lt;br /&gt;
Custom CSS Styles&lt;br /&gt;
&lt;br /&gt;
2. Bidding Details Table&lt;br /&gt;
&lt;br /&gt;
*A table with headers for Topic Name, Topic ID, Bidding Teams, and bids.&lt;br /&gt;
*The table body (&amp;lt;tbody&amp;gt;) dynamically generates rows for each topic using a loop (&amp;lt;% @topics.each do |topic| %&amp;gt;).&lt;br /&gt;
*For each topic, the table displays its name, ID, bidding teams, and the number of bids for each choice.&lt;br /&gt;
*Teams are marked with the .assigned-team class if they are assigned to the topic.&lt;br /&gt;
*Bid counts are displayed, with a placeholder (&amp;quot;–&amp;quot;) if the count is zero.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;table class=&amp;quot;table table-bordered table-hover&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;thead&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic Name&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic ID&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Bidding Teams&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#1 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#2 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#3 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;/thead&amp;gt;&lt;br /&gt;
  &amp;lt;tbody&amp;gt;&lt;br /&gt;
    &amp;lt;% @topics.each do |topic| %&amp;gt;&lt;br /&gt;
      &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.topic_name %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.id %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&lt;br /&gt;
          &amp;lt;% @bids_by_topic[topic.id].each do |bid_info| %&amp;gt;&lt;br /&gt;
            &amp;lt;% team = bid_info[:team] %&amp;gt;&lt;br /&gt;
            &amp;lt;% assigned_team = @assigned_teams_by_topic[topic.id].include?(team) %&amp;gt;&lt;br /&gt;
            &amp;lt;span class=&amp;quot;&amp;lt;%= assigned_team ? 'assigned-team' : '' %&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;%= team.name %&amp;gt; (#&amp;lt;%= bid_info[:priority] %&amp;gt;)&lt;br /&gt;
            &amp;lt;/span&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count1[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count1[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count2[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count2[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count3[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count3[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
      &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;% end %&amp;gt;&lt;br /&gt;
  &amp;lt;/tbody&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;javascript:history.back()&amp;quot;&amp;gt;Back&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
1. Test for Populating Bids and Assigned Teams:&lt;br /&gt;
*This test ensures that the bidding_table_for_each_topic method correctly populates bids and assigned teams for each topic.&lt;br /&gt;
*It checks if @bids_by_topic is populated correctly, verifying the length of bids for specific topics.&lt;br /&gt;
*It tests @assigned_teams_by_topic, ensuring it handles cases where topics have no teams.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    it 'populates bids and assigned teams for each topic, handling topics with no teams' do&lt;br /&gt;
        controller.bidding_table_for_each_topic&lt;br /&gt;
        # Check if @bids_by_topic is populated correctly&lt;br /&gt;
        expect(controller.instance_variable_get(:@bids_by_topic)[topic1.id].length).to eq(1)&lt;br /&gt;
        expect(controller.instance_variable_get(:@bids_by_topic)[topic2.id].length).to eq(1)&lt;br /&gt;
        # Check if @assigned_teams_by_topic is populated correctly, allowing for no teams&lt;br /&gt;
        assigned_teams_topic1 = controller.instance_variable_get(:@assigned_teams_by_topic)[topic1.id]&lt;br /&gt;
        if assigned_teams_topic1&lt;br /&gt;
            expect(assigned_teams_topic1.length).to(satisfy { |value| (value == 0) || (value == 1) })&lt;br /&gt;
        else&lt;br /&gt;
            expect(assigned_teams_topic1).to be_nil&lt;br /&gt;
        end&lt;br /&gt;
        # Check the counts of bids for each priority level&lt;br /&gt;
        # Ensure to adjust these based on what is set up in your test data&lt;br /&gt;
        expect(controller.instance_variable_get(:@count1)[topic1.id]).to eq(1)&lt;br /&gt;
        # assuming there is one bid with priority 1 for topic1&lt;br /&gt;
        expect(controller.instance_variable_get(:@count2)[topic1.id]).to eq(0)&lt;br /&gt;
        # assuming there are no bids with priority 2 for topic1&lt;br /&gt;
        expect(controller.instance_variable_get(:@count3)[topic1.id]).to eq(0)&lt;br /&gt;
        # assuming there are no bids with priority 3 for topic1&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Test for Fetching All Topics:&lt;br /&gt;
*This test verifies that all topics for the assignment are fetched and stored in @topics.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    it 'fetches all topics for the assignment' do&lt;br /&gt;
        controller.bidding_table_for_each_topic&lt;br /&gt;
        expect(controller.instance_variable_get(:@topics)).to match_array([topic1, topic2, topic3, topic4])&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Test for Calculating Priority Counts:&lt;br /&gt;
*This test checks the calculation of priority counts for each topic.&lt;br /&gt;
*It compares the calculated priority counts against an expected set of values.&lt;br /&gt;
*It verifies the priority count is computing the values precisely for topics.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    it 'correctly calculates priority counts for each topic' do&lt;br /&gt;
        controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
        # Assuming you have a way to know the expected counts for each priority&lt;br /&gt;
        expected_priority_counts = { 1 =&amp;gt; 0, &lt;br /&gt;
                                     2 =&amp;gt; 0, &lt;br /&gt;
                                     3 =&amp;gt; 0 }&lt;br /&gt;
  &lt;br /&gt;
        priority_counts = controller.instance_variable_get(:@priority_counts)&lt;br /&gt;
        expect(priority_counts).to eq(expected_priority_counts)&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Test for Calculating Percentages for Teams Getting Their Choices:&lt;br /&gt;
*This test ensures that the method correctly calculates the percentages of teams getting their preferred choices.&lt;br /&gt;
*It handles special cases where the expected percentages are not a number (NaN).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    it 'correctly calculates percentages for teams getting their choices' do&lt;br /&gt;
        controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
        # Assuming you have a way to know the expected percentages&lt;br /&gt;
        expected_percentages = { 1 =&amp;gt; Float::NAN, &lt;br /&gt;
                                 2 =&amp;gt; Float::NAN, &lt;br /&gt;
                                 3 =&amp;gt; Float::NAN }&lt;br /&gt;
  &lt;br /&gt;
        percentages = controller.instance_variable_get(:@percentages)&lt;br /&gt;
        expect(percentages[1].nan?).to be true if expected_percentages[1].nan?&lt;br /&gt;
        expect(percentages[2].nan?).to be true if expected_percentages[2].nan?&lt;br /&gt;
        expect(percentages[3].nan?).to be true if expected_percentages[3].nan?&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rspec Testing &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_each_topic.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
&lt;br /&gt;
'''Github Repository: ''' https://github.com/Shreshth-Malik/expertiza&lt;br /&gt;
&lt;br /&gt;
'''Demo Video:''' https://www.youtube.com/watch?v=pGmHyqLj7PM&lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/expertiza/pull/2659&lt;br /&gt;
&lt;br /&gt;
== Testing Credentials ==&lt;br /&gt;
&lt;br /&gt;
username: instructor6&lt;br /&gt;
&lt;br /&gt;
password: password&lt;br /&gt;
&lt;br /&gt;
== Team == &lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Edward F. Gehringer (efg@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
'''Members'''&lt;br /&gt;
&lt;br /&gt;
Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shreshth Malik (smalik4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shuai Chen (schen76@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152923</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding (Phase2)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152923"/>
		<updated>2023-12-14T20:22:56Z</updated>

		<summary type="html">&lt;p&gt;Schen76: /* Code Effort */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Motivation ==&lt;br /&gt;
&lt;br /&gt;
The bidding view is needed because we don’t have a way of finding out whether the bidding algorithm is running correctly.  This project is to add a bidding view to show how the topics are assigned to those teams who bid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Work Plan ==&lt;br /&gt;
&lt;br /&gt;
Based on the project's objectives and feedback received from our mentor, we have identified specific areas for improvement:&lt;br /&gt;
&lt;br /&gt;
1) Refactor variable names within methods such as &amp;quot;bidding_details&amp;quot; and variables like &amp;quot;Topic name&amp;quot; and &amp;quot;Bidding teams&amp;quot; to enhance clarity and specificity.&lt;br /&gt;
&lt;br /&gt;
2) Adjust capitalization for certain components, ensuring that only the first word is capitalized for consistency.&lt;br /&gt;
&lt;br /&gt;
3) Introduce calculations to determine percentages based on additional data, such as the total number of teams and the number of teams for each priority, within the &amp;quot;lottery_controller.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4) Conduct thorough testing of the modified controller and view to ensure optimal functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Newfeature.jpg | 888px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To add functionality for showing the percentages of the number of teams that got their #1, #2, and #3 choices. We can follow these high-level steps:&lt;br /&gt;
&lt;br /&gt;
'''Lottery_Controller:'''&lt;br /&gt;
&lt;br /&gt;
i) Calculate the Total Number of Teams: Before we can calculate percentages, we need to know the total number of teams that participated in the bidding process. This will be our denominator in the percentage calculation.&lt;br /&gt;
&lt;br /&gt;
ii) Calculate the Number of Teams for Each Priority: From our `bidding_details` method, we already have counts for how many teams bid on each topic as their #1, #2, and #3 choice (`@count1`, `@count2`, `@count3`). However, these counts are currently organized by topic. We would need to modify this to count how many teams got their #1, #2, and #3 choices as their assigned topic.&lt;br /&gt;
&lt;br /&gt;
iii) Calculate Percentages: Once we have the number of teams that got their #1, #2, and #3 choices, we can calculate the percentages by dividing these numbers by the total number of teams and multiplying by 100.&lt;br /&gt;
&lt;br /&gt;
'''Bidding_detail view:'''&lt;br /&gt;
&lt;br /&gt;
i) Update the View and Display Percentages: Above the table in our previous view, we can add a section to display these percentages.&lt;br /&gt;
&lt;br /&gt;
ii) Format the Display: We will use a bold heading for each percentage type and format the number to a fixed number of decimal places.&lt;br /&gt;
&lt;br /&gt;
iii) Ensure Responsiveness: Make sure the display of these percentages adjusts well to different screen sizes, maintaining readability and layout consistency. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code Effort ==&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; app/controllers/lottery_controller.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 1: bidding_table_for_each_topic'''&lt;br /&gt;
&lt;br /&gt;
This method generates a bidding table for each topic within an assignment. It performs several operations to gather and organize data related to topics, bids, and teams. Here's a breakdown of what the code does:&lt;br /&gt;
&lt;br /&gt;
1. Fetch Assignment:&lt;br /&gt;
&lt;br /&gt;
*It retrieves the assignment with the specified params[:id] from the database and stores it in the @assignment instance variable.&lt;br /&gt;
&lt;br /&gt;
2. Fetch Topics:&lt;br /&gt;
&lt;br /&gt;
*It retrieves all sign-up topics associated with the assignment and stores them in the @topics instance variable.&lt;br /&gt;
&lt;br /&gt;
3. Fetch Bids and Assigned Teams:&lt;br /&gt;
&lt;br /&gt;
For each topic in @topics, it:&lt;br /&gt;
*Retrieves all bids associated with that topic and stores them in a hash, where the key is the topic's ID and the value is an array of bids with their associated teams and priorities.&lt;br /&gt;
*Retrieves teams that are not waitlisted for the topic and stores them in a hash, again using the topic's ID as the key and an array of teams as the value.&lt;br /&gt;
&lt;br /&gt;
4. Priority Count Calculation:&lt;br /&gt;
&lt;br /&gt;
*It dynamically calculates and updates the counts for each bid priority level (1, 2, and 3) for each topic. These counts are stored in instance variables named @count1, @count2, and @count3. These instance variables are hashes where the keys are topic IDs, and the values are counts for each priority level.&lt;br /&gt;
&lt;br /&gt;
5. Calculate Total Teams:&lt;br /&gt;
&lt;br /&gt;
*It determines the total number of teams across all topics in the assignment by counting distinct team IDs among all non-waitlisted teams for the specified topics.&lt;br /&gt;
&lt;br /&gt;
6. Calculate Priority Counts and Percentages:&lt;br /&gt;
&lt;br /&gt;
*It calls two helper methods, calculate_priority_counts and calculate_percentages, to calculate the total counts of teams at each priority level and the corresponding percentages. The results are stored in the @priority_counts and @percentages instance variables, respectively.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Prepares data for displaying the bidding details for each topic within an assignment.&lt;br /&gt;
  # It calculates the number of bids for each priority (1, 2, 3) per topic and also computes&lt;br /&gt;
  # the overall percentages of teams that received their first, second, and third choice.&lt;br /&gt;
  def bidding_table_for_each_topic&lt;br /&gt;
    @assignment = Assignment.find(params[:id])&lt;br /&gt;
    # Fetch all topics for the assignment&lt;br /&gt;
    @topics = @assignment.sign_up_topics&lt;br /&gt;
    # Fetch all bids for these topics&lt;br /&gt;
    @bids_by_topic = {}&lt;br /&gt;
    @assigned_teams_by_topic = {} # This will store the assigned teams for each topic&lt;br /&gt;
    @topics.each do |topic|&lt;br /&gt;
      # Assuming bids are stored with a topic_id, and each bid has a team associated with it&lt;br /&gt;
      @bids_by_topic[topic.id] = Bid.where(topic_id: topic.id).map { |bid| { team: bid.team, priority: bid.priority } }&lt;br /&gt;
      # Fetch teams that are not waitlisted for this topic&lt;br /&gt;
      @assigned_teams_by_topic[topic.id] = SignedUpTeam.where(topic_id: topic.id, is_waitlisted: false).map(&amp;amp;:team)&lt;br /&gt;
      # @count1[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 1 }&lt;br /&gt;
      # @count2[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 2 }&lt;br /&gt;
      # @count3[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 3 }       &lt;br /&gt;
&lt;br /&gt;
      # Dynamically initializing and updating @count1, @count2, and @count3&lt;br /&gt;
      (1..3).each do |priority|&lt;br /&gt;
        instance_variable_set(&amp;quot;@count#{priority}&amp;quot;, Hash.new(0)) unless instance_variable_defined?(&amp;quot;@count#{priority}&amp;quot;)&lt;br /&gt;
        instance_variable_get(&amp;quot;@count#{priority}&amp;quot;)[topic.id] = @bids_by_topic[topic.id].count { |bid| bid[:priority] == priority }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # Calculate the total number of teams and percentages after fetching bid details&lt;br /&gt;
    topic_ids = SignUpTopic.where(assignment_id: @assignment.id).pluck(:id)&lt;br /&gt;
    @total_teams = SignedUpTeam.where(topic_id: topic_ids).distinct.count(:team_id)&lt;br /&gt;
    @priority_counts = calculate_priority_counts(@assigned_teams_by_topic, @bids_by_topic)&lt;br /&gt;
    @percentages = calculate_percentages(@priority_counts, @total_teams)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 2: calculate_priority_counts'''&lt;br /&gt;
&lt;br /&gt;
1. Parameters&lt;br /&gt;
*assigned_teams_by_topic (Hash): A hash mapping each topic to an array of assigned teams.&lt;br /&gt;
*bids_by_topic (Hash): A hash mapping each topic to an array of bid objects, where each bid object is a hash containing team and priority information.&lt;br /&gt;
&lt;br /&gt;
2. Functionality&lt;br /&gt;
*Initial Setup: Initializes a hash priority_counts with keys 1, 2, and 3, each having an initial value of 0. These keys represent the priority levels, and their values count the number of teams assigned to each level.&lt;br /&gt;
&lt;br /&gt;
*Iterating Over Topics and Teams: Iterates over each topic and its associated teams found in assigned_teams_by_topic. For each team in a topic, the method searches bids_by_topic[topic_id] to find a bid made by the team.&lt;br /&gt;
&lt;br /&gt;
*Updating Priority Counts: If a bid is found, the method increments the count in priority_counts corresponding to the priority level in the bid. This process effectively tallies the number of teams assigned to each priority level.&lt;br /&gt;
&lt;br /&gt;
3. Returns&lt;br /&gt;
*priority_counts (Hash): A hash with keys 1, 2, and 3, where each key's value represents the count of teams assigned to that respective priority level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Calculates the count of assigned teams for each priority level (1, 2, 3) across all topics.&lt;br /&gt;
  # It checks each team associated with a topic and determines if the team's bid matches&lt;br /&gt;
  # one of the priority levels, incrementing the respective count if so.&lt;br /&gt;
  def calculate_priority_counts(assigned_teams_by_topic, bids_by_topic)&lt;br /&gt;
    priority_counts = { 1 =&amp;gt; 0, 2 =&amp;gt; 0, 3 =&amp;gt; 0 }&lt;br /&gt;
    assigned_teams_by_topic.each do |topic_id, teams|&lt;br /&gt;
      teams.each do |team|&lt;br /&gt;
        bid_info = bids_by_topic[topic_id].find { |bid| bid[:team] == team }&lt;br /&gt;
        priority_counts[bid_info[:priority]] += 1 if bid_info&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    priority_counts&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 3: calculate_percentages'''&lt;br /&gt;
&lt;br /&gt;
* This method calculates the percentages of teams that received their first, second, and third choice based on the counts of teams at each priority level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Calculates the percentages of teams that received their first, second, and third choice&lt;br /&gt;
  # based on the counts of teams at each priority level.&lt;br /&gt;
  def calculate_percentages(priority_counts, total_teams)&lt;br /&gt;
    priority_counts.transform_values { |count| (count.to_f / total_teams * 100).round(2) }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_each_topic.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:bidding_percentage.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Components:&lt;br /&gt;
&lt;br /&gt;
1. Percentage Display Section&lt;br /&gt;
&lt;br /&gt;
*This section is styled with a border, padding, and a background color to make it visually distinct.&lt;br /&gt;
*It contains a subtitle (h4) describing the content: &amp;quot;Percentage of Teams Getting Their Choices.&amp;quot;&lt;br /&gt;
*A list (ul) displays the percentages of teams that received their 1st, 2nd, and 3rd choice. These percentages are pulled dynamically from @percentages array.&lt;br /&gt;
*The colors of the percentage values vary based on the choice priority (green for #1, orange for #2, and red for #3).&lt;br /&gt;
Custom CSS Styles&lt;br /&gt;
&lt;br /&gt;
2. Bidding Details Table&lt;br /&gt;
&lt;br /&gt;
*A table with headers for Topic Name, Topic ID, Bidding Teams, and bids.&lt;br /&gt;
*The table body (&amp;lt;tbody&amp;gt;) dynamically generates rows for each topic using a loop (&amp;lt;% @topics.each do |topic| %&amp;gt;).&lt;br /&gt;
*For each topic, the table displays its name, ID, bidding teams, and the number of bids for each choice.&lt;br /&gt;
*Teams are marked with the .assigned-team class if they are assigned to the topic.&lt;br /&gt;
*Bid counts are displayed, with a placeholder (&amp;quot;–&amp;quot;) if the count is zero.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;table class=&amp;quot;table table-bordered table-hover&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;thead&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic Name&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic ID&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Bidding Teams&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#1 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#2 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#3 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;/thead&amp;gt;&lt;br /&gt;
  &amp;lt;tbody&amp;gt;&lt;br /&gt;
    &amp;lt;% @topics.each do |topic| %&amp;gt;&lt;br /&gt;
      &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.topic_name %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.id %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&lt;br /&gt;
          &amp;lt;% @bids_by_topic[topic.id].each do |bid_info| %&amp;gt;&lt;br /&gt;
            &amp;lt;% team = bid_info[:team] %&amp;gt;&lt;br /&gt;
            &amp;lt;% assigned_team = @assigned_teams_by_topic[topic.id].include?(team) %&amp;gt;&lt;br /&gt;
            &amp;lt;span class=&amp;quot;&amp;lt;%= assigned_team ? 'assigned-team' : '' %&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;%= team.name %&amp;gt; (#&amp;lt;%= bid_info[:priority] %&amp;gt;)&lt;br /&gt;
            &amp;lt;/span&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count1[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count1[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count2[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count2[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count3[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count3[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
      &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;% end %&amp;gt;&lt;br /&gt;
  &amp;lt;/tbody&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;javascript:history.back()&amp;quot;&amp;gt;Back&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
1. Test for Populating Bids and Assigned Teams:&lt;br /&gt;
*This test ensures that the bidding_table_for_each_topic method correctly populates bids and assigned teams for each topic.&lt;br /&gt;
*It checks if @bids_by_topic is populated correctly, verifying the length of bids for specific topics.&lt;br /&gt;
*It tests @assigned_teams_by_topic, ensuring it handles cases where topics have no teams.&lt;br /&gt;
&lt;br /&gt;
2. Test for Fetching All Topics:&lt;br /&gt;
*This test verifies that all topics for the assignment are fetched and stored in @topics.&lt;br /&gt;
&lt;br /&gt;
3. Test for Calculating Priority Counts:&lt;br /&gt;
*This test checks the calculation of priority counts for each topic.&lt;br /&gt;
*It compares the calculated priority counts against an expected set of values.&lt;br /&gt;
&lt;br /&gt;
4. Test for Calculating Percentages for Teams Getting Their Choices:&lt;br /&gt;
*This test ensures that the method correctly calculates the percentages of teams getting their preferred choices.&lt;br /&gt;
*It handles special cases where the expected percentages are not a number (NaN).&lt;br /&gt;
&lt;br /&gt;
Rspec Testing &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_each_topic.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe '#bidding_table_for_each_topic' do&lt;br /&gt;
    before :each do&lt;br /&gt;
      # Set the assignment id in the params&lt;br /&gt;
      params = ActionController::Parameters.new(id: assignment.id)&lt;br /&gt;
      allow(controller).to receive(:params).and_return(params)&lt;br /&gt;
    end&lt;br /&gt;
    it 'populates bids and assigned teams for each topic, handling topics with no teams' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
      # Check if @bids_by_topic is populated correctly&lt;br /&gt;
      expect(controller.instance_variable_get(:@bids_by_topic)[topic1.id].length).to eq(1)&lt;br /&gt;
      expect(controller.instance_variable_get(:@bids_by_topic)[topic2.id].length).to eq(1)&lt;br /&gt;
      # Check if @assigned_teams_by_topic is populated correctly, allowing for no teams&lt;br /&gt;
      assigned_teams_topic1 = controller.instance_variable_get(:@assigned_teams_by_topic)[topic1.id]&lt;br /&gt;
      if assigned_teams_topic1&lt;br /&gt;
        expect(assigned_teams_topic1.length).to(satisfy { |value| (value == 0) || (value == 1) })&lt;br /&gt;
      else&lt;br /&gt;
        expect(assigned_teams_topic1).to be_nil&lt;br /&gt;
      end&lt;br /&gt;
      # Check the counts of bids for each priority level&lt;br /&gt;
      # Ensure to adjust these based on what is set up in your test data&lt;br /&gt;
      expect(controller.instance_variable_get(:@count1)[topic1.id]).to eq(1)&lt;br /&gt;
      # assuming there is one bid with priority 1 for topic1&lt;br /&gt;
      expect(controller.instance_variable_get(:@count2)[topic1.id]).to eq(0)&lt;br /&gt;
      # assuming there are no bids with priority 2 for topic1&lt;br /&gt;
      expect(controller.instance_variable_get(:@count3)[topic1.id]).to eq(0)&lt;br /&gt;
      # assuming there are no bids with priority 3 for topic1&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'fetches all topics for the assignment' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
      expect(controller.instance_variable_get(:@topics)).to match_array([topic1, topic2, topic3, topic4])&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'correctly calculates priority counts for each topic' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
      # Assuming you have a way to know the expected counts for each priority&lt;br /&gt;
      expected_priority_counts = { 1 =&amp;gt; 0, &lt;br /&gt;
                                   2 =&amp;gt; 0, &lt;br /&gt;
                                   3 =&amp;gt; 0 }&lt;br /&gt;
  &lt;br /&gt;
      priority_counts = controller.instance_variable_get(:@priority_counts)&lt;br /&gt;
      expect(priority_counts).to eq(expected_priority_counts)&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'correctly calculates percentages for teams getting their choices' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
      # Assuming you have a way to know the expected percentages&lt;br /&gt;
      expected_percentages = { 1 =&amp;gt; Float::NAN, &lt;br /&gt;
                               2 =&amp;gt; Float::NAN, &lt;br /&gt;
                               3 =&amp;gt; Float::NAN }&lt;br /&gt;
  &lt;br /&gt;
      percentages = controller.instance_variable_get(:@percentages)&lt;br /&gt;
      expect(percentages[1].nan?).to be true if expected_percentages[1].nan?&lt;br /&gt;
      expect(percentages[2].nan?).to be true if expected_percentages[2].nan?&lt;br /&gt;
      expect(percentages[3].nan?).to be true if expected_percentages[3].nan?&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
&lt;br /&gt;
'''Github Repository: ''' https://github.com/Shreshth-Malik/expertiza&lt;br /&gt;
&lt;br /&gt;
'''Demo Video:''' https://www.youtube.com/watch?v=pGmHyqLj7PM&lt;br /&gt;
&lt;br /&gt;
== Testing Credentials ==&lt;br /&gt;
&lt;br /&gt;
username: instructor6&lt;br /&gt;
&lt;br /&gt;
password: password&lt;br /&gt;
&lt;br /&gt;
== Team == &lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Edward F. Gehringer (efg@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
'''Members'''&lt;br /&gt;
&lt;br /&gt;
Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shreshth Malik (smalik4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shuai Chen (schen76@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152922</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding (Phase2)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152922"/>
		<updated>2023-12-14T20:20:23Z</updated>

		<summary type="html">&lt;p&gt;Schen76: /* Code Effort */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Motivation ==&lt;br /&gt;
&lt;br /&gt;
The bidding view is needed because we don’t have a way of finding out whether the bidding algorithm is running correctly.  This project is to add a bidding view to show how the topics are assigned to those teams who bid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Work Plan ==&lt;br /&gt;
&lt;br /&gt;
Based on the project's objectives and feedback received from our mentor, we have identified specific areas for improvement:&lt;br /&gt;
&lt;br /&gt;
1) Refactor variable names within methods such as &amp;quot;bidding_details&amp;quot; and variables like &amp;quot;Topic name&amp;quot; and &amp;quot;Bidding teams&amp;quot; to enhance clarity and specificity.&lt;br /&gt;
&lt;br /&gt;
2) Adjust capitalization for certain components, ensuring that only the first word is capitalized for consistency.&lt;br /&gt;
&lt;br /&gt;
3) Introduce calculations to determine percentages based on additional data, such as the total number of teams and the number of teams for each priority, within the &amp;quot;lottery_controller.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4) Conduct thorough testing of the modified controller and view to ensure optimal functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Newfeature.jpg | 888px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To add functionality for showing the percentages of the number of teams that got their #1, #2, and #3 choices. We can follow these high-level steps:&lt;br /&gt;
&lt;br /&gt;
'''Lottery_Controller:'''&lt;br /&gt;
&lt;br /&gt;
i) Calculate the Total Number of Teams: Before we can calculate percentages, we need to know the total number of teams that participated in the bidding process. This will be our denominator in the percentage calculation.&lt;br /&gt;
&lt;br /&gt;
ii) Calculate the Number of Teams for Each Priority: From our `bidding_details` method, we already have counts for how many teams bid on each topic as their #1, #2, and #3 choice (`@count1`, `@count2`, `@count3`). However, these counts are currently organized by topic. We would need to modify this to count how many teams got their #1, #2, and #3 choices as their assigned topic.&lt;br /&gt;
&lt;br /&gt;
iii) Calculate Percentages: Once we have the number of teams that got their #1, #2, and #3 choices, we can calculate the percentages by dividing these numbers by the total number of teams and multiplying by 100.&lt;br /&gt;
&lt;br /&gt;
'''Bidding_detail view:'''&lt;br /&gt;
&lt;br /&gt;
i) Update the View and Display Percentages: Above the table in our previous view, we can add a section to display these percentages.&lt;br /&gt;
&lt;br /&gt;
ii) Format the Display: We will use a bold heading for each percentage type and format the number to a fixed number of decimal places.&lt;br /&gt;
&lt;br /&gt;
iii) Ensure Responsiveness: Make sure the display of these percentages adjusts well to different screen sizes, maintaining readability and layout consistency. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code Effort ==&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; app/controllers/lottery_controller.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 1: bidding_table_for_each_topic'''&lt;br /&gt;
&lt;br /&gt;
This method generates a bidding table for each topic within an assignment. It performs several operations to gather and organize data related to topics, bids, and teams. Here's a breakdown of what the code does:&lt;br /&gt;
&lt;br /&gt;
1. Fetch Assignment:&lt;br /&gt;
&lt;br /&gt;
*It retrieves the assignment with the specified params[:id] from the database and stores it in the @assignment instance variable.&lt;br /&gt;
&lt;br /&gt;
2. Fetch Topics:&lt;br /&gt;
&lt;br /&gt;
*It retrieves all sign-up topics associated with the assignment and stores them in the @topics instance variable.&lt;br /&gt;
&lt;br /&gt;
3. Fetch Bids and Assigned Teams:&lt;br /&gt;
&lt;br /&gt;
For each topic in @topics, it:&lt;br /&gt;
*Retrieves all bids associated with that topic and stores them in a hash, where the key is the topic's ID and the value is an array of bids with their associated teams and priorities.&lt;br /&gt;
*Retrieves teams that are not waitlisted for the topic and stores them in a hash, again using the topic's ID as the key and an array of teams as the value.&lt;br /&gt;
&lt;br /&gt;
4. Priority Count Calculation:&lt;br /&gt;
&lt;br /&gt;
*It dynamically calculates and updates the counts for each bid priority level (1, 2, and 3) for each topic. These counts are stored in instance variables named @count1, @count2, and @count3. These instance variables are hashes where the keys are topic IDs, and the values are counts for each priority level.&lt;br /&gt;
&lt;br /&gt;
5. Calculate Total Teams:&lt;br /&gt;
&lt;br /&gt;
*It determines the total number of teams across all topics in the assignment by counting distinct team IDs among all non-waitlisted teams for the specified topics.&lt;br /&gt;
&lt;br /&gt;
6. Calculate Priority Counts and Percentages:&lt;br /&gt;
&lt;br /&gt;
*It calls two helper methods, calculate_priority_counts and calculate_percentages, to calculate the total counts of teams at each priority level and the corresponding percentages. The results are stored in the @priority_counts and @percentages instance variables, respectively.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Prepares data for displaying the bidding details for each topic within an assignment.&lt;br /&gt;
  # It calculates the number of bids for each priority (1, 2, 3) per topic and also computes&lt;br /&gt;
  # the overall percentages of teams that received their first, second, and third choice.&lt;br /&gt;
  def bidding_table_for_each_topic&lt;br /&gt;
    @assignment = Assignment.find(params[:id])&lt;br /&gt;
    # Fetch all topics for the assignment&lt;br /&gt;
    @topics = @assignment.sign_up_topics&lt;br /&gt;
    # Fetch all bids for these topics&lt;br /&gt;
    @bids_by_topic = {}&lt;br /&gt;
    @assigned_teams_by_topic = {} # This will store the assigned teams for each topic&lt;br /&gt;
    @topics.each do |topic|&lt;br /&gt;
      # Assuming bids are stored with a topic_id, and each bid has a team associated with it&lt;br /&gt;
      @bids_by_topic[topic.id] = Bid.where(topic_id: topic.id).map { |bid| { team: bid.team, priority: bid.priority } }&lt;br /&gt;
      # Fetch teams that are not waitlisted for this topic&lt;br /&gt;
      @assigned_teams_by_topic[topic.id] = SignedUpTeam.where(topic_id: topic.id, is_waitlisted: false).map(&amp;amp;:team)&lt;br /&gt;
      # @count1[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 1 }&lt;br /&gt;
      # @count2[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 2 }&lt;br /&gt;
      # @count3[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 3 }       &lt;br /&gt;
&lt;br /&gt;
      # Dynamically initializing and updating @count1, @count2, and @count3&lt;br /&gt;
      (1..3).each do |priority|&lt;br /&gt;
        instance_variable_set(&amp;quot;@count#{priority}&amp;quot;, Hash.new(0)) unless instance_variable_defined?(&amp;quot;@count#{priority}&amp;quot;)&lt;br /&gt;
        instance_variable_get(&amp;quot;@count#{priority}&amp;quot;)[topic.id] = @bids_by_topic[topic.id].count { |bid| bid[:priority] == priority }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # Calculate the total number of teams and percentages after fetching bid details&lt;br /&gt;
    topic_ids = SignUpTopic.where(assignment_id: @assignment.id).pluck(:id)&lt;br /&gt;
    @total_teams = SignedUpTeam.where(topic_id: topic_ids).distinct.count(:team_id)&lt;br /&gt;
    @priority_counts = calculate_priority_counts(@assigned_teams_by_topic, @bids_by_topic)&lt;br /&gt;
    @percentages = calculate_percentages(@priority_counts, @total_teams)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 2: calculate_priority_counts'''&lt;br /&gt;
&lt;br /&gt;
1. Parameters&lt;br /&gt;
*assigned_teams_by_topic (Hash): A hash mapping each topic to an array of assigned teams.&lt;br /&gt;
*bids_by_topic (Hash): A hash mapping each topic to an array of bid objects, where each bid object is a hash containing team and priority information.&lt;br /&gt;
&lt;br /&gt;
2. Functionality&lt;br /&gt;
*Initial Setup: Initializes a hash priority_counts with keys 1, 2, and 3, each having an initial value of 0. These keys represent the priority levels, and their values count the number of teams assigned to each level.&lt;br /&gt;
&lt;br /&gt;
*Iterating Over Topics and Teams: Iterates over each topic and its associated teams found in assigned_teams_by_topic. For each team in a topic, the method searches bids_by_topic[topic_id] to find a bid made by the team.&lt;br /&gt;
&lt;br /&gt;
*Updating Priority Counts: If a bid is found, the method increments the count in priority_counts corresponding to the priority level in the bid. This process effectively tallies the number of teams assigned to each priority level.&lt;br /&gt;
&lt;br /&gt;
3. Returns&lt;br /&gt;
*priority_counts (Hash): A hash with keys 1, 2, and 3, where each key's value represents the count of teams assigned to that respective priority level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Calculates the count of assigned teams for each priority level (1, 2, 3) across all topics.&lt;br /&gt;
  # It checks each team associated with a topic and determines if the team's bid matches&lt;br /&gt;
  # one of the priority levels, incrementing the respective count if so.&lt;br /&gt;
  def calculate_priority_counts(assigned_teams_by_topic, bids_by_topic)&lt;br /&gt;
    priority_counts = { 1 =&amp;gt; 0, 2 =&amp;gt; 0, 3 =&amp;gt; 0 }&lt;br /&gt;
    assigned_teams_by_topic.each do |topic_id, teams|&lt;br /&gt;
      teams.each do |team|&lt;br /&gt;
        bid_info = bids_by_topic[topic_id].find { |bid| bid[:team] == team }&lt;br /&gt;
        priority_counts[bid_info[:priority]] += 1 if bid_info&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    priority_counts&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 3: calculate_percentages'''&lt;br /&gt;
&lt;br /&gt;
* This method calculates the percentages of teams that received their first, second, and third choice based on the counts of teams at each priority level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Calculates the percentages of teams that received their first, second, and third choice&lt;br /&gt;
  # based on the counts of teams at each priority level.&lt;br /&gt;
  def calculate_percentages(priority_counts, total_teams)&lt;br /&gt;
    priority_counts.transform_values { |count| (count.to_f / total_teams * 100).round(2) }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_each_topic.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:bidding_percentage.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Components:&lt;br /&gt;
&lt;br /&gt;
1. Percentage Display Section&lt;br /&gt;
&lt;br /&gt;
*This section is styled with a border, padding, and a background color to make it visually distinct.&lt;br /&gt;
*It contains a subtitle (h4) describing the content: &amp;quot;Percentage of Teams Getting Their Choices.&amp;quot;&lt;br /&gt;
*A list (ul) displays the percentages of teams that received their 1st, 2nd, and 3rd choice. These percentages are pulled dynamically from @percentages array.&lt;br /&gt;
*The colors of the percentage values vary based on the choice priority (green for #1, orange for #2, and red for #3).&lt;br /&gt;
Custom CSS Styles&lt;br /&gt;
&lt;br /&gt;
2. Bidding Details Table&lt;br /&gt;
&lt;br /&gt;
*A table with headers for Topic Name, Topic ID, Bidding Teams, and bids.&lt;br /&gt;
*The table body (&amp;lt;tbody&amp;gt;) dynamically generates rows for each topic using a loop (&amp;lt;% @topics.each do |topic| %&amp;gt;).&lt;br /&gt;
*For each topic, the table displays its name, ID, bidding teams, and the number of bids for each choice.&lt;br /&gt;
*Teams are marked with the .assigned-team class if they are assigned to the topic.&lt;br /&gt;
*Bid counts are displayed, with a placeholder (&amp;quot;–&amp;quot;) if the count is zero.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table class=&amp;quot;table table-bordered table-hover&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;thead&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic Name&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic ID&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Bidding Teams&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#1 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#2 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#3 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;/thead&amp;gt;&lt;br /&gt;
  &amp;lt;tbody&amp;gt;&lt;br /&gt;
    &amp;lt;% @topics.each do |topic| %&amp;gt;&lt;br /&gt;
      &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.topic_name %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.id %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&lt;br /&gt;
          &amp;lt;% @bids_by_topic[topic.id].each do |bid_info| %&amp;gt;&lt;br /&gt;
            &amp;lt;% team = bid_info[:team] %&amp;gt;&lt;br /&gt;
            &amp;lt;% assigned_team = @assigned_teams_by_topic[topic.id].include?(team) %&amp;gt;&lt;br /&gt;
            &amp;lt;span class=&amp;quot;&amp;lt;%= assigned_team ? 'assigned-team' : '' %&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;%= team.name %&amp;gt; (#&amp;lt;%= bid_info[:priority] %&amp;gt;)&lt;br /&gt;
            &amp;lt;/span&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count1[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count1[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count2[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count2[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count3[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count3[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
      &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;% end %&amp;gt;&lt;br /&gt;
  &amp;lt;/tbody&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;javascript:history.back()&amp;quot;&amp;gt;Back&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
1. Test for Populating Bids and Assigned Teams:&lt;br /&gt;
*This test ensures that the bidding_table_for_each_topic method correctly populates bids and assigned teams for each topic.&lt;br /&gt;
*It checks if @bids_by_topic is populated correctly, verifying the length of bids for specific topics.&lt;br /&gt;
*It tests @assigned_teams_by_topic, ensuring it handles cases where topics have no teams.&lt;br /&gt;
&lt;br /&gt;
2. Test for Fetching All Topics:&lt;br /&gt;
*This test verifies that all topics for the assignment are fetched and stored in @topics.&lt;br /&gt;
&lt;br /&gt;
3. Test for Calculating Priority Counts:&lt;br /&gt;
*This test checks the calculation of priority counts for each topic.&lt;br /&gt;
*It compares the calculated priority counts against an expected set of values.&lt;br /&gt;
&lt;br /&gt;
4. Test for Calculating Percentages for Teams Getting Their Choices:&lt;br /&gt;
*This test ensures that the method correctly calculates the percentages of teams getting their preferred choices.&lt;br /&gt;
*It handles special cases where the expected percentages are not a number (NaN).&lt;br /&gt;
&lt;br /&gt;
Rspec Testing &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_each_topic.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe '#bidding_table_for_each_topic' do&lt;br /&gt;
    before :each do&lt;br /&gt;
      # Set the assignment id in the params&lt;br /&gt;
      params = ActionController::Parameters.new(id: assignment.id)&lt;br /&gt;
      allow(controller).to receive(:params).and_return(params)&lt;br /&gt;
    end&lt;br /&gt;
    it 'populates bids and assigned teams for each topic, handling topics with no teams' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
      # Check if @bids_by_topic is populated correctly&lt;br /&gt;
      expect(controller.instance_variable_get(:@bids_by_topic)[topic1.id].length).to eq(1)&lt;br /&gt;
      expect(controller.instance_variable_get(:@bids_by_topic)[topic2.id].length).to eq(1)&lt;br /&gt;
      # Check if @assigned_teams_by_topic is populated correctly, allowing for no teams&lt;br /&gt;
      assigned_teams_topic1 = controller.instance_variable_get(:@assigned_teams_by_topic)[topic1.id]&lt;br /&gt;
      if assigned_teams_topic1&lt;br /&gt;
        expect(assigned_teams_topic1.length).to(satisfy { |value| (value == 0) || (value == 1) })&lt;br /&gt;
      else&lt;br /&gt;
        expect(assigned_teams_topic1).to be_nil&lt;br /&gt;
      end&lt;br /&gt;
      # Check the counts of bids for each priority level&lt;br /&gt;
      # Ensure to adjust these based on what is set up in your test data&lt;br /&gt;
      expect(controller.instance_variable_get(:@count1)[topic1.id]).to eq(1)&lt;br /&gt;
      # assuming there is one bid with priority 1 for topic1&lt;br /&gt;
      expect(controller.instance_variable_get(:@count2)[topic1.id]).to eq(0)&lt;br /&gt;
      # assuming there are no bids with priority 2 for topic1&lt;br /&gt;
      expect(controller.instance_variable_get(:@count3)[topic1.id]).to eq(0)&lt;br /&gt;
      # assuming there are no bids with priority 3 for topic1&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'fetches all topics for the assignment' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
      expect(controller.instance_variable_get(:@topics)).to match_array([topic1, topic2, topic3, topic4])&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'correctly calculates priority counts for each topic' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
      # Assuming you have a way to know the expected counts for each priority&lt;br /&gt;
      expected_priority_counts = { 1 =&amp;gt; 0, &lt;br /&gt;
                                   2 =&amp;gt; 0, &lt;br /&gt;
                                   3 =&amp;gt; 0 }&lt;br /&gt;
  &lt;br /&gt;
      priority_counts = controller.instance_variable_get(:@priority_counts)&lt;br /&gt;
      expect(priority_counts).to eq(expected_priority_counts)&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'correctly calculates percentages for teams getting their choices' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
      # Assuming you have a way to know the expected percentages&lt;br /&gt;
      expected_percentages = { 1 =&amp;gt; Float::NAN, &lt;br /&gt;
                               2 =&amp;gt; Float::NAN, &lt;br /&gt;
                               3 =&amp;gt; Float::NAN }&lt;br /&gt;
  &lt;br /&gt;
      percentages = controller.instance_variable_get(:@percentages)&lt;br /&gt;
      expect(percentages[1].nan?).to be true if expected_percentages[1].nan?&lt;br /&gt;
      expect(percentages[2].nan?).to be true if expected_percentages[2].nan?&lt;br /&gt;
      expect(percentages[3].nan?).to be true if expected_percentages[3].nan?&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
&lt;br /&gt;
'''Github Repository: ''' https://github.com/Shreshth-Malik/expertiza&lt;br /&gt;
&lt;br /&gt;
'''Demo Video:''' https://www.youtube.com/watch?v=pGmHyqLj7PM&lt;br /&gt;
&lt;br /&gt;
== Testing Credentials ==&lt;br /&gt;
&lt;br /&gt;
username: instructor6&lt;br /&gt;
&lt;br /&gt;
password: password&lt;br /&gt;
&lt;br /&gt;
== Team == &lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Edward F. Gehringer (efg@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
'''Members'''&lt;br /&gt;
&lt;br /&gt;
Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shreshth Malik (smalik4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shuai Chen (schen76@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding&amp;diff=152826</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding&amp;diff=152826"/>
		<updated>2023-12-06T05:34:26Z</updated>

		<summary type="html">&lt;p&gt;Schen76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
When topics are opened up for bidding, students can see how “hot” each topic is by the color it has on their topic list. However, instructors have no way to view the bidding process except by impersonating students. Furthermore, when the bidding assignment algorithm is run, there is no way to verify that it did in fact assign teams to topics they had chosen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Previous Work ==&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE_517_Spring_2022_-_E2245:_View_for_results_of_bidding]]&lt;br /&gt;
&lt;br /&gt;
== Accomplishments ==&lt;br /&gt;
&lt;br /&gt;
This project added a &amp;quot;View Bidding Details&amp;quot; when the instructor enables the &amp;quot;bidding for topics&amp;quot; feature. By clicking it, it redirects us to a new page, where shows the following details of bidding:&lt;br /&gt;
&lt;br /&gt;
*Topic Name&lt;br /&gt;
*Bidding Teams&lt;br /&gt;
*Bidding Order&lt;br /&gt;
*The number of bidding a topic gets&lt;br /&gt;
&lt;br /&gt;
Also, for each topic, the team that wins the bidding will be highlighted with a yellow background color so that the instructor can easily find out which team each topic is assigned to.&lt;br /&gt;
&lt;br /&gt;
The button leads to a page that contains bidding information for the assignment. It displays the number of #1, #2, and #3 bids on a specific topic, the teams that bid and priority of their bid, and the name of the team that got assigned the topic is highlighted. &lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_button.png ‎| 888px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details.png ‎| 888px]]&lt;br /&gt;
&lt;br /&gt;
'''Files Involved:'''&lt;br /&gt;
&lt;br /&gt;
The files to be worked upon are:&lt;br /&gt;
&lt;br /&gt;
*./app/controllers/lottering_controller.rb&lt;br /&gt;
*./app/views/lottery/bidding_details.ntml.erb&lt;br /&gt;
*./app/assignments/edit/_topics.html.erb&lt;br /&gt;
*./spec/controllers/lottery_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
*Richard Li  rli14@ncsu.edu&lt;br /&gt;
*Shreshth Malik  smalik4@ncsu.edu&lt;br /&gt;
*Shuai Chen  schen76@ncsu.edu&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Implemented Code ==&lt;br /&gt;
&lt;br /&gt;
'''1. Lottery Controller'''&lt;br /&gt;
&lt;br /&gt;
File: &amp;lt;code&amp;gt;./app/controllers/lottery_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Method: &amp;lt;code&amp;gt;&amp;quot;bidding_details&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Functionality:&lt;br /&gt;
&lt;br /&gt;
(1) Assignment Retrieval:&lt;br /&gt;
&lt;br /&gt;
*Retrieves the assignment based on the provided id from the params.&lt;br /&gt;
&lt;br /&gt;
(2) Topic Fetching:&lt;br /&gt;
&lt;br /&gt;
*Gathers all the sign-up topics associated with the retrieved assignment.&lt;br /&gt;
&lt;br /&gt;
(3) Initialization of Data Structures:&lt;br /&gt;
&lt;br /&gt;
*Initializes two hash data structures:&lt;br /&gt;
#@bids_by_topic: To store bids by topic.&lt;br /&gt;
#@assigned_teams_by_topic: To store teams assigned to each topic.&lt;br /&gt;
&lt;br /&gt;
(4) Data Aggregation:&lt;br /&gt;
&lt;br /&gt;
Iterates through each topic and performs the following actions:&lt;br /&gt;
&lt;br /&gt;
(i) Bids Gathering:&lt;br /&gt;
*Fetches all bids for each topic.&lt;br /&gt;
*Bids are stored in @bids_by_topic, mapped by the topic.id. Each bid includes the team and its priority.&lt;br /&gt;
&lt;br /&gt;
(ii) Assigned Teams Gathering:&lt;br /&gt;
*Retrieves teams that are assigned to a topic and are not waitlisted.&lt;br /&gt;
*The results are stored in @assigned_teams_by_topic, indexed by topic.id.&lt;br /&gt;
&lt;br /&gt;
(5) Priority Counts:&lt;br /&gt;
&lt;br /&gt;
*For each topic, the method calculates the number of bids at each priority level (1 to 3).&lt;br /&gt;
*It dynamically initializes and updates three instance variables: @count1, @count2, and @count3.&lt;br /&gt;
*Each of these variables is a hash that maps topic IDs to the count of bids at the respective priority.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def bidding_details&lt;br /&gt;
    @assignment = Assignment.find(params[:id])&lt;br /&gt;
    # Fetch all topics for the assignment&lt;br /&gt;
    @topics = @assignment.sign_up_topics&lt;br /&gt;
    # Fetch all bids for these topics&lt;br /&gt;
    @bids_by_topic = {}&lt;br /&gt;
    @assigned_teams_by_topic = {} # This will store the assigned teams for each topic&lt;br /&gt;
    @topics.each do |topic|&lt;br /&gt;
      # Assuming bids are stored with a topic_id, and each bid has a team associated with it&lt;br /&gt;
      @bids_by_topic[topic.id] = Bid.where(topic_id: topic.id).map { |bid| { team: bid.team, priority: bid.priority } }&lt;br /&gt;
      # Fetch teams that are not waitlisted for this topic&lt;br /&gt;
      @assigned_teams_by_topic[topic.id] = SignedUpTeam.where(topic_id: topic.id, is_waitlisted: false).map(&amp;amp;:team)&lt;br /&gt;
      # Dynamically initializing and updating @count1, @count2, and @count3&lt;br /&gt;
      (1..3).each do |priority|&lt;br /&gt;
        instance_variable_set(&amp;quot;@count#{priority}&amp;quot;, Hash.new(0)) unless instance_variable_defined?(&amp;quot;@count#{priority}&amp;quot;)&lt;br /&gt;
        instance_variable_get(&amp;quot;@count#{priority}&amp;quot;)[topic.id] = @bids_by_topic[topic.id].count { |bid| bid[:priority] == priority }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details_controller.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
'''2. Bidding Details View'''&lt;br /&gt;
&lt;br /&gt;
File: &amp;lt;code&amp;gt;./app/views/lottery/bidding_details.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Added a button and corresponding JavaScript which toggles its visibility based on “Enable bidding for topics?” checkbox.'''&lt;br /&gt;
&lt;br /&gt;
Components:&lt;br /&gt;
&lt;br /&gt;
1. Custom CSS Style:&lt;br /&gt;
&lt;br /&gt;
*A style block is defined to style elements with the assigned-team class. Teams assigned to a topic will have a yellow background and black text.&lt;br /&gt;
&lt;br /&gt;
2. Bidding Details Table:&lt;br /&gt;
&lt;br /&gt;
*A table is created with classes table, table-bordered, and table-hover for styling.&lt;br /&gt;
*The header (&amp;lt;thead&amp;gt;) section of the table defines five columns: &amp;quot;Topic Name&amp;quot;, &amp;quot;Bidding Teams&amp;quot;, and three columns for bid counts (&amp;quot;#1 bids&amp;quot;, &amp;quot;#2 bids&amp;quot;, &amp;quot;#3 bids&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
3. Dynamic Table Rows:&lt;br /&gt;
&lt;br /&gt;
*The &amp;lt;tbody&amp;gt; section uses ERB to iterate over each topic in the @topics array.&lt;br /&gt;
*Each topic creates a table row (&amp;lt;tr&amp;gt;) with the following data:&lt;br /&gt;
**Topic Name: Displayed using &amp;lt;%= topic.topic_name %&amp;gt;.&lt;br /&gt;
**Bidding Teams: A list of teams bidding on the topic. For each bid associated with the topic:&lt;br /&gt;
***The team's name and priority number are displayed.&lt;br /&gt;
***If the team is assigned to the topic, it is styled with the assigned-team class.&lt;br /&gt;
**Bid Counts: Three columns display the number of #1, #2, and #3 bids for each topic. If there are no bids, it displays &amp;quot;No bids yet&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
4. Navigation Link:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;a href=&amp;quot;javascript:history.back()&amp;quot;&amp;gt;Back&amp;lt;/a&amp;gt;&amp;lt;/code&amp;gt;: Provides a link to go back to the previous page in the browser history.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt;Bidding Details for &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;style&amp;gt;&lt;br /&gt;
.assigned-team {&lt;br /&gt;
  background-color: yellow; &lt;br /&gt;
  color: black;             &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/style&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table class=&amp;quot;table table-bordered table-hover&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;thead&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic Name&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Bidding Teams&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#1 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#2 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#3 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;/thead&amp;gt;&lt;br /&gt;
  &amp;lt;tbody&amp;gt;&lt;br /&gt;
    &amp;lt;% @topics.each do |topic| %&amp;gt;&lt;br /&gt;
      &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.topic_name %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&lt;br /&gt;
          &amp;lt;% @bids_by_topic[topic.id].each do |bid_info| %&amp;gt;&lt;br /&gt;
            &amp;lt;% team = bid_info[:team] %&amp;gt;&lt;br /&gt;
            &amp;lt;% assigned_team = @assigned_teams_by_topic[topic.id].include?(team) %&amp;gt;&lt;br /&gt;
            &amp;lt;span class=&amp;quot;&amp;lt;%= assigned_team ? 'assigned-team' : '' %&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;%= team.name %&amp;gt; (#&amp;lt;%= bid_info[:priority] %&amp;gt;)&lt;br /&gt;
            &amp;lt;/span&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count1[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count1[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            No bids yet&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count2[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count2[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            No bids yet&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count3[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count3[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            No bids yet&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
      &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;% end %&amp;gt;&lt;br /&gt;
  &amp;lt;/tbody&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;javascript:history.back()&amp;quot;&amp;gt;Back&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details_view.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
'''3. The button of View Bidding Details'''&lt;br /&gt;
&lt;br /&gt;
File: &amp;lt;code&amp;gt;./app/assignments/edit/_topics.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= button_to 'View Bidding Details', {:controller =&amp;gt; 'lottery', :action =&amp;gt; 'bidding_details', :id =&amp;gt; @assignment_form.assignment.id}, &lt;br /&gt;
:method =&amp;gt; :get, class: 'custom-button', id: 'bidding-button' %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:View_bidding_button.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
'''4. RSpec Testing on &amp;quot;bidding_details&amp;quot; Method'''&lt;br /&gt;
&lt;br /&gt;
File: &amp;lt;code&amp;gt;./spec/controllers/lottery_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Structure:&lt;br /&gt;
&lt;br /&gt;
1. Setup (before :each block):&lt;br /&gt;
&lt;br /&gt;
*Initializes a testing environment before each test case.&lt;br /&gt;
*Sets up parameters (like assignment.id) to mimic a real request context.&lt;br /&gt;
&lt;br /&gt;
2. Test Case 1: Populating Bids and Assigned Teams&lt;br /&gt;
&lt;br /&gt;
*Objective: To test if the #bidding_details method correctly populates bids and assigned teams for each topic, including handling topics with no teams.&lt;br /&gt;
*Execution: Calls the #bidding_details method.&lt;br /&gt;
*Expectations:&lt;br /&gt;
**@bids_by_topic should correctly map topics to their respective bids.&lt;br /&gt;
**@assigned_teams_by_topic should correctly map topics to their assigned teams, handling cases where no teams are assigned.&lt;br /&gt;
**Counts of bids for each priority level (@count1, @count2, @count3) are checked against expected values.&lt;br /&gt;
&lt;br /&gt;
3. Test Case 2: Fetching All Topics&lt;br /&gt;
&lt;br /&gt;
*Objective: To verify if the method fetches all topics related to the assignment.&lt;br /&gt;
*Execution: Invokes #bidding_details.&lt;br /&gt;
*Expectation: The @topics instance variable should contain an array of all topics (e.g., [topic1, topic2, topic3, topic4]).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe '#bidding_details' do&lt;br /&gt;
    before :each do&lt;br /&gt;
      # Set the assignment id in the params&lt;br /&gt;
      params = ActionController::Parameters.new(id: assignment.id)&lt;br /&gt;
      allow(controller).to receive(:params).and_return(params)&lt;br /&gt;
    end&lt;br /&gt;
    it 'populates bids and assigned teams for each topic, handling topics with no teams' do&lt;br /&gt;
      controller.bidding_details&lt;br /&gt;
      # Check if @bids_by_topic is populated correctly&lt;br /&gt;
      expect(controller.instance_variable_get(:@bids_by_topic)[topic1.id].length).to eq(1)&lt;br /&gt;
      expect(controller.instance_variable_get(:@bids_by_topic)[topic2.id].length).to eq(1)&lt;br /&gt;
      # Check if @assigned_teams_by_topic is populated correctly, allowing for no teams&lt;br /&gt;
      assigned_teams_topic1 = controller.instance_variable_get(:@assigned_teams_by_topic)[topic1.id]&lt;br /&gt;
      if assigned_teams_topic1&lt;br /&gt;
        expect(assigned_teams_topic1.length).to(satisfy { |value| (value == 0) || (value == 1) })&lt;br /&gt;
      else&lt;br /&gt;
        expect(assigned_teams_topic1).to be_nil&lt;br /&gt;
      end&lt;br /&gt;
      # Check the counts of bids for each priority level&lt;br /&gt;
      # Ensure to adjust these based on what is set up in your test data&lt;br /&gt;
      expect(controller.instance_variable_get(:@count1)[topic1.id]).to eq(1) # assuming there is one bid with priority 1 for topic1&lt;br /&gt;
      expect(controller.instance_variable_get(:@count2)[topic1.id]).to eq(0) # assuming there are no bids with priority 2 for topic1&lt;br /&gt;
      expect(controller.instance_variable_get(:@count3)[topic1.id]).to eq(0) # assuming there are no bids with priority 3 for topic1&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'fetches all topics for the assignment' do&lt;br /&gt;
      controller.bidding_details&lt;br /&gt;
      expect(controller.instance_variable_get(:@topics)).to match_array([topic1, topic2, topic3, topic4])&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Rspec_testing.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
&lt;br /&gt;
'''Github Repository: ''' https://github.com/Shreshth-Malik/expertiza&lt;br /&gt;
&lt;br /&gt;
== Testing Credentials ==&lt;br /&gt;
&lt;br /&gt;
username: instructor6&lt;br /&gt;
&lt;br /&gt;
password: password&lt;br /&gt;
&lt;br /&gt;
== Team == &lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Edward F. Gehringer (efg@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
'''Members'''&lt;br /&gt;
&lt;br /&gt;
Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shreshth Malik (smalik4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shuai Chen (schen76@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding&amp;diff=152825</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding&amp;diff=152825"/>
		<updated>2023-12-06T05:33:19Z</updated>

		<summary type="html">&lt;p&gt;Schen76: /* Implemented Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
When topics are opened up for bidding, students can see how “hot” each topic is by the color it has on their topic list. However, instructors have no way to view the bidding process except by impersonating students. Furthermore, when the bidding assignment algorithm is run, there is no way to verify that it did in fact assign teams to topics they had chosen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Previous Work ==&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE_517_Spring_2022_-_E2245:_View_for_results_of_bidding]]&lt;br /&gt;
&lt;br /&gt;
== Accomplishments ==&lt;br /&gt;
&lt;br /&gt;
This project added a &amp;quot;View Bidding Details&amp;quot; when the instructor enables the &amp;quot;bidding for topics&amp;quot; feature. By clicking it, it redirects us to a new page, where shows the following details of bidding:&lt;br /&gt;
&lt;br /&gt;
*Topic Name&lt;br /&gt;
*Bidding Teams&lt;br /&gt;
*Bidding Order&lt;br /&gt;
*The number of bidding a topic gets&lt;br /&gt;
&lt;br /&gt;
Also, for each topic, the team that wins the bidding will be highlighted with a yellow background color so that the instructor can easily find out which team each topic is assigned to.&lt;br /&gt;
&lt;br /&gt;
The button leads to a page that contains bidding information for the assignment. It displays the number of #1, #2, and #3 bids on a specific topic, the teams that bid and priority of their bid, and the name of the team that got assigned the topic is highlighted. &lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_button.png ‎| 888px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details.png ‎| 888px]]&lt;br /&gt;
&lt;br /&gt;
'''Files Involved:'''&lt;br /&gt;
&lt;br /&gt;
The files to be worked upon are:&lt;br /&gt;
&lt;br /&gt;
*./app/controllers/lottering_controller.rb&lt;br /&gt;
*./app/views/lottery/bidding_details.ntml.erb&lt;br /&gt;
*./app/assignments/edit/_topics.html.erb&lt;br /&gt;
*./spec/controllers/lottery_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
*Richard Li  rli14@ncsu.edu&lt;br /&gt;
*Shreshth Malik  smalik4@ncsu.edu&lt;br /&gt;
*Shuai Chen  schen76@ncsu.edu&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Implemented Code ==&lt;br /&gt;
&lt;br /&gt;
'''1. Lottery Controller'''&lt;br /&gt;
&lt;br /&gt;
File: &amp;lt;code&amp;gt;./app/controllers/lottery_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Method: &amp;lt;code&amp;gt;&amp;quot;bidding_details&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Functionality:&lt;br /&gt;
&lt;br /&gt;
(1) Assignment Retrieval:&lt;br /&gt;
&lt;br /&gt;
*Retrieves the assignment based on the provided id from the params.&lt;br /&gt;
&lt;br /&gt;
(2) Topic Fetching:&lt;br /&gt;
&lt;br /&gt;
*Gathers all the sign-up topics associated with the retrieved assignment.&lt;br /&gt;
&lt;br /&gt;
(3) Initialization of Data Structures:&lt;br /&gt;
&lt;br /&gt;
*Initializes two hash data structures:&lt;br /&gt;
#@bids_by_topic: To store bids by topic.&lt;br /&gt;
#@assigned_teams_by_topic: To store teams assigned to each topic.&lt;br /&gt;
&lt;br /&gt;
(4) Data Aggregation:&lt;br /&gt;
&lt;br /&gt;
Iterates through each topic and performs the following actions:&lt;br /&gt;
&lt;br /&gt;
(i) Bids Gathering:&lt;br /&gt;
*Fetches all bids for each topic.&lt;br /&gt;
*Bids are stored in @bids_by_topic, mapped by the topic.id. Each bid includes the team and its priority.&lt;br /&gt;
&lt;br /&gt;
(ii) Assigned Teams Gathering:&lt;br /&gt;
*Retrieves teams that are assigned to a topic and are not waitlisted.&lt;br /&gt;
*The results are stored in @assigned_teams_by_topic, indexed by topic.id.&lt;br /&gt;
&lt;br /&gt;
(5) Priority Counts:&lt;br /&gt;
&lt;br /&gt;
*For each topic, the method calculates the number of bids at each priority level (1 to 3).&lt;br /&gt;
*It dynamically initializes and updates three instance variables: @count1, @count2, and @count3.&lt;br /&gt;
*Each of these variables is a hash that maps topic IDs to the count of bids at the respective priority.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def bidding_details&lt;br /&gt;
    @assignment = Assignment.find(params[:id])&lt;br /&gt;
    # Fetch all topics for the assignment&lt;br /&gt;
    @topics = @assignment.sign_up_topics&lt;br /&gt;
    # Fetch all bids for these topics&lt;br /&gt;
    @bids_by_topic = {}&lt;br /&gt;
    @assigned_teams_by_topic = {} # This will store the assigned teams for each topic&lt;br /&gt;
    @topics.each do |topic|&lt;br /&gt;
      # Assuming bids are stored with a topic_id, and each bid has a team associated with it&lt;br /&gt;
      @bids_by_topic[topic.id] = Bid.where(topic_id: topic.id).map { |bid| { team: bid.team, priority: bid.priority } }&lt;br /&gt;
      # Fetch teams that are not waitlisted for this topic&lt;br /&gt;
      @assigned_teams_by_topic[topic.id] = SignedUpTeam.where(topic_id: topic.id, is_waitlisted: false).map(&amp;amp;:team)&lt;br /&gt;
      # Dynamically initializing and updating @count1, @count2, and @count3&lt;br /&gt;
      (1..3).each do |priority|&lt;br /&gt;
        instance_variable_set(&amp;quot;@count#{priority}&amp;quot;, Hash.new(0)) unless instance_variable_defined?(&amp;quot;@count#{priority}&amp;quot;)&lt;br /&gt;
        instance_variable_get(&amp;quot;@count#{priority}&amp;quot;)[topic.id] = @bids_by_topic[topic.id].count { |bid| bid[:priority] == priority }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details_controller.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
'''2. Bidding Details View'''&lt;br /&gt;
&lt;br /&gt;
File: &amp;lt;code&amp;gt;./app/views/lottery/bidding_details.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Added a button and corresponding JavaScript which toggles its visibility based on “Enable bidding for topics?” checkbox.'''&lt;br /&gt;
&lt;br /&gt;
Components:&lt;br /&gt;
&lt;br /&gt;
1. Custom CSS Style:&lt;br /&gt;
&lt;br /&gt;
*A style block is defined to style elements with the assigned-team class. Teams assigned to a topic will have a yellow background and black text.&lt;br /&gt;
&lt;br /&gt;
2. Bidding Details Table:&lt;br /&gt;
&lt;br /&gt;
*A table is created with classes table, table-bordered, and table-hover for styling.&lt;br /&gt;
*The header (&amp;lt;thead&amp;gt;) section of the table defines five columns: &amp;quot;Topic Name&amp;quot;, &amp;quot;Bidding Teams&amp;quot;, and three columns for bid counts (&amp;quot;#1 bids&amp;quot;, &amp;quot;#2 bids&amp;quot;, &amp;quot;#3 bids&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
3. Dynamic Table Rows:&lt;br /&gt;
&lt;br /&gt;
*The &amp;lt;tbody&amp;gt; section uses ERB to iterate over each topic in the @topics array.&lt;br /&gt;
*Each topic creates a table row (&amp;lt;tr&amp;gt;) with the following data:&lt;br /&gt;
**Topic Name: Displayed using &amp;lt;%= topic.topic_name %&amp;gt;.&lt;br /&gt;
**Bidding Teams: A list of teams bidding on the topic. For each bid associated with the topic:&lt;br /&gt;
***The team's name and priority number are displayed.&lt;br /&gt;
***If the team is assigned to the topic, it is styled with the assigned-team class.&lt;br /&gt;
**Bid Counts: Three columns display the number of #1, #2, and #3 bids for each topic. If there are no bids, it displays &amp;quot;No bids yet&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
4. Navigation Link:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;a href=&amp;quot;javascript:history.back()&amp;quot;&amp;gt;Back&amp;lt;/a&amp;gt;&amp;lt;/code&amp;gt;: Provides a link to go back to the previous page in the browser history.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt;Bidding Details for &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;style&amp;gt;&lt;br /&gt;
.assigned-team {&lt;br /&gt;
  background-color: yellow; &lt;br /&gt;
  color: black;             &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/style&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table class=&amp;quot;table table-bordered table-hover&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;thead&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic Name&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Bidding Teams&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#1 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#2 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#3 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;/thead&amp;gt;&lt;br /&gt;
  &amp;lt;tbody&amp;gt;&lt;br /&gt;
    &amp;lt;% @topics.each do |topic| %&amp;gt;&lt;br /&gt;
      &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.topic_name %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&lt;br /&gt;
          &amp;lt;% @bids_by_topic[topic.id].each do |bid_info| %&amp;gt;&lt;br /&gt;
            &amp;lt;% team = bid_info[:team] %&amp;gt;&lt;br /&gt;
            &amp;lt;% assigned_team = @assigned_teams_by_topic[topic.id].include?(team) %&amp;gt;&lt;br /&gt;
            &amp;lt;span class=&amp;quot;&amp;lt;%= assigned_team ? 'assigned-team' : '' %&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;%= team.name %&amp;gt; (#&amp;lt;%= bid_info[:priority] %&amp;gt;)&lt;br /&gt;
            &amp;lt;/span&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count1[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count1[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            No bids yet&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count2[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count2[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            No bids yet&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count3[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count3[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            No bids yet&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
      &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;% end %&amp;gt;&lt;br /&gt;
  &amp;lt;/tbody&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;javascript:history.back()&amp;quot;&amp;gt;Back&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details_view.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
'''3. The button of View Bidding Details'''&lt;br /&gt;
&lt;br /&gt;
File: &amp;lt;code&amp;gt;./app/assignments/edit/_topics.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= button_to 'View Bidding Details', {:controller =&amp;gt; 'lottery', :action =&amp;gt; 'bidding_details', :id =&amp;gt; @assignment_form.assignment.id}, &lt;br /&gt;
:method =&amp;gt; :get, class: 'custom-button', id: 'bidding-button' %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:View_bidding_button.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
'''4. RSpec Testing on &amp;quot;bidding_details&amp;quot; Method'''&lt;br /&gt;
&lt;br /&gt;
File: &amp;lt;code&amp;gt;./spec/controllers/lottery_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Structure:&lt;br /&gt;
&lt;br /&gt;
1. Setup (before :each block):&lt;br /&gt;
&lt;br /&gt;
*Initializes a testing environment before each test case.&lt;br /&gt;
*Sets up parameters (like assignment.id) to mimic a real request context.&lt;br /&gt;
&lt;br /&gt;
2. Test Case 1: Populating Bids and Assigned Teams&lt;br /&gt;
&lt;br /&gt;
*Objective: To test if the #bidding_details method correctly populates bids and assigned teams for each topic, including handling topics with no teams.&lt;br /&gt;
*Execution: Calls the #bidding_details method.&lt;br /&gt;
*Expectations:&lt;br /&gt;
**@bids_by_topic should correctly map topics to their respective bids.&lt;br /&gt;
**@assigned_teams_by_topic should correctly map topics to their assigned teams, handling cases where no teams are assigned.&lt;br /&gt;
**Counts of bids for each priority level (@count1, @count2, @count3) are checked against expected values.&lt;br /&gt;
&lt;br /&gt;
3. Test Case 2: Fetching All Topics&lt;br /&gt;
&lt;br /&gt;
*Objective: To verify if the method fetches all topics related to the assignment.&lt;br /&gt;
*Execution: Invokes #bidding_details.&lt;br /&gt;
*Expectation: The @topics instance variable should contain an array of all topics (e.g., [topic1, topic2, topic3, topic4]).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe '#bidding_details' do&lt;br /&gt;
    before :each do&lt;br /&gt;
      # Set the assignment id in the params&lt;br /&gt;
      params = ActionController::Parameters.new(id: assignment.id)&lt;br /&gt;
      allow(controller).to receive(:params).and_return(params)&lt;br /&gt;
    end&lt;br /&gt;
    it 'populates bids and assigned teams for each topic, handling topics with no teams' do&lt;br /&gt;
      controller.bidding_details&lt;br /&gt;
      # Check if @bids_by_topic is populated correctly&lt;br /&gt;
      expect(controller.instance_variable_get(:@bids_by_topic)[topic1.id].length).to eq(1)&lt;br /&gt;
      expect(controller.instance_variable_get(:@bids_by_topic)[topic2.id].length).to eq(1)&lt;br /&gt;
      # Check if @assigned_teams_by_topic is populated correctly, allowing for no teams&lt;br /&gt;
      assigned_teams_topic1 = controller.instance_variable_get(:@assigned_teams_by_topic)[topic1.id]&lt;br /&gt;
      if assigned_teams_topic1&lt;br /&gt;
        expect(assigned_teams_topic1.length).to(satisfy { |value| (value == 0) || (value == 1) })&lt;br /&gt;
      else&lt;br /&gt;
        expect(assigned_teams_topic1).to be_nil&lt;br /&gt;
      end&lt;br /&gt;
      # Check the counts of bids for each priority level&lt;br /&gt;
      # Ensure to adjust these based on what is set up in your test data&lt;br /&gt;
      expect(controller.instance_variable_get(:@count1)[topic1.id]).to eq(1) # assuming there is one bid with priority 1 for topic1&lt;br /&gt;
      expect(controller.instance_variable_get(:@count2)[topic1.id]).to eq(0) # assuming there are no bids with priority 2 for topic1&lt;br /&gt;
      expect(controller.instance_variable_get(:@count3)[topic1.id]).to eq(0) # assuming there are no bids with priority 3 for topic1&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'fetches all topics for the assignment' do&lt;br /&gt;
      controller.bidding_details&lt;br /&gt;
      expect(controller.instance_variable_get(:@topics)).to match_array([topic1, topic2, topic3, topic4])&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Rspec_testing.png | 888px]]&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding&amp;diff=152824</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding&amp;diff=152824"/>
		<updated>2023-12-06T05:30:19Z</updated>

		<summary type="html">&lt;p&gt;Schen76: /* Implemented Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
When topics are opened up for bidding, students can see how “hot” each topic is by the color it has on their topic list. However, instructors have no way to view the bidding process except by impersonating students. Furthermore, when the bidding assignment algorithm is run, there is no way to verify that it did in fact assign teams to topics they had chosen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Previous Work ==&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE_517_Spring_2022_-_E2245:_View_for_results_of_bidding]]&lt;br /&gt;
&lt;br /&gt;
== Accomplishments ==&lt;br /&gt;
&lt;br /&gt;
This project added a &amp;quot;View Bidding Details&amp;quot; when the instructor enables the &amp;quot;bidding for topics&amp;quot; feature. By clicking it, it redirects us to a new page, where shows the following details of bidding:&lt;br /&gt;
&lt;br /&gt;
*Topic Name&lt;br /&gt;
*Bidding Teams&lt;br /&gt;
*Bidding Order&lt;br /&gt;
*The number of bidding a topic gets&lt;br /&gt;
&lt;br /&gt;
Also, for each topic, the team that wins the bidding will be highlighted with a yellow background color so that the instructor can easily find out which team each topic is assigned to.&lt;br /&gt;
&lt;br /&gt;
The button leads to a page that contains bidding information for the assignment. It displays the number of #1, #2, and #3 bids on a specific topic, the teams that bid and priority of their bid, and the name of the team that got assigned the topic is highlighted. &lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_button.png ‎| 888px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details.png ‎| 888px]]&lt;br /&gt;
&lt;br /&gt;
'''Files Involved:'''&lt;br /&gt;
&lt;br /&gt;
The files to be worked upon are:&lt;br /&gt;
&lt;br /&gt;
*./app/controllers/lottering_controller.rb&lt;br /&gt;
*./app/views/lottery/bidding_details.ntml.erb&lt;br /&gt;
*./app/assignments/edit/_topics.html.erb&lt;br /&gt;
*./spec/controllers/lottery_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
*Richard Li  rli14@ncsu.edu&lt;br /&gt;
*Shreshth Malik  smalik4@ncsu.edu&lt;br /&gt;
*Shuai Chen  schen76@ncsu.edu&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Implemented Code ==&lt;br /&gt;
&lt;br /&gt;
'''1. Lottery Controller'''&lt;br /&gt;
&lt;br /&gt;
File: &amp;lt;code&amp;gt;./app/controllers/lottery_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Method: &amp;lt;code&amp;gt;&amp;quot;bidding_details&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Functionality:&lt;br /&gt;
&lt;br /&gt;
(1) Assignment Retrieval:&lt;br /&gt;
&lt;br /&gt;
*Retrieves the assignment based on the provided id from the params.&lt;br /&gt;
&lt;br /&gt;
(2) Topic Fetching:&lt;br /&gt;
&lt;br /&gt;
*Gathers all the sign-up topics associated with the retrieved assignment.&lt;br /&gt;
&lt;br /&gt;
(3) Initialization of Data Structures:&lt;br /&gt;
&lt;br /&gt;
*Initializes two hash data structures:&lt;br /&gt;
#@bids_by_topic: To store bids by topic.&lt;br /&gt;
#@assigned_teams_by_topic: To store teams assigned to each topic.&lt;br /&gt;
&lt;br /&gt;
(4) Data Aggregation:&lt;br /&gt;
&lt;br /&gt;
Iterates through each topic and performs the following actions:&lt;br /&gt;
&lt;br /&gt;
(i) Bids Gathering:&lt;br /&gt;
*Fetches all bids for each topic.&lt;br /&gt;
*Bids are stored in @bids_by_topic, mapped by the topic.id. Each bid includes the team and its priority.&lt;br /&gt;
&lt;br /&gt;
(ii) Assigned Teams Gathering:&lt;br /&gt;
*Retrieves teams that are assigned to a topic and are not waitlisted.&lt;br /&gt;
*The results are stored in @assigned_teams_by_topic, indexed by topic.id.&lt;br /&gt;
&lt;br /&gt;
(5) Priority Counts:&lt;br /&gt;
&lt;br /&gt;
*For each topic, the method calculates the number of bids at each priority level (1 to 3).&lt;br /&gt;
*It dynamically initializes and updates three instance variables: @count1, @count2, and @count3.&lt;br /&gt;
*Each of these variables is a hash that maps topic IDs to the count of bids at the respective priority.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def bidding_details&lt;br /&gt;
    @assignment = Assignment.find(params[:id])&lt;br /&gt;
    # Fetch all topics for the assignment&lt;br /&gt;
    @topics = @assignment.sign_up_topics&lt;br /&gt;
    # Fetch all bids for these topics&lt;br /&gt;
    @bids_by_topic = {}&lt;br /&gt;
    @assigned_teams_by_topic = {} # This will store the assigned teams for each topic&lt;br /&gt;
    @topics.each do |topic|&lt;br /&gt;
      # Assuming bids are stored with a topic_id, and each bid has a team associated with it&lt;br /&gt;
      @bids_by_topic[topic.id] = Bid.where(topic_id: topic.id).map { |bid| { team: bid.team, priority: bid.priority } }&lt;br /&gt;
      # Fetch teams that are not waitlisted for this topic&lt;br /&gt;
      @assigned_teams_by_topic[topic.id] = SignedUpTeam.where(topic_id: topic.id, is_waitlisted: false).map(&amp;amp;:team)&lt;br /&gt;
      # Dynamically initializing and updating @count1, @count2, and @count3&lt;br /&gt;
      (1..3).each do |priority|&lt;br /&gt;
        instance_variable_set(&amp;quot;@count#{priority}&amp;quot;, Hash.new(0)) unless instance_variable_defined?(&amp;quot;@count#{priority}&amp;quot;)&lt;br /&gt;
        instance_variable_get(&amp;quot;@count#{priority}&amp;quot;)[topic.id] = @bids_by_topic[topic.id].count { |bid| bid[:priority] == priority }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details_controller.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
'''2. Bidding Details View'''&lt;br /&gt;
&lt;br /&gt;
File: &amp;lt;code&amp;gt;./app/views/lottery/bidding_details.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Added a button and corresponding JavaScript which toggles its visibility based on “Enable bidding for topics?” checkbox.'''&lt;br /&gt;
&lt;br /&gt;
Components:&lt;br /&gt;
&lt;br /&gt;
1. Custom CSS Style:&lt;br /&gt;
&lt;br /&gt;
*A style block is defined to style elements with the assigned-team class. Teams assigned to a topic will have a yellow background and black text.&lt;br /&gt;
&lt;br /&gt;
2. Bidding Details Table:&lt;br /&gt;
&lt;br /&gt;
*A table is created with classes table, table-bordered, and table-hover for styling.&lt;br /&gt;
*The header (&amp;lt;thead&amp;gt;) section of the table defines five columns: &amp;quot;Topic Name&amp;quot;, &amp;quot;Bidding Teams&amp;quot;, and three columns for bid counts (&amp;quot;#1 bids&amp;quot;, &amp;quot;#2 bids&amp;quot;, &amp;quot;#3 bids&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
3. Dynamic Table Rows:&lt;br /&gt;
&lt;br /&gt;
*The &amp;lt;tbody&amp;gt; section uses ERB to iterate over each topic in the @topics array.&lt;br /&gt;
*Each topic creates a table row (&amp;lt;tr&amp;gt;) with the following data:&lt;br /&gt;
**Topic Name: Displayed using &amp;lt;%= topic.topic_name %&amp;gt;.&lt;br /&gt;
**Bidding Teams: A list of teams bidding on the topic. For each bid associated with the topic:&lt;br /&gt;
***The team's name and priority number are displayed.&lt;br /&gt;
***If the team is assigned to the topic, it is styled with the assigned-team class.&lt;br /&gt;
**Bid Counts: Three columns display the number of #1, #2, and #3 bids for each topic. If there are no bids, it displays &amp;quot;No bids yet&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
4. Navigation Link:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;a href=&amp;quot;javascript:history.back()&amp;quot;&amp;gt;Back&amp;lt;/a&amp;gt;&amp;lt;/code&amp;gt;: Provides a link to go back to the previous page in the browser history.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt;Bidding Details for &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;style&amp;gt;&lt;br /&gt;
.assigned-team {&lt;br /&gt;
  background-color: yellow; &lt;br /&gt;
  color: black;             &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/style&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table class=&amp;quot;table table-bordered table-hover&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;thead&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic Name&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Bidding Teams&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#1 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#2 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#3 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;/thead&amp;gt;&lt;br /&gt;
  &amp;lt;tbody&amp;gt;&lt;br /&gt;
    &amp;lt;% @topics.each do |topic| %&amp;gt;&lt;br /&gt;
      &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.topic_name %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&lt;br /&gt;
          &amp;lt;% @bids_by_topic[topic.id].each do |bid_info| %&amp;gt;&lt;br /&gt;
            &amp;lt;% team = bid_info[:team] %&amp;gt;&lt;br /&gt;
            &amp;lt;% assigned_team = @assigned_teams_by_topic[topic.id].include?(team) %&amp;gt;&lt;br /&gt;
            &amp;lt;span class=&amp;quot;&amp;lt;%= assigned_team ? 'assigned-team' : '' %&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;%= team.name %&amp;gt; (#&amp;lt;%= bid_info[:priority] %&amp;gt;)&lt;br /&gt;
            &amp;lt;/span&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count1[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count1[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            No bids yet&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count2[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count2[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            No bids yet&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count3[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count3[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            No bids yet&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
      &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;% end %&amp;gt;&lt;br /&gt;
  &amp;lt;/tbody&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;javascript:history.back()&amp;quot;&amp;gt;Back&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details_view.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
'''3. The button of View Bidding Details'''&lt;br /&gt;
&lt;br /&gt;
File: &amp;lt;code&amp;gt;./app/assignments/edit/_topics.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= button_to 'View Bidding Details', {:controller =&amp;gt; 'lottery', :action =&amp;gt; 'bidding_details', :id =&amp;gt; @assignment_form.assignment.id}, &lt;br /&gt;
:method =&amp;gt; :get, class: 'custom-button', id: 'bidding-button' %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:View_bidding_button.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
'''4. RSpec Testing on &amp;quot;bidding_details&amp;quot; Method'''&lt;br /&gt;
&lt;br /&gt;
File: &amp;lt;code&amp;gt;./spec/controllers/lottery_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe '#bidding_details' do&lt;br /&gt;
    before :each do&lt;br /&gt;
      # Set the assignment id in the params&lt;br /&gt;
      params = ActionController::Parameters.new(id: assignment.id)&lt;br /&gt;
      allow(controller).to receive(:params).and_return(params)&lt;br /&gt;
    end&lt;br /&gt;
    it 'populates bids and assigned teams for each topic, handling topics with no teams' do&lt;br /&gt;
      controller.bidding_details&lt;br /&gt;
      # Check if @bids_by_topic is populated correctly&lt;br /&gt;
      expect(controller.instance_variable_get(:@bids_by_topic)[topic1.id].length).to eq(1)&lt;br /&gt;
      expect(controller.instance_variable_get(:@bids_by_topic)[topic2.id].length).to eq(1)&lt;br /&gt;
      # Check if @assigned_teams_by_topic is populated correctly, allowing for no teams&lt;br /&gt;
      assigned_teams_topic1 = controller.instance_variable_get(:@assigned_teams_by_topic)[topic1.id]&lt;br /&gt;
      if assigned_teams_topic1&lt;br /&gt;
        expect(assigned_teams_topic1.length).to(satisfy { |value| (value == 0) || (value == 1) })&lt;br /&gt;
      else&lt;br /&gt;
        expect(assigned_teams_topic1).to be_nil&lt;br /&gt;
      end&lt;br /&gt;
      # Check the counts of bids for each priority level&lt;br /&gt;
      # Ensure to adjust these based on what is set up in your test data&lt;br /&gt;
      expect(controller.instance_variable_get(:@count1)[topic1.id]).to eq(1) # assuming there is one bid with priority 1 for topic1&lt;br /&gt;
      expect(controller.instance_variable_get(:@count2)[topic1.id]).to eq(0) # assuming there are no bids with priority 2 for topic1&lt;br /&gt;
      expect(controller.instance_variable_get(:@count3)[topic1.id]).to eq(0) # assuming there are no bids with priority 3 for topic1&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'fetches all topics for the assignment' do&lt;br /&gt;
      controller.bidding_details&lt;br /&gt;
      expect(controller.instance_variable_get(:@topics)).to match_array([topic1, topic2, topic3, topic4])&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Rspec_testing.png | 888px]]&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding&amp;diff=152823</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding&amp;diff=152823"/>
		<updated>2023-12-06T05:23:52Z</updated>

		<summary type="html">&lt;p&gt;Schen76: /* Implemented Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
When topics are opened up for bidding, students can see how “hot” each topic is by the color it has on their topic list. However, instructors have no way to view the bidding process except by impersonating students. Furthermore, when the bidding assignment algorithm is run, there is no way to verify that it did in fact assign teams to topics they had chosen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Previous Work ==&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE_517_Spring_2022_-_E2245:_View_for_results_of_bidding]]&lt;br /&gt;
&lt;br /&gt;
== Accomplishments ==&lt;br /&gt;
&lt;br /&gt;
This project added a &amp;quot;View Bidding Details&amp;quot; when the instructor enables the &amp;quot;bidding for topics&amp;quot; feature. By clicking it, it redirects us to a new page, where shows the following details of bidding:&lt;br /&gt;
&lt;br /&gt;
*Topic Name&lt;br /&gt;
*Bidding Teams&lt;br /&gt;
*Bidding Order&lt;br /&gt;
*The number of bidding a topic gets&lt;br /&gt;
&lt;br /&gt;
Also, for each topic, the team that wins the bidding will be highlighted with a yellow background color so that the instructor can easily find out which team each topic is assigned to.&lt;br /&gt;
&lt;br /&gt;
The button leads to a page that contains bidding information for the assignment. It displays the number of #1, #2, and #3 bids on a specific topic, the teams that bid and priority of their bid, and the name of the team that got assigned the topic is highlighted. &lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_button.png ‎| 888px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details.png ‎| 888px]]&lt;br /&gt;
&lt;br /&gt;
'''Files Involved:'''&lt;br /&gt;
&lt;br /&gt;
The files to be worked upon are:&lt;br /&gt;
&lt;br /&gt;
*./app/controllers/lottering_controller.rb&lt;br /&gt;
*./app/views/lottery/bidding_details.ntml.erb&lt;br /&gt;
*./app/assignments/edit/_topics.html.erb&lt;br /&gt;
*./spec/controllers/lottery_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
*Richard Li  rli14@ncsu.edu&lt;br /&gt;
*Shreshth Malik  smalik4@ncsu.edu&lt;br /&gt;
*Shuai Chen  schen76@ncsu.edu&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Implemented Code ==&lt;br /&gt;
&lt;br /&gt;
'''1. Lottery Controller'''&lt;br /&gt;
&lt;br /&gt;
File: &amp;lt;code&amp;gt;./app/controllers/lottery_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Method: &amp;lt;code&amp;gt;&amp;quot;bidding_details&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Functionality:&lt;br /&gt;
&lt;br /&gt;
(1) Assignment Retrieval:&lt;br /&gt;
&lt;br /&gt;
*Retrieves the assignment based on the provided id from the params.&lt;br /&gt;
&lt;br /&gt;
(2) Topic Fetching:&lt;br /&gt;
&lt;br /&gt;
*Gathers all the sign-up topics associated with the retrieved assignment.&lt;br /&gt;
&lt;br /&gt;
(3) Initialization of Data Structures:&lt;br /&gt;
&lt;br /&gt;
*Initializes two hash data structures:&lt;br /&gt;
#@bids_by_topic: To store bids by topic.&lt;br /&gt;
#@assigned_teams_by_topic: To store teams assigned to each topic.&lt;br /&gt;
&lt;br /&gt;
(4) Data Aggregation:&lt;br /&gt;
&lt;br /&gt;
Iterates through each topic and performs the following actions:&lt;br /&gt;
&lt;br /&gt;
(i) Bids Gathering:&lt;br /&gt;
*Fetches all bids for each topic.&lt;br /&gt;
*Bids are stored in @bids_by_topic, mapped by the topic.id. Each bid includes the team and its priority.&lt;br /&gt;
&lt;br /&gt;
(ii) Assigned Teams Gathering:&lt;br /&gt;
*Retrieves teams that are assigned to a topic and are not waitlisted.&lt;br /&gt;
*The results are stored in @assigned_teams_by_topic, indexed by topic.id.&lt;br /&gt;
&lt;br /&gt;
(5) Priority Counts:&lt;br /&gt;
&lt;br /&gt;
*For each topic, the method calculates the number of bids at each priority level (1 to 3).&lt;br /&gt;
*It dynamically initializes and updates three instance variables: @count1, @count2, and @count3.&lt;br /&gt;
*Each of these variables is a hash that maps topic IDs to the count of bids at the respective priority.&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details_controller.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
'''2. Bidding Details View'''&lt;br /&gt;
&lt;br /&gt;
File: &amp;lt;code&amp;gt;./app/views/lottery/bidding_details.html.erb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Added a button and corresponding JavaScript which toggles its visibility based on “Enable bidding for topics?” checkbox.'''&lt;br /&gt;
&lt;br /&gt;
Components:&lt;br /&gt;
&lt;br /&gt;
1. Custom CSS Style:&lt;br /&gt;
&lt;br /&gt;
*A style block is defined to style elements with the assigned-team class. Teams assigned to a topic will have a yellow background and black text.&lt;br /&gt;
&lt;br /&gt;
2. Bidding Details Table:&lt;br /&gt;
&lt;br /&gt;
*A table is created with classes table, table-bordered, and table-hover for styling.&lt;br /&gt;
*The header (&amp;lt;thead&amp;gt;) section of the table defines five columns: &amp;quot;Topic Name&amp;quot;, &amp;quot;Bidding Teams&amp;quot;, and three columns for bid counts (&amp;quot;#1 bids&amp;quot;, &amp;quot;#2 bids&amp;quot;, &amp;quot;#3 bids&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
3. Dynamic Table Rows:&lt;br /&gt;
&lt;br /&gt;
*The &amp;lt;tbody&amp;gt; section uses ERB to iterate over each topic in the @topics array.&lt;br /&gt;
*Each topic creates a table row (&amp;lt;tr&amp;gt;) with the following data:&lt;br /&gt;
**Topic Name: Displayed using &amp;lt;%= topic.topic_name %&amp;gt;.&lt;br /&gt;
**Bidding Teams: A list of teams bidding on the topic. For each bid associated with the topic:&lt;br /&gt;
***The team's name and priority number are displayed.&lt;br /&gt;
***If the team is assigned to the topic, it is styled with the assigned-team class.&lt;br /&gt;
**Bid Counts: Three columns display the number of #1, #2, and #3 bids for each topic. If there are no bids, it displays &amp;quot;No bids yet&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
4. Navigation Link:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;a href=&amp;quot;javascript:history.back()&amp;quot;&amp;gt;Back&amp;lt;/a&amp;gt;&amp;lt;/code&amp;gt;: Provides a link to go back to the previous page in the browser history.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details_view.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
'''3. The button of View Bidding Details'''&lt;br /&gt;
&lt;br /&gt;
File: ./app/assignments/edit/_topics.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:View_bidding_button.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
File: ./spec/controllers/lottery_controller.spec.rb&lt;br /&gt;
&lt;br /&gt;
'''4. RSpec Testing on &amp;quot;bidding_details&amp;quot; Method'''&lt;br /&gt;
&lt;br /&gt;
File: ./spec/controllers/lottery_controller.spec.rb&lt;br /&gt;
&lt;br /&gt;
[[File:Rspec_testing.png | 888px]]&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding&amp;diff=152822</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding&amp;diff=152822"/>
		<updated>2023-12-06T05:05:25Z</updated>

		<summary type="html">&lt;p&gt;Schen76: /* Implemented Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
When topics are opened up for bidding, students can see how “hot” each topic is by the color it has on their topic list. However, instructors have no way to view the bidding process except by impersonating students. Furthermore, when the bidding assignment algorithm is run, there is no way to verify that it did in fact assign teams to topics they had chosen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Previous Work ==&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE_517_Spring_2022_-_E2245:_View_for_results_of_bidding]]&lt;br /&gt;
&lt;br /&gt;
== Accomplishments ==&lt;br /&gt;
&lt;br /&gt;
This project added a &amp;quot;View Bidding Details&amp;quot; when the instructor enables the &amp;quot;bidding for topics&amp;quot; feature. By clicking it, it redirects us to a new page, where shows the following details of bidding:&lt;br /&gt;
&lt;br /&gt;
*Topic Name&lt;br /&gt;
*Bidding Teams&lt;br /&gt;
*Bidding Order&lt;br /&gt;
*The number of bidding a topic gets&lt;br /&gt;
&lt;br /&gt;
Also, for each topic, the team that wins the bidding will be highlighted with a yellow background color so that the instructor can easily find out which team each topic is assigned to.&lt;br /&gt;
&lt;br /&gt;
The button leads to a page that contains bidding information for the assignment. It displays the number of #1, #2, and #3 bids on a specific topic, the teams that bid and priority of their bid, and the name of the team that got assigned the topic is highlighted. &lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_button.png ‎| 888px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details.png ‎| 888px]]&lt;br /&gt;
&lt;br /&gt;
'''Files Involved:'''&lt;br /&gt;
&lt;br /&gt;
The files to be worked upon are:&lt;br /&gt;
&lt;br /&gt;
*./app/controllers/lottering_controller.rb&lt;br /&gt;
*./app/views/lottery/bidding_details.ntml.erb&lt;br /&gt;
*./app/assignments/edit/_topics.html.erb&lt;br /&gt;
*./spec/controllers/lottery_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
*Richard Li  rli14@ncsu.edu&lt;br /&gt;
*Shreshth Malik  smalik4@ncsu.edu&lt;br /&gt;
*Shuai Chen  schen76@ncsu.edu&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Implemented Code ==&lt;br /&gt;
&lt;br /&gt;
'''1. Lottering Controller'''&lt;br /&gt;
&lt;br /&gt;
File: ./app/controllers/lottery_controller.rb&lt;br /&gt;
&lt;br /&gt;
Method: &amp;quot;bidding_details&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''The controller for fetching topics and bids.'''&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details_controller.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
'''2. Bidding Details View'''&lt;br /&gt;
&lt;br /&gt;
File: ./app/views/lottery/bidding_details.ntml.erb&lt;br /&gt;
&lt;br /&gt;
'''Added a button and corresponding JavaScript which toggles its visibility based on “Enable bidding for topics?” checkbox.'''&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details_view.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
'''3. The button of View Bidding Details'''&lt;br /&gt;
&lt;br /&gt;
File: ./app/assignments/edit/_topics.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:View_bidding_button.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
File: ./spec/controllers/lottery_controller.spec.rb&lt;br /&gt;
&lt;br /&gt;
'''4. RSpec Testing on &amp;quot;bidding_details&amp;quot; Method'''&lt;br /&gt;
&lt;br /&gt;
File: ./spec/controllers/lottery_controller.spec.rb&lt;br /&gt;
&lt;br /&gt;
[[File:Rspec_testing.png | 888px]]&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152821</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding (Phase2)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152821"/>
		<updated>2023-12-06T04:59:02Z</updated>

		<summary type="html">&lt;p&gt;Schen76: /* Code Effort */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Motivation ==&lt;br /&gt;
&lt;br /&gt;
The bidding view is needed because we don’t have a way of finding out whether the bidding algorithm is running correctly.  This project is to add a bidding view to show how the topics are assigned to those teams who bid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Work Plan ==&lt;br /&gt;
&lt;br /&gt;
Based on the project's objectives and feedback received from our mentor, we have identified specific areas for improvement:&lt;br /&gt;
&lt;br /&gt;
1) Refactor variable names within methods such as &amp;quot;bidding_details&amp;quot; and variables like &amp;quot;Topic name&amp;quot; and &amp;quot;Bidding teams&amp;quot; to enhance clarity and specificity.&lt;br /&gt;
&lt;br /&gt;
2) Adjust capitalization for certain components, ensuring that only the first word is capitalized for consistency.&lt;br /&gt;
&lt;br /&gt;
3) Introduce calculations to determine percentages based on additional data, such as the total number of teams and the number of teams for each priority, within the &amp;quot;lottery_controller.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4) Conduct thorough testing of the modified controller and view to ensure optimal functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Newfeature.jpg | 888px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To add functionality for showing the percentages of the number of teams that got their #1, #2, and #3 choices. We can follow these high-level steps:&lt;br /&gt;
&lt;br /&gt;
'''Lottery_Controller:'''&lt;br /&gt;
&lt;br /&gt;
i) Calculate the Total Number of Teams: Before we can calculate percentages, we need to know the total number of teams that participated in the bidding process. This will be our denominator in the percentage calculation.&lt;br /&gt;
&lt;br /&gt;
ii) Calculate the Number of Teams for Each Priority: From our `bidding_details` method, we already have counts for how many teams bid on each topic as their #1, #2, and #3 choice (`@count1`, `@count2`, `@count3`). However, these counts are currently organized by topic. We would need to modify this to count how many teams got their #1, #2, and #3 choices as their assigned topic.&lt;br /&gt;
&lt;br /&gt;
iii) Calculate Percentages: Once we have the number of teams that got their #1, #2, and #3 choices, we can calculate the percentages by dividing these numbers by the total number of teams and multiplying by 100.&lt;br /&gt;
&lt;br /&gt;
'''Bidding_detail view:'''&lt;br /&gt;
&lt;br /&gt;
i) Update the View and Display Percentages: Above the table in our previous view, we can add a section to display these percentages.&lt;br /&gt;
&lt;br /&gt;
ii) Format the Display: We will use a bold heading for each percentage type and format the number to a fixed number of decimal places.&lt;br /&gt;
&lt;br /&gt;
iii) Ensure Responsiveness: Make sure the display of these percentages adjusts well to different screen sizes, maintaining readability and layout consistency. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code Effort ==&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; app/controllers/lottery_controller.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 1: bidding_table_for_each_topic'''&lt;br /&gt;
&lt;br /&gt;
This method generates a bidding table for each topic within an assignment. It performs several operations to gather and organize data related to topics, bids, and teams. Here's a breakdown of what the code does:&lt;br /&gt;
&lt;br /&gt;
1. Fetch Assignment:&lt;br /&gt;
&lt;br /&gt;
*It retrieves the assignment with the specified params[:id] from the database and stores it in the @assignment instance variable.&lt;br /&gt;
&lt;br /&gt;
2. Fetch Topics:&lt;br /&gt;
&lt;br /&gt;
*It retrieves all sign-up topics associated with the assignment and stores them in the @topics instance variable.&lt;br /&gt;
&lt;br /&gt;
3. Fetch Bids and Assigned Teams:&lt;br /&gt;
&lt;br /&gt;
For each topic in @topics, it:&lt;br /&gt;
*Retrieves all bids associated with that topic and stores them in a hash, where the key is the topic's ID and the value is an array of bids with their associated teams and priorities.&lt;br /&gt;
*Retrieves teams that are not waitlisted for the topic and stores them in a hash, again using the topic's ID as the key and an array of teams as the value.&lt;br /&gt;
&lt;br /&gt;
4. Priority Count Calculation:&lt;br /&gt;
&lt;br /&gt;
*It dynamically calculates and updates the counts for each bid priority level (1, 2, and 3) for each topic. These counts are stored in instance variables named @count1, @count2, and @count3. These instance variables are hashes where the keys are topic IDs, and the values are counts for each priority level.&lt;br /&gt;
&lt;br /&gt;
5. Calculate Total Teams:&lt;br /&gt;
&lt;br /&gt;
*It determines the total number of teams across all topics in the assignment by counting distinct team IDs among all non-waitlisted teams for the specified topics.&lt;br /&gt;
&lt;br /&gt;
6. Calculate Priority Counts and Percentages:&lt;br /&gt;
&lt;br /&gt;
*It calls two helper methods, calculate_priority_counts and calculate_percentages, to calculate the total counts of teams at each priority level and the corresponding percentages. The results are stored in the @priority_counts and @percentages instance variables, respectively.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Prepares data for displaying the bidding details for each topic within an assignment.&lt;br /&gt;
  # It calculates the number of bids for each priority (1, 2, 3) per topic and also computes&lt;br /&gt;
  # the overall percentages of teams that received their first, second, and third choice.&lt;br /&gt;
  def bidding_table_for_each_topic&lt;br /&gt;
    @assignment = Assignment.find(params[:id])&lt;br /&gt;
    # Fetch all topics for the assignment&lt;br /&gt;
    @topics = @assignment.sign_up_topics&lt;br /&gt;
    # Fetch all bids for these topics&lt;br /&gt;
    @bids_by_topic = {}&lt;br /&gt;
    @assigned_teams_by_topic = {} # This will store the assigned teams for each topic&lt;br /&gt;
    @topics.each do |topic|&lt;br /&gt;
      # Assuming bids are stored with a topic_id, and each bid has a team associated with it&lt;br /&gt;
      @bids_by_topic[topic.id] = Bid.where(topic_id: topic.id).map { |bid| { team: bid.team, priority: bid.priority } }&lt;br /&gt;
      # Fetch teams that are not waitlisted for this topic&lt;br /&gt;
      @assigned_teams_by_topic[topic.id] = SignedUpTeam.where(topic_id: topic.id, is_waitlisted: false).map(&amp;amp;:team)&lt;br /&gt;
      # @count1[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 1 }&lt;br /&gt;
      # @count2[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 2 }&lt;br /&gt;
      # @count3[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 3 }       &lt;br /&gt;
&lt;br /&gt;
      # Dynamically initializing and updating @count1, @count2, and @count3&lt;br /&gt;
      (1..3).each do |priority|&lt;br /&gt;
        instance_variable_set(&amp;quot;@count#{priority}&amp;quot;, Hash.new(0)) unless instance_variable_defined?(&amp;quot;@count#{priority}&amp;quot;)&lt;br /&gt;
        instance_variable_get(&amp;quot;@count#{priority}&amp;quot;)[topic.id] = @bids_by_topic[topic.id].count { |bid| bid[:priority] == priority }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # Calculate the total number of teams and percentages after fetching bid details&lt;br /&gt;
    topic_ids = SignUpTopic.where(assignment_id: @assignment.id).pluck(:id)&lt;br /&gt;
    @total_teams = SignedUpTeam.where(topic_id: topic_ids).distinct.count(:team_id)&lt;br /&gt;
    @priority_counts = calculate_priority_counts(@assigned_teams_by_topic, @bids_by_topic)&lt;br /&gt;
    @percentages = calculate_percentages(@priority_counts, @total_teams)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 2: calculate_priority_counts'''&lt;br /&gt;
&lt;br /&gt;
1. Parameters&lt;br /&gt;
*assigned_teams_by_topic (Hash): A hash mapping each topic to an array of assigned teams.&lt;br /&gt;
*bids_by_topic (Hash): A hash mapping each topic to an array of bid objects, where each bid object is a hash containing team and priority information.&lt;br /&gt;
&lt;br /&gt;
2. Functionality&lt;br /&gt;
*Initial Setup: Initializes a hash priority_counts with keys 1, 2, and 3, each having an initial value of 0. These keys represent the priority levels, and their values count the number of teams assigned to each level.&lt;br /&gt;
&lt;br /&gt;
*Iterating Over Topics and Teams: Iterates over each topic and its associated teams found in assigned_teams_by_topic. For each team in a topic, the method searches bids_by_topic[topic_id] to find a bid made by the team.&lt;br /&gt;
&lt;br /&gt;
*Updating Priority Counts: If a bid is found, the method increments the count in priority_counts corresponding to the priority level in the bid. This process effectively tallies the number of teams assigned to each priority level.&lt;br /&gt;
&lt;br /&gt;
3. Returns&lt;br /&gt;
*priority_counts (Hash): A hash with keys 1, 2, and 3, where each key's value represents the count of teams assigned to that respective priority level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Calculates the count of assigned teams for each priority level (1, 2, 3) across all topics.&lt;br /&gt;
  # It checks each team associated with a topic and determines if the team's bid matches&lt;br /&gt;
  # one of the priority levels, incrementing the respective count if so.&lt;br /&gt;
  def calculate_priority_counts(assigned_teams_by_topic, bids_by_topic)&lt;br /&gt;
    priority_counts = { 1 =&amp;gt; 0, 2 =&amp;gt; 0, 3 =&amp;gt; 0 }&lt;br /&gt;
    assigned_teams_by_topic.each do |topic_id, teams|&lt;br /&gt;
      teams.each do |team|&lt;br /&gt;
        bid_info = bids_by_topic[topic_id].find { |bid| bid[:team] == team }&lt;br /&gt;
        priority_counts[bid_info[:priority]] += 1 if bid_info&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    priority_counts&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 3: calculate_percentages'''&lt;br /&gt;
&lt;br /&gt;
* This method calculates the percentages of teams that received their first, second, and third choice based on the counts of teams at each priority level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Calculates the percentages of teams that received their first, second, and third choice&lt;br /&gt;
  # based on the counts of teams at each priority level.&lt;br /&gt;
  def calculate_percentages(priority_counts, total_teams)&lt;br /&gt;
    priority_counts.transform_values { |count| (count.to_f / total_teams * 100).round(2) }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_each_topic.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:bidding_percentage.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Components:&lt;br /&gt;
&lt;br /&gt;
1. Bidding Details Header&lt;br /&gt;
&lt;br /&gt;
*Displays the name of the assignment dynamically using &amp;lt;%= @assignment.name %&amp;gt;.&lt;br /&gt;
*This is enclosed in an &amp;quot;h3&amp;quot; tag, emphasizing its importance as the page's main title.&lt;br /&gt;
&lt;br /&gt;
2. Percentage Display Section&lt;br /&gt;
&lt;br /&gt;
*This section is styled with a border, padding, and a background color to make it visually distinct.&lt;br /&gt;
*It contains a subtitle (h4) describing the content: &amp;quot;Percentage of Teams Getting Their Choices.&amp;quot;&lt;br /&gt;
*A list (ul) displays the percentages of teams that received their 1st, 2nd, and 3rd choice. These percentages are pulled dynamically from @percentages array.&lt;br /&gt;
*The colors of the percentage values vary based on the choice priority (green for #1, orange for #2, and red for #3).&lt;br /&gt;
Custom CSS Styles&lt;br /&gt;
&lt;br /&gt;
3. Two CSS classes are defined:&lt;br /&gt;
&lt;br /&gt;
*.assigned-team: Styles elements with a yellow background and black text.&lt;br /&gt;
*.bids-column: Sets a fixed width for columns in the table.&lt;br /&gt;
&lt;br /&gt;
4. Bidding Details Table&lt;br /&gt;
&lt;br /&gt;
*A table with headers for Topic Name, Topic ID, Bidding Teams, and bids.&lt;br /&gt;
*The table body (&amp;lt;tbody&amp;gt;) dynamically generates rows for each topic using a loop (&amp;lt;% @topics.each do |topic| %&amp;gt;).&lt;br /&gt;
*For each topic, the table displays its name, ID, bidding teams, and the number of bids for each choice.&lt;br /&gt;
*Teams are marked with the .assigned-team class if they are assigned to the topic.&lt;br /&gt;
*Bid counts are displayed, with a placeholder (&amp;quot;–&amp;quot;) if the count is zero.&lt;br /&gt;
&lt;br /&gt;
5. Navigation&lt;br /&gt;
&lt;br /&gt;
*A link allowing users to navigate back to the previous page using JavaScript's history.back() function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt;Bidding Details for &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;!-- Displaying percentages in a more visually appealing way --&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;percentages&amp;quot; style=&amp;quot;margin-bottom: 20px; padding: 15px; border: 1px solid&lt;br /&gt;
#ccc; border-radius: 5px; background-color: #f9f9f9;&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;h4 style=&amp;quot;margin-bottom: 15px; border-bottom: 1px solid #eee;&lt;br /&gt;
padding-bottom: 10px;&amp;quot;&amp;gt;Percentage of Teams Getting Their Choices:&amp;lt;/h4&amp;gt;&lt;br /&gt;
  &amp;lt;ul style=&amp;quot;list-style: none; padding: 0;&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;#1 Choice:&amp;lt;/strong&amp;gt; &amp;lt;span style=&amp;quot;color: #4CAF50;&amp;quot;&amp;gt;&amp;lt;%= @percentages[1] || 0 %&amp;gt; %&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;#2 Choice:&amp;lt;/strong&amp;gt; &amp;lt;span style=&amp;quot;color: #FF9800;&amp;quot;&amp;gt;&amp;lt;%= @percentages[2] || 0 %&amp;gt; %&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;#3 Choice:&amp;lt;/strong&amp;gt; &amp;lt;span style=&amp;quot;color: #F44336;&amp;quot;&amp;gt;&amp;lt;%= @percentages[3] || 0 %&amp;gt; %&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;style&amp;gt;&lt;br /&gt;
.assigned-team {&lt;br /&gt;
  background-color: yellow; &lt;br /&gt;
  color: black;             &lt;br /&gt;
}&lt;br /&gt;
.bids-column {&lt;br /&gt;
    width: 100px; /* Adjust width as needed */&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/style&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table class=&amp;quot;table table-bordered table-hover&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;thead&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic Name&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic ID&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Bidding Teams&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#1 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#2 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#3 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;/thead&amp;gt;&lt;br /&gt;
  &amp;lt;tbody&amp;gt;&lt;br /&gt;
    &amp;lt;% @topics.each do |topic| %&amp;gt;&lt;br /&gt;
      &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.topic_name %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.id %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&lt;br /&gt;
          &amp;lt;% @bids_by_topic[topic.id].each do |bid_info| %&amp;gt;&lt;br /&gt;
            &amp;lt;% team = bid_info[:team] %&amp;gt;&lt;br /&gt;
            &amp;lt;% assigned_team = @assigned_teams_by_topic[topic.id].include?(team) %&amp;gt;&lt;br /&gt;
            &amp;lt;span class=&amp;quot;&amp;lt;%= assigned_team ? 'assigned-team' : '' %&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;%= team.name %&amp;gt; (#&amp;lt;%= bid_info[:priority] %&amp;gt;)&lt;br /&gt;
            &amp;lt;/span&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count1[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count1[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count2[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count2[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count3[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count3[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
      &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;% end %&amp;gt;&lt;br /&gt;
  &amp;lt;/tbody&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;javascript:history.back()&amp;quot;&amp;gt;Back&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
1. Test for Populating Bids and Assigned Teams:&lt;br /&gt;
*This test ensures that the bidding_table_for_each_topic method correctly populates bids and assigned teams for each topic.&lt;br /&gt;
*It checks if @bids_by_topic is populated correctly, verifying the length of bids for specific topics.&lt;br /&gt;
*It tests @assigned_teams_by_topic, ensuring it handles cases where topics have no teams.&lt;br /&gt;
&lt;br /&gt;
2. Test for Fetching All Topics:&lt;br /&gt;
*This test verifies that all topics for the assignment are fetched and stored in @topics.&lt;br /&gt;
&lt;br /&gt;
3. Test for Calculating Priority Counts:&lt;br /&gt;
*This test checks the calculation of priority counts for each topic.&lt;br /&gt;
*It compares the calculated priority counts against an expected set of values.&lt;br /&gt;
&lt;br /&gt;
4. Test for Calculating Percentages for Teams Getting Their Choices:&lt;br /&gt;
*This test ensures that the method correctly calculates the percentages of teams getting their preferred choices.&lt;br /&gt;
*It handles special cases where the expected percentages are not a number (NaN).&lt;br /&gt;
&lt;br /&gt;
Rspec Testing &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_each_topic.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe '#bidding_table_for_each_topic' do&lt;br /&gt;
    before :each do&lt;br /&gt;
      # Set the assignment id in the params&lt;br /&gt;
      params = ActionController::Parameters.new(id: assignment.id)&lt;br /&gt;
      allow(controller).to receive(:params).and_return(params)&lt;br /&gt;
    end&lt;br /&gt;
    it 'populates bids and assigned teams for each topic, handling topics with no teams' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
      # Check if @bids_by_topic is populated correctly&lt;br /&gt;
      expect(controller.instance_variable_get(:@bids_by_topic)[topic1.id].length).to eq(1)&lt;br /&gt;
      expect(controller.instance_variable_get(:@bids_by_topic)[topic2.id].length).to eq(1)&lt;br /&gt;
      # Check if @assigned_teams_by_topic is populated correctly, allowing for no teams&lt;br /&gt;
      assigned_teams_topic1 = controller.instance_variable_get(:@assigned_teams_by_topic)[topic1.id]&lt;br /&gt;
      if assigned_teams_topic1&lt;br /&gt;
        expect(assigned_teams_topic1.length).to(satisfy { |value| (value == 0) || (value == 1) })&lt;br /&gt;
      else&lt;br /&gt;
        expect(assigned_teams_topic1).to be_nil&lt;br /&gt;
      end&lt;br /&gt;
      # Check the counts of bids for each priority level&lt;br /&gt;
      # Ensure to adjust these based on what is set up in your test data&lt;br /&gt;
      expect(controller.instance_variable_get(:@count1)[topic1.id]).to eq(1)&lt;br /&gt;
      # assuming there is one bid with priority 1 for topic1&lt;br /&gt;
      expect(controller.instance_variable_get(:@count2)[topic1.id]).to eq(0)&lt;br /&gt;
      # assuming there are no bids with priority 2 for topic1&lt;br /&gt;
      expect(controller.instance_variable_get(:@count3)[topic1.id]).to eq(0)&lt;br /&gt;
      # assuming there are no bids with priority 3 for topic1&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'fetches all topics for the assignment' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
      expect(controller.instance_variable_get(:@topics)).to match_array([topic1, topic2, topic3, topic4])&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'correctly calculates priority counts for each topic' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
      # Assuming you have a way to know the expected counts for each priority&lt;br /&gt;
      expected_priority_counts = { 1 =&amp;gt; 0, &lt;br /&gt;
                                   2 =&amp;gt; 0, &lt;br /&gt;
                                   3 =&amp;gt; 0 }&lt;br /&gt;
  &lt;br /&gt;
      priority_counts = controller.instance_variable_get(:@priority_counts)&lt;br /&gt;
      expect(priority_counts).to eq(expected_priority_counts)&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'correctly calculates percentages for teams getting their choices' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
      # Assuming you have a way to know the expected percentages&lt;br /&gt;
      expected_percentages = { 1 =&amp;gt; Float::NAN, &lt;br /&gt;
                               2 =&amp;gt; Float::NAN, &lt;br /&gt;
                               3 =&amp;gt; Float::NAN }&lt;br /&gt;
  &lt;br /&gt;
      percentages = controller.instance_variable_get(:@percentages)&lt;br /&gt;
      expect(percentages[1].nan?).to be true if expected_percentages[1].nan?&lt;br /&gt;
      expect(percentages[2].nan?).to be true if expected_percentages[2].nan?&lt;br /&gt;
      expect(percentages[3].nan?).to be true if expected_percentages[3].nan?&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
&lt;br /&gt;
'''Github Repository: ''' https://github.com/Shreshth-Malik/expertiza&lt;br /&gt;
&lt;br /&gt;
'''Demo Video:''' https://www.youtube.com/watch?v=pGmHyqLj7PM&lt;br /&gt;
&lt;br /&gt;
== Testing Credentials ==&lt;br /&gt;
&lt;br /&gt;
username: instructor6&lt;br /&gt;
&lt;br /&gt;
password: password&lt;br /&gt;
&lt;br /&gt;
== Team == &lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Edward F. Gehringer (efg@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
'''Members'''&lt;br /&gt;
&lt;br /&gt;
Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shreshth Malik (smalik4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shuai Chen (schen76@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152812</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding (Phase2)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152812"/>
		<updated>2023-12-06T04:34:18Z</updated>

		<summary type="html">&lt;p&gt;Schen76: /* Relevant Links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Motivation ==&lt;br /&gt;
&lt;br /&gt;
The bidding view is needed because we don’t have a way of finding out whether the bidding algorithm is running correctly.  This project is to add a bidding view to show how the topics are assigned to those teams who bid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Work Plan ==&lt;br /&gt;
&lt;br /&gt;
Based on the project's objectives and feedback received from our mentor, we have identified specific areas for improvement:&lt;br /&gt;
&lt;br /&gt;
1) Refactor variable names within methods such as &amp;quot;bidding_details&amp;quot; and variables like &amp;quot;Topic name&amp;quot; and &amp;quot;Bidding teams&amp;quot; to enhance clarity and specificity.&lt;br /&gt;
&lt;br /&gt;
2) Adjust capitalization for certain components, ensuring that only the first word is capitalized for consistency.&lt;br /&gt;
&lt;br /&gt;
3) Introduce calculations to determine percentages based on additional data, such as the total number of teams and the number of teams for each priority, within the &amp;quot;lottery_controller.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4) Conduct thorough testing of the modified controller and view to ensure optimal functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Newfeature.jpg | 888px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To add functionality for showing the percentages of the number of teams that got their #1, #2, and #3 choices. We can follow these high-level steps:&lt;br /&gt;
&lt;br /&gt;
'''Lottery_Controller:'''&lt;br /&gt;
&lt;br /&gt;
i) Calculate the Total Number of Teams: Before we can calculate percentages, we need to know the total number of teams that participated in the bidding process. This will be our denominator in the percentage calculation.&lt;br /&gt;
&lt;br /&gt;
ii) Calculate the Number of Teams for Each Priority: From our `bidding_details` method, we already have counts for how many teams bid on each topic as their #1, #2, and #3 choice (`@count1`, `@count2`, `@count3`). However, these counts are currently organized by topic. We would need to modify this to count how many teams got their #1, #2, and #3 choices as their assigned topic.&lt;br /&gt;
&lt;br /&gt;
iii) Calculate Percentages: Once we have the number of teams that got their #1, #2, and #3 choices, we can calculate the percentages by dividing these numbers by the total number of teams and multiplying by 100.&lt;br /&gt;
&lt;br /&gt;
'''Bidding_detail view:'''&lt;br /&gt;
&lt;br /&gt;
i) Update the View and Display Percentages: Above the table in our previous view, we can add a section to display these percentages.&lt;br /&gt;
&lt;br /&gt;
ii) Format the Display: We will use a bold heading for each percentage type and format the number to a fixed number of decimal places.&lt;br /&gt;
&lt;br /&gt;
iii) Ensure Responsiveness: Make sure the display of these percentages adjusts well to different screen sizes, maintaining readability and layout consistency. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code Effort ==&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; app/controllers/lottery_controller.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 1: bidding_table_for_each_topic'''&lt;br /&gt;
&lt;br /&gt;
This method generates a bidding table for each topic within an assignment. It performs several operations to gather and organize data related to topics, bids, and teams. Here's a breakdown of what the code does:&lt;br /&gt;
&lt;br /&gt;
1. Fetch Assignment:&lt;br /&gt;
&lt;br /&gt;
*It retrieves the assignment with the specified params[:id] from the database and stores it in the @assignment instance variable.&lt;br /&gt;
&lt;br /&gt;
2. Fetch Topics:&lt;br /&gt;
&lt;br /&gt;
*It retrieves all sign-up topics associated with the assignment and stores them in the @topics instance variable.&lt;br /&gt;
&lt;br /&gt;
3. Fetch Bids and Assigned Teams:&lt;br /&gt;
&lt;br /&gt;
For each topic in @topics, it:&lt;br /&gt;
*Retrieves all bids associated with that topic and stores them in a hash, where the key is the topic's ID and the value is an array of bids with their associated teams and priorities.&lt;br /&gt;
*Retrieves teams that are not waitlisted for the topic and stores them in a hash, again using the topic's ID as the key and an array of teams as the value.&lt;br /&gt;
&lt;br /&gt;
4. Priority Count Calculation:&lt;br /&gt;
&lt;br /&gt;
*It dynamically calculates and updates the counts for each bid priority level (1, 2, and 3) for each topic. These counts are stored in instance variables named @count1, @count2, and @count3. These instance variables are hashes where the keys are topic IDs, and the values are counts for each priority level.&lt;br /&gt;
&lt;br /&gt;
5. Calculate Total Teams:&lt;br /&gt;
&lt;br /&gt;
*It determines the total number of teams across all topics in the assignment by counting distinct team IDs among all non-waitlisted teams for the specified topics.&lt;br /&gt;
&lt;br /&gt;
6. Calculate Priority Counts and Percentages:&lt;br /&gt;
&lt;br /&gt;
*It calls two helper methods, calculate_priority_counts and calculate_percentages, to calculate the total counts of teams at each priority level and the corresponding percentages. The results are stored in the @priority_counts and @percentages instance variables, respectively.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Prepares data for displaying the bidding details for each topic within an assignment.&lt;br /&gt;
  # It calculates the number of bids for each priority (1, 2, 3) per topic and also computes&lt;br /&gt;
  # the overall percentages of teams that received their first, second, and third choice.&lt;br /&gt;
  def bidding_table_for_each_topic&lt;br /&gt;
    @assignment = Assignment.find(params[:id])&lt;br /&gt;
    # Fetch all topics for the assignment&lt;br /&gt;
    @topics = @assignment.sign_up_topics&lt;br /&gt;
    # Fetch all bids for these topics&lt;br /&gt;
    @bids_by_topic = {}&lt;br /&gt;
    @assigned_teams_by_topic = {} # This will store the assigned teams for each topic&lt;br /&gt;
    @topics.each do |topic|&lt;br /&gt;
      # Assuming bids are stored with a topic_id, and each bid has a team associated with it&lt;br /&gt;
      @bids_by_topic[topic.id] = Bid.where(topic_id: topic.id).map { |bid| { team: bid.team, priority: bid.priority } }&lt;br /&gt;
      # Fetch teams that are not waitlisted for this topic&lt;br /&gt;
      @assigned_teams_by_topic[topic.id] = SignedUpTeam.where(topic_id: topic.id, is_waitlisted: false).map(&amp;amp;:team)&lt;br /&gt;
      # @count1[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 1 }&lt;br /&gt;
      # @count2[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 2 }&lt;br /&gt;
      # @count3[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 3 }       &lt;br /&gt;
&lt;br /&gt;
      # Dynamically initializing and updating @count1, @count2, and @count3&lt;br /&gt;
      (1..3).each do |priority|&lt;br /&gt;
        instance_variable_set(&amp;quot;@count#{priority}&amp;quot;, Hash.new(0)) unless instance_variable_defined?(&amp;quot;@count#{priority}&amp;quot;)&lt;br /&gt;
        instance_variable_get(&amp;quot;@count#{priority}&amp;quot;)[topic.id] = @bids_by_topic[topic.id].count { |bid| bid[:priority] == priority }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # Calculate the total number of teams and percentages after fetching bid details&lt;br /&gt;
    topic_ids = SignUpTopic.where(assignment_id: @assignment.id).pluck(:id)&lt;br /&gt;
    @total_teams = SignedUpTeam.where(topic_id: topic_ids).distinct.count(:team_id)&lt;br /&gt;
    @priority_counts = calculate_priority_counts(@assigned_teams_by_topic, @bids_by_topic)&lt;br /&gt;
    @percentages = calculate_percentages(@priority_counts, @total_teams)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 2: calculate_priority_counts'''&lt;br /&gt;
&lt;br /&gt;
1. Parameters&lt;br /&gt;
*assigned_teams_by_topic (Hash): A hash mapping each topic to an array of assigned teams.&lt;br /&gt;
*bids_by_topic (Hash): A hash mapping each topic to an array of bid objects, where each bid object is a hash containing team and priority information.&lt;br /&gt;
&lt;br /&gt;
2. Functionality&lt;br /&gt;
*Initial Setup: Initializes a hash priority_counts with keys 1, 2, and 3, each having an initial value of 0. These keys represent the priority levels, and their values count the number of teams assigned to each level.&lt;br /&gt;
&lt;br /&gt;
*Iterating Over Topics and Teams: Iterates over each topic and its associated teams found in assigned_teams_by_topic. For each team in a topic, the method searches bids_by_topic[topic_id] to find a bid made by the team.&lt;br /&gt;
&lt;br /&gt;
*Updating Priority Counts: If a bid is found, the method increments the count in priority_counts corresponding to the priority level in the bid. This process effectively tallies the number of teams assigned to each priority level.&lt;br /&gt;
&lt;br /&gt;
3. Returns&lt;br /&gt;
*priority_counts (Hash): A hash with keys 1, 2, and 3, where each key's value represents the count of teams assigned to that respective priority level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Calculates the count of assigned teams for each priority level (1, 2, 3) across all topics.&lt;br /&gt;
  # It checks each team associated with a topic and determines if the team's bid matches&lt;br /&gt;
  # one of the priority levels, incrementing the respective count if so.&lt;br /&gt;
  def calculate_priority_counts(assigned_teams_by_topic, bids_by_topic)&lt;br /&gt;
    priority_counts = { 1 =&amp;gt; 0, 2 =&amp;gt; 0, 3 =&amp;gt; 0 }&lt;br /&gt;
    assigned_teams_by_topic.each do |topic_id, teams|&lt;br /&gt;
      teams.each do |team|&lt;br /&gt;
        bid_info = bids_by_topic[topic_id].find { |bid| bid[:team] == team }&lt;br /&gt;
        priority_counts[bid_info[:priority]] += 1 if bid_info&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    priority_counts&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 3: calculate_percentages'''&lt;br /&gt;
&lt;br /&gt;
* This method calculates the percentages of teams that received their first, second, and third choice based on the counts of teams at each priority level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Calculates the percentages of teams that received their first, second, and third choice&lt;br /&gt;
  # based on the counts of teams at each priority level.&lt;br /&gt;
  def calculate_percentages(priority_counts, total_teams)&lt;br /&gt;
    priority_counts.transform_values { |count| (count.to_f / total_teams * 100).round(2) }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_each_topic.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:bidding_percentage.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt;Bidding Details for &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;!-- Displaying percentages in a more visually appealing way --&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;percentages&amp;quot; style=&amp;quot;margin-bottom: 20px; padding: 15px; border: 1px solid&lt;br /&gt;
#ccc; border-radius: 5px; background-color: #f9f9f9;&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;h4 style=&amp;quot;margin-bottom: 15px; border-bottom: 1px solid #eee;&lt;br /&gt;
padding-bottom: 10px;&amp;quot;&amp;gt;Percentage of Teams Getting Their Choices:&amp;lt;/h4&amp;gt;&lt;br /&gt;
  &amp;lt;ul style=&amp;quot;list-style: none; padding: 0;&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;#1 Choice:&amp;lt;/strong&amp;gt; &amp;lt;span style=&amp;quot;color: #4CAF50;&amp;quot;&amp;gt;&amp;lt;%= @percentages[1] || 0 %&amp;gt; %&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;#2 Choice:&amp;lt;/strong&amp;gt; &amp;lt;span style=&amp;quot;color: #FF9800;&amp;quot;&amp;gt;&amp;lt;%= @percentages[2] || 0 %&amp;gt; %&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;#3 Choice:&amp;lt;/strong&amp;gt; &amp;lt;span style=&amp;quot;color: #F44336;&amp;quot;&amp;gt;&amp;lt;%= @percentages[3] || 0 %&amp;gt; %&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;style&amp;gt;&lt;br /&gt;
.assigned-team {&lt;br /&gt;
  background-color: yellow; &lt;br /&gt;
  color: black;             &lt;br /&gt;
}&lt;br /&gt;
.bids-column {&lt;br /&gt;
    width: 100px; /* Adjust width as needed */&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/style&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table class=&amp;quot;table table-bordered table-hover&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;thead&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic Name&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic ID&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Bidding Teams&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#1 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#2 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#3 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;/thead&amp;gt;&lt;br /&gt;
  &amp;lt;tbody&amp;gt;&lt;br /&gt;
    &amp;lt;% @topics.each do |topic| %&amp;gt;&lt;br /&gt;
      &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.topic_name %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.id %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&lt;br /&gt;
          &amp;lt;% @bids_by_topic[topic.id].each do |bid_info| %&amp;gt;&lt;br /&gt;
            &amp;lt;% team = bid_info[:team] %&amp;gt;&lt;br /&gt;
            &amp;lt;% assigned_team = @assigned_teams_by_topic[topic.id].include?(team) %&amp;gt;&lt;br /&gt;
            &amp;lt;span class=&amp;quot;&amp;lt;%= assigned_team ? 'assigned-team' : '' %&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;%= team.name %&amp;gt; (#&amp;lt;%= bid_info[:priority] %&amp;gt;)&lt;br /&gt;
            &amp;lt;/span&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count1[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count1[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count2[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count2[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count3[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count3[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
      &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;% end %&amp;gt;&lt;br /&gt;
  &amp;lt;/tbody&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;javascript:history.back()&amp;quot;&amp;gt;Back&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
1. Test for Populating Bids and Assigned Teams:&lt;br /&gt;
*This test ensures that the bidding_table_for_each_topic method correctly populates bids and assigned teams for each topic.&lt;br /&gt;
*It checks if @bids_by_topic is populated correctly, verifying the length of bids for specific topics.&lt;br /&gt;
*It tests @assigned_teams_by_topic, ensuring it handles cases where topics have no teams.&lt;br /&gt;
&lt;br /&gt;
2. Test for Fetching All Topics:&lt;br /&gt;
*This test verifies that all topics for the assignment are fetched and stored in @topics.&lt;br /&gt;
&lt;br /&gt;
3. Test for Calculating Priority Counts:&lt;br /&gt;
*This test checks the calculation of priority counts for each topic.&lt;br /&gt;
*It compares the calculated priority counts against an expected set of values.&lt;br /&gt;
&lt;br /&gt;
4. Test for Calculating Percentages for Teams Getting Their Choices:&lt;br /&gt;
*This test ensures that the method correctly calculates the percentages of teams getting their preferred choices.&lt;br /&gt;
*It handles special cases where the expected percentages are not a number (NaN).&lt;br /&gt;
&lt;br /&gt;
Rspec Testing &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_each_topic.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe '#bidding_table_for_each_topic' do&lt;br /&gt;
    before :each do&lt;br /&gt;
      # Set the assignment id in the params&lt;br /&gt;
      params = ActionController::Parameters.new(id: assignment.id)&lt;br /&gt;
      allow(controller).to receive(:params).and_return(params)&lt;br /&gt;
    end&lt;br /&gt;
    it 'populates bids and assigned teams for each topic, handling topics with no teams' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
      # Check if @bids_by_topic is populated correctly&lt;br /&gt;
      expect(controller.instance_variable_get(:@bids_by_topic)[topic1.id].length).to eq(1)&lt;br /&gt;
      expect(controller.instance_variable_get(:@bids_by_topic)[topic2.id].length).to eq(1)&lt;br /&gt;
      # Check if @assigned_teams_by_topic is populated correctly, allowing for no teams&lt;br /&gt;
      assigned_teams_topic1 = controller.instance_variable_get(:@assigned_teams_by_topic)[topic1.id]&lt;br /&gt;
      if assigned_teams_topic1&lt;br /&gt;
        expect(assigned_teams_topic1.length).to(satisfy { |value| (value == 0) || (value == 1) })&lt;br /&gt;
      else&lt;br /&gt;
        expect(assigned_teams_topic1).to be_nil&lt;br /&gt;
      end&lt;br /&gt;
      # Check the counts of bids for each priority level&lt;br /&gt;
      # Ensure to adjust these based on what is set up in your test data&lt;br /&gt;
      expect(controller.instance_variable_get(:@count1)[topic1.id]).to eq(1)&lt;br /&gt;
      # assuming there is one bid with priority 1 for topic1&lt;br /&gt;
      expect(controller.instance_variable_get(:@count2)[topic1.id]).to eq(0)&lt;br /&gt;
      # assuming there are no bids with priority 2 for topic1&lt;br /&gt;
      expect(controller.instance_variable_get(:@count3)[topic1.id]).to eq(0)&lt;br /&gt;
      # assuming there are no bids with priority 3 for topic1&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'fetches all topics for the assignment' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
      expect(controller.instance_variable_get(:@topics)).to match_array([topic1, topic2, topic3, topic4])&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'correctly calculates priority counts for each topic' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
      # Assuming you have a way to know the expected counts for each priority&lt;br /&gt;
      expected_priority_counts = { 1 =&amp;gt; 0, &lt;br /&gt;
                                   2 =&amp;gt; 0, &lt;br /&gt;
                                   3 =&amp;gt; 0 }&lt;br /&gt;
  &lt;br /&gt;
      priority_counts = controller.instance_variable_get(:@priority_counts)&lt;br /&gt;
      expect(priority_counts).to eq(expected_priority_counts)&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'correctly calculates percentages for teams getting their choices' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
      # Assuming you have a way to know the expected percentages&lt;br /&gt;
      expected_percentages = { 1 =&amp;gt; Float::NAN, &lt;br /&gt;
                               2 =&amp;gt; Float::NAN, &lt;br /&gt;
                               3 =&amp;gt; Float::NAN }&lt;br /&gt;
  &lt;br /&gt;
      percentages = controller.instance_variable_get(:@percentages)&lt;br /&gt;
      expect(percentages[1].nan?).to be true if expected_percentages[1].nan?&lt;br /&gt;
      expect(percentages[2].nan?).to be true if expected_percentages[2].nan?&lt;br /&gt;
      expect(percentages[3].nan?).to be true if expected_percentages[3].nan?&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
&lt;br /&gt;
'''Github Repository: ''' https://github.com/Shreshth-Malik/expertiza&lt;br /&gt;
&lt;br /&gt;
'''Demo Video:''' https://www.youtube.com/watch?v=pGmHyqLj7PM&lt;br /&gt;
&lt;br /&gt;
== Testing Credentials ==&lt;br /&gt;
&lt;br /&gt;
username: instructor6&lt;br /&gt;
&lt;br /&gt;
password: password&lt;br /&gt;
&lt;br /&gt;
== Team == &lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Edward F. Gehringer (efg@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
'''Members'''&lt;br /&gt;
&lt;br /&gt;
Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shreshth Malik (smalik4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shuai Chen (schen76@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152759</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding (Phase2)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152759"/>
		<updated>2023-12-05T07:54:20Z</updated>

		<summary type="html">&lt;p&gt;Schen76: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Motivation ==&lt;br /&gt;
&lt;br /&gt;
The bidding view is needed because we don’t have a way of finding out whether the bidding algorithm is running correctly.  This project is to add a bidding view to show how the topics are assigned to those teams who bid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Work Plan ==&lt;br /&gt;
&lt;br /&gt;
Based on the project's objectives and feedback received from our mentor, we have identified specific areas for improvement:&lt;br /&gt;
&lt;br /&gt;
1) Refactor variable names within methods such as &amp;quot;bidding_details&amp;quot; and variables like &amp;quot;Topic name&amp;quot; and &amp;quot;Bidding teams&amp;quot; to enhance clarity and specificity.&lt;br /&gt;
&lt;br /&gt;
2) Adjust capitalization for certain components, ensuring that only the first word is capitalized for consistency.&lt;br /&gt;
&lt;br /&gt;
3) Introduce calculations to determine percentages based on additional data, such as the total number of teams and the number of teams for each priority, within the &amp;quot;lottery_controller.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4) Conduct thorough testing of the modified controller and view to ensure optimal functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Newfeature.jpg | 888px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To add functionality for showing the percentages of the number of teams that got their #1, #2, and #3 choices. We can follow these high-level steps:&lt;br /&gt;
&lt;br /&gt;
'''Lottery_Controller:'''&lt;br /&gt;
&lt;br /&gt;
i) Calculate the Total Number of Teams: Before we can calculate percentages, we need to know the total number of teams that participated in the bidding process. This will be our denominator in the percentage calculation.&lt;br /&gt;
&lt;br /&gt;
ii) Calculate the Number of Teams for Each Priority: From our `bidding_details` method, we already have counts for how many teams bid on each topic as their #1, #2, and #3 choice (`@count1`, `@count2`, `@count3`). However, these counts are currently organized by topic. We would need to modify this to count how many teams got their #1, #2, and #3 choices as their assigned topic.&lt;br /&gt;
&lt;br /&gt;
iii) Calculate Percentages: Once we have the number of teams that got their #1, #2, and #3 choices, we can calculate the percentages by dividing these numbers by the total number of teams and multiplying by 100.&lt;br /&gt;
&lt;br /&gt;
'''Bidding_detail view:'''&lt;br /&gt;
&lt;br /&gt;
i) Update the View and Display Percentages: Above the table in our previous view, we can add a section to display these percentages.&lt;br /&gt;
&lt;br /&gt;
ii) Format the Display: We will use a bold heading for each percentage type and format the number to a fixed number of decimal places.&lt;br /&gt;
&lt;br /&gt;
iii) Ensure Responsiveness: Make sure the display of these percentages adjusts well to different screen sizes, maintaining readability and layout consistency. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code Effort ==&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; app/controllers/lottery_controller.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 1: bidding_table_for_each_topic'''&lt;br /&gt;
&lt;br /&gt;
This method generates a bidding table for each topic within an assignment. It performs several operations to gather and organize data related to topics, bids, and teams. Here's a breakdown of what the code does:&lt;br /&gt;
&lt;br /&gt;
1. Fetch Assignment:&lt;br /&gt;
&lt;br /&gt;
*It retrieves the assignment with the specified params[:id] from the database and stores it in the @assignment instance variable.&lt;br /&gt;
&lt;br /&gt;
2. Fetch Topics:&lt;br /&gt;
&lt;br /&gt;
*It retrieves all sign-up topics associated with the assignment and stores them in the @topics instance variable.&lt;br /&gt;
&lt;br /&gt;
3. Fetch Bids and Assigned Teams:&lt;br /&gt;
&lt;br /&gt;
For each topic in @topics, it:&lt;br /&gt;
*Retrieves all bids associated with that topic and stores them in a hash, where the key is the topic's ID and the value is an array of bids with their associated teams and priorities.&lt;br /&gt;
*Retrieves teams that are not waitlisted for the topic and stores them in a hash, again using the topic's ID as the key and an array of teams as the value.&lt;br /&gt;
&lt;br /&gt;
4. Priority Count Calculation:&lt;br /&gt;
&lt;br /&gt;
*It dynamically calculates and updates the counts for each bid priority level (1, 2, and 3) for each topic. These counts are stored in instance variables named @count1, @count2, and @count3. These instance variables are hashes where the keys are topic IDs, and the values are counts for each priority level.&lt;br /&gt;
&lt;br /&gt;
5. Calculate Total Teams:&lt;br /&gt;
&lt;br /&gt;
*It determines the total number of teams across all topics in the assignment by counting distinct team IDs among all non-waitlisted teams for the specified topics.&lt;br /&gt;
&lt;br /&gt;
6. Calculate Priority Counts and Percentages:&lt;br /&gt;
&lt;br /&gt;
*It calls two helper methods, calculate_priority_counts and calculate_percentages, to calculate the total counts of teams at each priority level and the corresponding percentages. The results are stored in the @priority_counts and @percentages instance variables, respectively.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Prepares data for displaying the bidding details for each topic within an assignment.&lt;br /&gt;
  # It calculates the number of bids for each priority (1, 2, 3) per topic and also computes&lt;br /&gt;
  # the overall percentages of teams that received their first, second, and third choice.&lt;br /&gt;
  def bidding_table_for_each_topic&lt;br /&gt;
    @assignment = Assignment.find(params[:id])&lt;br /&gt;
    # Fetch all topics for the assignment&lt;br /&gt;
    @topics = @assignment.sign_up_topics&lt;br /&gt;
    # Fetch all bids for these topics&lt;br /&gt;
    @bids_by_topic = {}&lt;br /&gt;
    @assigned_teams_by_topic = {} # This will store the assigned teams for each topic&lt;br /&gt;
    @topics.each do |topic|&lt;br /&gt;
      # Assuming bids are stored with a topic_id, and each bid has a team associated with it&lt;br /&gt;
      @bids_by_topic[topic.id] = Bid.where(topic_id: topic.id).map { |bid| { team: bid.team, priority: bid.priority } }&lt;br /&gt;
      # Fetch teams that are not waitlisted for this topic&lt;br /&gt;
      @assigned_teams_by_topic[topic.id] = SignedUpTeam.where(topic_id: topic.id, is_waitlisted: false).map(&amp;amp;:team)&lt;br /&gt;
      # @count1[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 1 }&lt;br /&gt;
      # @count2[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 2 }&lt;br /&gt;
      # @count3[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 3 }       &lt;br /&gt;
&lt;br /&gt;
      # Dynamically initializing and updating @count1, @count2, and @count3&lt;br /&gt;
      (1..3).each do |priority|&lt;br /&gt;
        instance_variable_set(&amp;quot;@count#{priority}&amp;quot;, Hash.new(0)) unless instance_variable_defined?(&amp;quot;@count#{priority}&amp;quot;)&lt;br /&gt;
        instance_variable_get(&amp;quot;@count#{priority}&amp;quot;)[topic.id] = @bids_by_topic[topic.id].count { |bid| bid[:priority] == priority }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # Calculate the total number of teams and percentages after fetching bid details&lt;br /&gt;
    topic_ids = SignUpTopic.where(assignment_id: @assignment.id).pluck(:id)&lt;br /&gt;
    @total_teams = SignedUpTeam.where(topic_id: topic_ids).distinct.count(:team_id)&lt;br /&gt;
    @priority_counts = calculate_priority_counts(@assigned_teams_by_topic, @bids_by_topic)&lt;br /&gt;
    @percentages = calculate_percentages(@priority_counts, @total_teams)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 2: calculate_priority_counts'''&lt;br /&gt;
&lt;br /&gt;
1. Parameters&lt;br /&gt;
*assigned_teams_by_topic (Hash): A hash mapping each topic to an array of assigned teams.&lt;br /&gt;
*bids_by_topic (Hash): A hash mapping each topic to an array of bid objects, where each bid object is a hash containing team and priority information.&lt;br /&gt;
&lt;br /&gt;
2. Functionality&lt;br /&gt;
*Initial Setup: Initializes a hash priority_counts with keys 1, 2, and 3, each having an initial value of 0. These keys represent the priority levels, and their values count the number of teams assigned to each level.&lt;br /&gt;
&lt;br /&gt;
*Iterating Over Topics and Teams: Iterates over each topic and its associated teams found in assigned_teams_by_topic. For each team in a topic, the method searches bids_by_topic[topic_id] to find a bid made by the team.&lt;br /&gt;
&lt;br /&gt;
*Updating Priority Counts: If a bid is found, the method increments the count in priority_counts corresponding to the priority level in the bid. This process effectively tallies the number of teams assigned to each priority level.&lt;br /&gt;
&lt;br /&gt;
3. Returns&lt;br /&gt;
*priority_counts (Hash): A hash with keys 1, 2, and 3, where each key's value represents the count of teams assigned to that respective priority level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Calculates the count of assigned teams for each priority level (1, 2, 3) across all topics.&lt;br /&gt;
  # It checks each team associated with a topic and determines if the team's bid matches&lt;br /&gt;
  # one of the priority levels, incrementing the respective count if so.&lt;br /&gt;
  def calculate_priority_counts(assigned_teams_by_topic, bids_by_topic)&lt;br /&gt;
    priority_counts = { 1 =&amp;gt; 0, 2 =&amp;gt; 0, 3 =&amp;gt; 0 }&lt;br /&gt;
    assigned_teams_by_topic.each do |topic_id, teams|&lt;br /&gt;
      teams.each do |team|&lt;br /&gt;
        bid_info = bids_by_topic[topic_id].find { |bid| bid[:team] == team }&lt;br /&gt;
        priority_counts[bid_info[:priority]] += 1 if bid_info&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    priority_counts&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 3: calculate_percentages'''&lt;br /&gt;
&lt;br /&gt;
* This method calculates the percentages of teams that received their first, second, and third choice based on the counts of teams at each priority level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Calculates the percentages of teams that received their first, second, and third choice&lt;br /&gt;
  # based on the counts of teams at each priority level.&lt;br /&gt;
  def calculate_percentages(priority_counts, total_teams)&lt;br /&gt;
    priority_counts.transform_values { |count| (count.to_f / total_teams * 100).round(2) }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_each_topic.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:bidding_percentage.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt;Bidding Details for &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;!-- Displaying percentages in a more visually appealing way --&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;percentages&amp;quot; style=&amp;quot;margin-bottom: 20px; padding: 15px; border: 1px solid&lt;br /&gt;
#ccc; border-radius: 5px; background-color: #f9f9f9;&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;h4 style=&amp;quot;margin-bottom: 15px; border-bottom: 1px solid #eee;&lt;br /&gt;
padding-bottom: 10px;&amp;quot;&amp;gt;Percentage of Teams Getting Their Choices:&amp;lt;/h4&amp;gt;&lt;br /&gt;
  &amp;lt;ul style=&amp;quot;list-style: none; padding: 0;&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;#1 Choice:&amp;lt;/strong&amp;gt; &amp;lt;span style=&amp;quot;color: #4CAF50;&amp;quot;&amp;gt;&amp;lt;%= @percentages[1] || 0 %&amp;gt; %&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;#2 Choice:&amp;lt;/strong&amp;gt; &amp;lt;span style=&amp;quot;color: #FF9800;&amp;quot;&amp;gt;&amp;lt;%= @percentages[2] || 0 %&amp;gt; %&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;#3 Choice:&amp;lt;/strong&amp;gt; &amp;lt;span style=&amp;quot;color: #F44336;&amp;quot;&amp;gt;&amp;lt;%= @percentages[3] || 0 %&amp;gt; %&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;style&amp;gt;&lt;br /&gt;
.assigned-team {&lt;br /&gt;
  background-color: yellow; &lt;br /&gt;
  color: black;             &lt;br /&gt;
}&lt;br /&gt;
.bids-column {&lt;br /&gt;
    width: 100px; /* Adjust width as needed */&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/style&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table class=&amp;quot;table table-bordered table-hover&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;thead&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic Name&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic ID&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Bidding Teams&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#1 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#2 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#3 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;/thead&amp;gt;&lt;br /&gt;
  &amp;lt;tbody&amp;gt;&lt;br /&gt;
    &amp;lt;% @topics.each do |topic| %&amp;gt;&lt;br /&gt;
      &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.topic_name %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.id %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&lt;br /&gt;
          &amp;lt;% @bids_by_topic[topic.id].each do |bid_info| %&amp;gt;&lt;br /&gt;
            &amp;lt;% team = bid_info[:team] %&amp;gt;&lt;br /&gt;
            &amp;lt;% assigned_team = @assigned_teams_by_topic[topic.id].include?(team) %&amp;gt;&lt;br /&gt;
            &amp;lt;span class=&amp;quot;&amp;lt;%= assigned_team ? 'assigned-team' : '' %&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;%= team.name %&amp;gt; (#&amp;lt;%= bid_info[:priority] %&amp;gt;)&lt;br /&gt;
            &amp;lt;/span&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count1[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count1[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count2[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count2[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count3[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count3[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
      &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;% end %&amp;gt;&lt;br /&gt;
  &amp;lt;/tbody&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;javascript:history.back()&amp;quot;&amp;gt;Back&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
1. Test for Populating Bids and Assigned Teams:&lt;br /&gt;
*This test ensures that the bidding_table_for_each_topic method correctly populates bids and assigned teams for each topic.&lt;br /&gt;
*It checks if @bids_by_topic is populated correctly, verifying the length of bids for specific topics.&lt;br /&gt;
*It tests @assigned_teams_by_topic, ensuring it handles cases where topics have no teams.&lt;br /&gt;
&lt;br /&gt;
2. Test for Fetching All Topics:&lt;br /&gt;
*This test verifies that all topics for the assignment are fetched and stored in @topics.&lt;br /&gt;
&lt;br /&gt;
3. Test for Calculating Priority Counts:&lt;br /&gt;
*This test checks the calculation of priority counts for each topic.&lt;br /&gt;
*It compares the calculated priority counts against an expected set of values.&lt;br /&gt;
&lt;br /&gt;
4. Test for Calculating Percentages for Teams Getting Their Choices:&lt;br /&gt;
*This test ensures that the method correctly calculates the percentages of teams getting their preferred choices.&lt;br /&gt;
*It handles special cases where the expected percentages are not a number (NaN).&lt;br /&gt;
&lt;br /&gt;
Rspec Testing &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_each_topic.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe '#bidding_table_for_each_topic' do&lt;br /&gt;
    before :each do&lt;br /&gt;
      # Set the assignment id in the params&lt;br /&gt;
      params = ActionController::Parameters.new(id: assignment.id)&lt;br /&gt;
      allow(controller).to receive(:params).and_return(params)&lt;br /&gt;
    end&lt;br /&gt;
    it 'populates bids and assigned teams for each topic, handling topics with no teams' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
      # Check if @bids_by_topic is populated correctly&lt;br /&gt;
      expect(controller.instance_variable_get(:@bids_by_topic)[topic1.id].length).to eq(1)&lt;br /&gt;
      expect(controller.instance_variable_get(:@bids_by_topic)[topic2.id].length).to eq(1)&lt;br /&gt;
      # Check if @assigned_teams_by_topic is populated correctly, allowing for no teams&lt;br /&gt;
      assigned_teams_topic1 = controller.instance_variable_get(:@assigned_teams_by_topic)[topic1.id]&lt;br /&gt;
      if assigned_teams_topic1&lt;br /&gt;
        expect(assigned_teams_topic1.length).to(satisfy { |value| (value == 0) || (value == 1) })&lt;br /&gt;
      else&lt;br /&gt;
        expect(assigned_teams_topic1).to be_nil&lt;br /&gt;
      end&lt;br /&gt;
      # Check the counts of bids for each priority level&lt;br /&gt;
      # Ensure to adjust these based on what is set up in your test data&lt;br /&gt;
      expect(controller.instance_variable_get(:@count1)[topic1.id]).to eq(1)&lt;br /&gt;
      # assuming there is one bid with priority 1 for topic1&lt;br /&gt;
      expect(controller.instance_variable_get(:@count2)[topic1.id]).to eq(0)&lt;br /&gt;
      # assuming there are no bids with priority 2 for topic1&lt;br /&gt;
      expect(controller.instance_variable_get(:@count3)[topic1.id]).to eq(0)&lt;br /&gt;
      # assuming there are no bids with priority 3 for topic1&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'fetches all topics for the assignment' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
      expect(controller.instance_variable_get(:@topics)).to match_array([topic1, topic2, topic3, topic4])&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'correctly calculates priority counts for each topic' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
      # Assuming you have a way to know the expected counts for each priority&lt;br /&gt;
      expected_priority_counts = { 1 =&amp;gt; 0, &lt;br /&gt;
                                   2 =&amp;gt; 0, &lt;br /&gt;
                                   3 =&amp;gt; 0 }&lt;br /&gt;
  &lt;br /&gt;
      priority_counts = controller.instance_variable_get(:@priority_counts)&lt;br /&gt;
      expect(priority_counts).to eq(expected_priority_counts)&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'correctly calculates percentages for teams getting their choices' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
      # Assuming you have a way to know the expected percentages&lt;br /&gt;
      expected_percentages = { 1 =&amp;gt; Float::NAN, &lt;br /&gt;
                               2 =&amp;gt; Float::NAN, &lt;br /&gt;
                               3 =&amp;gt; Float::NAN }&lt;br /&gt;
  &lt;br /&gt;
      percentages = controller.instance_variable_get(:@percentages)&lt;br /&gt;
      expect(percentages[1].nan?).to be true if expected_percentages[1].nan?&lt;br /&gt;
      expect(percentages[2].nan?).to be true if expected_percentages[2].nan?&lt;br /&gt;
      expect(percentages[3].nan?).to be true if expected_percentages[3].nan?&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
&lt;br /&gt;
'''Github Repository: ''' https://github.com/Shreshth-Malik/expertiza&lt;br /&gt;
&lt;br /&gt;
== Testing Credentials ==&lt;br /&gt;
&lt;br /&gt;
username: instructor6&lt;br /&gt;
&lt;br /&gt;
password: password&lt;br /&gt;
&lt;br /&gt;
== Team == &lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Edward F. Gehringer (efg@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
'''Members'''&lt;br /&gt;
&lt;br /&gt;
Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shreshth Malik (smalik4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shuai Chen (schen76@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152758</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding (Phase2)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152758"/>
		<updated>2023-12-05T07:53:48Z</updated>

		<summary type="html">&lt;p&gt;Schen76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Motivation ==&lt;br /&gt;
&lt;br /&gt;
The bidding view is needed because we don’t have a way of finding out whether the bidding algorithm is running correctly.  This project is to add a bidding view to show how the topics are assigned to those teams who bid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Work Plan ==&lt;br /&gt;
&lt;br /&gt;
Based on the project's objectives and feedback received from our mentor, we have identified specific areas for improvement:&lt;br /&gt;
&lt;br /&gt;
1) Refactor variable names within methods such as &amp;quot;bidding_details&amp;quot; and variables like &amp;quot;Topic name&amp;quot; and &amp;quot;Bidding teams&amp;quot; to enhance clarity and specificity.&lt;br /&gt;
&lt;br /&gt;
2) Adjust capitalization for certain components, ensuring that only the first word is capitalized for consistency.&lt;br /&gt;
&lt;br /&gt;
3) Introduce calculations to determine percentages based on additional data, such as the total number of teams and the number of teams for each priority, within the &amp;quot;lottery_controller.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4) Conduct thorough testing of the modified controller and view to ensure optimal functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Newfeature.jpg | 888px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To add functionality for showing the percentages of the number of teams that got their #1, #2, and #3 choices. We can follow these high-level steps:&lt;br /&gt;
&lt;br /&gt;
'''Lottery_Controller:'''&lt;br /&gt;
&lt;br /&gt;
i) Calculate the Total Number of Teams: Before we can calculate percentages, we need to know the total number of teams that participated in the bidding process. This will be our denominator in the percentage calculation.&lt;br /&gt;
&lt;br /&gt;
ii) Calculate the Number of Teams for Each Priority: From our `bidding_details` method, we already have counts for how many teams bid on each topic as their #1, #2, and #3 choice (`@count1`, `@count2`, `@count3`). However, these counts are currently organized by topic. We would need to modify this to count how many teams got their #1, #2, and #3 choices as their assigned topic.&lt;br /&gt;
&lt;br /&gt;
iii) Calculate Percentages: Once we have the number of teams that got their #1, #2, and #3 choices, we can calculate the percentages by dividing these numbers by the total number of teams and multiplying by 100.&lt;br /&gt;
&lt;br /&gt;
'''Bidding_detail view:'''&lt;br /&gt;
&lt;br /&gt;
i) Update the View and Display Percentages: Above the table in our previous view, we can add a section to display these percentages.&lt;br /&gt;
&lt;br /&gt;
ii) Format the Display: We will use a bold heading for each percentage type and format the number to a fixed number of decimal places.&lt;br /&gt;
&lt;br /&gt;
iii) Ensure Responsiveness: Make sure the display of these percentages adjusts well to different screen sizes, maintaining readability and layout consistency. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code Effort ==&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; app/controllers/lottery_controller.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 1: bidding_table_for_each_topic'''&lt;br /&gt;
&lt;br /&gt;
This method generates a bidding table for each topic within an assignment. It performs several operations to gather and organize data related to topics, bids, and teams. Here's a breakdown of what the code does:&lt;br /&gt;
&lt;br /&gt;
1. Fetch Assignment:&lt;br /&gt;
&lt;br /&gt;
*It retrieves the assignment with the specified params[:id] from the database and stores it in the @assignment instance variable.&lt;br /&gt;
&lt;br /&gt;
2. Fetch Topics:&lt;br /&gt;
&lt;br /&gt;
*It retrieves all sign-up topics associated with the assignment and stores them in the @topics instance variable.&lt;br /&gt;
&lt;br /&gt;
3. Fetch Bids and Assigned Teams:&lt;br /&gt;
&lt;br /&gt;
For each topic in @topics, it:&lt;br /&gt;
*Retrieves all bids associated with that topic and stores them in a hash, where the key is the topic's ID and the value is an array of bids with their associated teams and priorities.&lt;br /&gt;
*Retrieves teams that are not waitlisted for the topic and stores them in a hash, again using the topic's ID as the key and an array of teams as the value.&lt;br /&gt;
&lt;br /&gt;
4. Priority Count Calculation:&lt;br /&gt;
&lt;br /&gt;
*It dynamically calculates and updates the counts for each bid priority level (1, 2, and 3) for each topic. These counts are stored in instance variables named @count1, @count2, and @count3. These instance variables are hashes where the keys are topic IDs, and the values are counts for each priority level.&lt;br /&gt;
&lt;br /&gt;
5. Calculate Total Teams:&lt;br /&gt;
&lt;br /&gt;
*It determines the total number of teams across all topics in the assignment by counting distinct team IDs among all non-waitlisted teams for the specified topics.&lt;br /&gt;
&lt;br /&gt;
6. Calculate Priority Counts and Percentages:&lt;br /&gt;
&lt;br /&gt;
*It calls two helper methods, calculate_priority_counts and calculate_percentages, to calculate the total counts of teams at each priority level and the corresponding percentages. The results are stored in the @priority_counts and @percentages instance variables, respectively.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Prepares data for displaying the bidding details for each topic within an assignment.&lt;br /&gt;
  # It calculates the number of bids for each priority (1, 2, 3) per topic and also computes&lt;br /&gt;
  # the overall percentages of teams that received their first, second, and third choice.&lt;br /&gt;
  def bidding_table_for_each_topic&lt;br /&gt;
    @assignment = Assignment.find(params[:id])&lt;br /&gt;
    # Fetch all topics for the assignment&lt;br /&gt;
    @topics = @assignment.sign_up_topics&lt;br /&gt;
    # Fetch all bids for these topics&lt;br /&gt;
    @bids_by_topic = {}&lt;br /&gt;
    @assigned_teams_by_topic = {} # This will store the assigned teams for each topic&lt;br /&gt;
    @topics.each do |topic|&lt;br /&gt;
      # Assuming bids are stored with a topic_id, and each bid has a team associated with it&lt;br /&gt;
      @bids_by_topic[topic.id] = Bid.where(topic_id: topic.id).map { |bid| { team: bid.team, priority: bid.priority } }&lt;br /&gt;
      # Fetch teams that are not waitlisted for this topic&lt;br /&gt;
      @assigned_teams_by_topic[topic.id] = SignedUpTeam.where(topic_id: topic.id, is_waitlisted: false).map(&amp;amp;:team)&lt;br /&gt;
      # @count1[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 1 }&lt;br /&gt;
      # @count2[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 2 }&lt;br /&gt;
      # @count3[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 3 }       &lt;br /&gt;
&lt;br /&gt;
      # Dynamically initializing and updating @count1, @count2, and @count3&lt;br /&gt;
      (1..3).each do |priority|&lt;br /&gt;
        instance_variable_set(&amp;quot;@count#{priority}&amp;quot;, Hash.new(0)) unless instance_variable_defined?(&amp;quot;@count#{priority}&amp;quot;)&lt;br /&gt;
        instance_variable_get(&amp;quot;@count#{priority}&amp;quot;)[topic.id] = @bids_by_topic[topic.id].count { |bid| bid[:priority] == priority }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # Calculate the total number of teams and percentages after fetching bid details&lt;br /&gt;
    topic_ids = SignUpTopic.where(assignment_id: @assignment.id).pluck(:id)&lt;br /&gt;
    @total_teams = SignedUpTeam.where(topic_id: topic_ids).distinct.count(:team_id)&lt;br /&gt;
    @priority_counts = calculate_priority_counts(@assigned_teams_by_topic, @bids_by_topic)&lt;br /&gt;
    @percentages = calculate_percentages(@priority_counts, @total_teams)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 2: calculate_priority_counts'''&lt;br /&gt;
&lt;br /&gt;
1. Parameters&lt;br /&gt;
*assigned_teams_by_topic (Hash): A hash mapping each topic to an array of assigned teams.&lt;br /&gt;
*bids_by_topic (Hash): A hash mapping each topic to an array of bid objects, where each bid object is a hash containing team and priority information.&lt;br /&gt;
&lt;br /&gt;
2. Functionality&lt;br /&gt;
*Initial Setup: Initializes a hash priority_counts with keys 1, 2, and 3, each having an initial value of 0. These keys represent the priority levels, and their values count the number of teams assigned to each level.&lt;br /&gt;
&lt;br /&gt;
*Iterating Over Topics and Teams: Iterates over each topic and its associated teams found in assigned_teams_by_topic. For each team in a topic, the method searches bids_by_topic[topic_id] to find a bid made by the team.&lt;br /&gt;
&lt;br /&gt;
*Updating Priority Counts: If a bid is found, the method increments the count in priority_counts corresponding to the priority level in the bid. This process effectively tallies the number of teams assigned to each priority level.&lt;br /&gt;
&lt;br /&gt;
3. Returns&lt;br /&gt;
*priority_counts (Hash): A hash with keys 1, 2, and 3, where each key's value represents the count of teams assigned to that respective priority level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Calculates the count of assigned teams for each priority level (1, 2, 3) across all topics.&lt;br /&gt;
  # It checks each team associated with a topic and determines if the team's bid matches&lt;br /&gt;
  # one of the priority levels, incrementing the respective count if so.&lt;br /&gt;
  def calculate_priority_counts(assigned_teams_by_topic, bids_by_topic)&lt;br /&gt;
    priority_counts = { 1 =&amp;gt; 0, 2 =&amp;gt; 0, 3 =&amp;gt; 0 }&lt;br /&gt;
    assigned_teams_by_topic.each do |topic_id, teams|&lt;br /&gt;
      teams.each do |team|&lt;br /&gt;
        bid_info = bids_by_topic[topic_id].find { |bid| bid[:team] == team }&lt;br /&gt;
        priority_counts[bid_info[:priority]] += 1 if bid_info&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    priority_counts&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 3: calculate_percentages'''&lt;br /&gt;
&lt;br /&gt;
* This method calculates the percentages of teams that received their first, second, and third choice based on the counts of teams at each priority level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Calculates the percentages of teams that received their first, second, and third choice&lt;br /&gt;
  # based on the counts of teams at each priority level.&lt;br /&gt;
  def calculate_percentages(priority_counts, total_teams)&lt;br /&gt;
    priority_counts.transform_values { |count| (count.to_f / total_teams * 100).round(2) }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_each_topic.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:bidding_percentage.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt;Bidding Details for &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;!-- Displaying percentages in a more visually appealing way --&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;percentages&amp;quot; style=&amp;quot;margin-bottom: 20px; padding: 15px; border: 1px solid&lt;br /&gt;
#ccc; border-radius: 5px; background-color: #f9f9f9;&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;h4 style=&amp;quot;margin-bottom: 15px; border-bottom: 1px solid #eee;&lt;br /&gt;
padding-bottom: 10px;&amp;quot;&amp;gt;Percentage of Teams Getting Their Choices:&amp;lt;/h4&amp;gt;&lt;br /&gt;
  &amp;lt;ul style=&amp;quot;list-style: none; padding: 0;&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;#1 Choice:&amp;lt;/strong&amp;gt; &amp;lt;span style=&amp;quot;color: #4CAF50;&amp;quot;&amp;gt;&amp;lt;%= @percentages[1] || 0 %&amp;gt; %&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;#2 Choice:&amp;lt;/strong&amp;gt; &amp;lt;span style=&amp;quot;color: #FF9800;&amp;quot;&amp;gt;&amp;lt;%= @percentages[2] || 0 %&amp;gt; %&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;#3 Choice:&amp;lt;/strong&amp;gt; &amp;lt;span style=&amp;quot;color: #F44336;&amp;quot;&amp;gt;&amp;lt;%= @percentages[3] || 0 %&amp;gt; %&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;style&amp;gt;&lt;br /&gt;
.assigned-team {&lt;br /&gt;
  background-color: yellow; &lt;br /&gt;
  color: black;             &lt;br /&gt;
}&lt;br /&gt;
.bids-column {&lt;br /&gt;
    width: 100px; /* Adjust width as needed */&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/style&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table class=&amp;quot;table table-bordered table-hover&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;thead&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic Name&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic ID&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Bidding Teams&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#1 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#2 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#3 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;/thead&amp;gt;&lt;br /&gt;
  &amp;lt;tbody&amp;gt;&lt;br /&gt;
    &amp;lt;% @topics.each do |topic| %&amp;gt;&lt;br /&gt;
      &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.topic_name %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.id %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&lt;br /&gt;
          &amp;lt;% @bids_by_topic[topic.id].each do |bid_info| %&amp;gt;&lt;br /&gt;
            &amp;lt;% team = bid_info[:team] %&amp;gt;&lt;br /&gt;
            &amp;lt;% assigned_team = @assigned_teams_by_topic[topic.id].include?(team) %&amp;gt;&lt;br /&gt;
            &amp;lt;span class=&amp;quot;&amp;lt;%= assigned_team ? 'assigned-team' : '' %&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;%= team.name %&amp;gt; (#&amp;lt;%= bid_info[:priority] %&amp;gt;)&lt;br /&gt;
            &amp;lt;/span&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count1[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count1[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count2[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count2[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count3[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count3[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
      &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;% end %&amp;gt;&lt;br /&gt;
  &amp;lt;/tbody&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;javascript:history.back()&amp;quot;&amp;gt;Back&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
1. Test for Populating Bids and Assigned Teams:&lt;br /&gt;
*This test ensures that the bidding_table_for_each_topic method correctly populates bids and assigned teams for each topic.&lt;br /&gt;
*It checks if @bids_by_topic is populated correctly, verifying the length of bids for specific topics.&lt;br /&gt;
*It tests @assigned_teams_by_topic, ensuring it handles cases where topics have no teams.&lt;br /&gt;
&lt;br /&gt;
2. Test for Fetching All Topics:&lt;br /&gt;
*This test verifies that all topics for the assignment are fetched and stored in @topics.&lt;br /&gt;
&lt;br /&gt;
3. Test for Calculating Priority Counts:&lt;br /&gt;
*This test checks the calculation of priority counts for each topic.&lt;br /&gt;
*It compares the calculated priority counts against an expected set of values.&lt;br /&gt;
&lt;br /&gt;
4. Test for Calculating Percentages for Teams Getting Their Choices:&lt;br /&gt;
*This test ensures that the method correctly calculates the percentages of teams getting their preferred choices.&lt;br /&gt;
*It handles special cases where the expected percentages are not a number (NaN).&lt;br /&gt;
&lt;br /&gt;
Rspec Testing &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_each_topic.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe '#bidding_table_for_each_topic' do&lt;br /&gt;
    before :each do&lt;br /&gt;
      # Set the assignment id in the params&lt;br /&gt;
      params = ActionController::Parameters.new(id: assignment.id)&lt;br /&gt;
      allow(controller).to receive(:params).and_return(params)&lt;br /&gt;
    end&lt;br /&gt;
    it 'populates bids and assigned teams for each topic, handling topics with no teams' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
      # Check if @bids_by_topic is populated correctly&lt;br /&gt;
      expect(controller.instance_variable_get(:@bids_by_topic)[topic1.id].length).to eq(1)&lt;br /&gt;
      expect(controller.instance_variable_get(:@bids_by_topic)[topic2.id].length).to eq(1)&lt;br /&gt;
      # Check if @assigned_teams_by_topic is populated correctly, allowing for no teams&lt;br /&gt;
      assigned_teams_topic1 = controller.instance_variable_get(:@assigned_teams_by_topic)[topic1.id]&lt;br /&gt;
      if assigned_teams_topic1&lt;br /&gt;
        expect(assigned_teams_topic1.length).to(satisfy { |value| (value == 0) || (value == 1) })&lt;br /&gt;
      else&lt;br /&gt;
        expect(assigned_teams_topic1).to be_nil&lt;br /&gt;
      end&lt;br /&gt;
      # Check the counts of bids for each priority level&lt;br /&gt;
      # Ensure to adjust these based on what is set up in your test data&lt;br /&gt;
      expect(controller.instance_variable_get(:@count1)[topic1.id]).to eq(1)&lt;br /&gt;
      # assuming there is one bid with priority 1 for topic1&lt;br /&gt;
      expect(controller.instance_variable_get(:@count2)[topic1.id]).to eq(0)&lt;br /&gt;
      # assuming there are no bids with priority 2 for topic1&lt;br /&gt;
      expect(controller.instance_variable_get(:@count3)[topic1.id]).to eq(0)&lt;br /&gt;
      # assuming there are no bids with priority 3 for topic1&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'fetches all topics for the assignment' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
      expect(controller.instance_variable_get(:@topics)).to match_array([topic1, topic2, topic3, topic4])&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'correctly calculates priority counts for each topic' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
      # Assuming you have a way to know the expected counts for each priority&lt;br /&gt;
      expected_priority_counts = { 1 =&amp;gt; 0, &lt;br /&gt;
                                   2 =&amp;gt; 0, &lt;br /&gt;
                                   3 =&amp;gt; 0 }&lt;br /&gt;
  &lt;br /&gt;
      priority_counts = controller.instance_variable_get(:@priority_counts)&lt;br /&gt;
      expect(priority_counts).to eq(expected_priority_counts)&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'correctly calculates percentages for teams getting their choices' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
      # Assuming you have a way to know the expected percentages&lt;br /&gt;
      expected_percentages = { 1 =&amp;gt; Float::NAN, &lt;br /&gt;
                               2 =&amp;gt; Float::NAN, &lt;br /&gt;
                               3 =&amp;gt; Float::NAN }&lt;br /&gt;
  &lt;br /&gt;
      percentages = controller.instance_variable_get(:@percentages)&lt;br /&gt;
      expect(percentages[1].nan?).to be true if expected_percentages[1].nan?&lt;br /&gt;
      expect(percentages[2].nan?).to be true if expected_percentages[2].nan?&lt;br /&gt;
      expect(percentages[3].nan?).to be true if expected_percentages[3].nan?&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
&lt;br /&gt;
'''Github Repository: ''' https://github.com/Shreshth-Malik/expertiza&lt;br /&gt;
&lt;br /&gt;
== Testing Credentials ==&lt;br /&gt;
&lt;br /&gt;
username: instructor6&lt;br /&gt;
&lt;br /&gt;
password: password&lt;br /&gt;
&lt;br /&gt;
== Team == &lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Edward F. Gehringer (efg@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
'''Members'''&lt;br /&gt;
&lt;br /&gt;
Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shreshth Malik (smalik4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shuai Chen (schen76@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152757</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding (Phase2)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152757"/>
		<updated>2023-12-05T07:52:14Z</updated>

		<summary type="html">&lt;p&gt;Schen76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Motivation ==&lt;br /&gt;
&lt;br /&gt;
The bidding view is needed because we don’t have a way of finding out whether the bidding algorithm is running correctly.  This project is to add a bidding view to show how the topics are assigned to those teams who bid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Work Plan ==&lt;br /&gt;
&lt;br /&gt;
Based on the project's objectives and feedback received from our mentor, we have identified specific areas for improvement:&lt;br /&gt;
&lt;br /&gt;
1) Refactor variable names within methods such as &amp;quot;bidding_details&amp;quot; and variables like &amp;quot;Topic name&amp;quot; and &amp;quot;Bidding teams&amp;quot; to enhance clarity and specificity.&lt;br /&gt;
&lt;br /&gt;
2) Adjust capitalization for certain components, ensuring that only the first word is capitalized for consistency.&lt;br /&gt;
&lt;br /&gt;
3) Introduce calculations to determine percentages based on additional data, such as the total number of teams and the number of teams for each priority, within the &amp;quot;lottery_controller.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4) Conduct thorough testing of the modified controller and view to ensure optimal functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Newfeature.jpg | 888px]]&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
To add functionality for showing the percentages of the number of teams that got their #1, #2, and #3 choices. We can follow these high-level steps:&lt;br /&gt;
&lt;br /&gt;
'''Lottery_Controller:'''&lt;br /&gt;
&lt;br /&gt;
i) Calculate the Total Number of Teams: Before we can calculate percentages, we need to know the total number of teams that participated in the bidding process. This will be our denominator in the percentage calculation.&lt;br /&gt;
&lt;br /&gt;
ii) Calculate the Number of Teams for Each Priority: From our `bidding_details` method, we already have counts for how many teams bid on each topic as their #1, #2, and #3 choice (`@count1`, `@count2`, `@count3`). However, these counts are currently organized by topic. We would need to modify this to count how many teams got their #1, #2, and #3 choices as their assigned topic.&lt;br /&gt;
&lt;br /&gt;
iii) Calculate Percentages: Once we have the number of teams that got their #1, #2, and #3 choices, we can calculate the percentages by dividing these numbers by the total number of teams and multiplying by 100.&lt;br /&gt;
&lt;br /&gt;
'''Bidding_detail view:'''&lt;br /&gt;
&lt;br /&gt;
i) Update the View and Display Percentages: Above the table in our previous view, we can add a section to display these percentages.&lt;br /&gt;
&lt;br /&gt;
ii) Format the Display: We will use a bold heading for each percentage type and format the number to a fixed number of decimal places.&lt;br /&gt;
&lt;br /&gt;
iii) Ensure Responsiveness: Make sure the display of these percentages adjusts well to different screen sizes, maintaining readability and layout consistency. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code Effort ==&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; app/controllers/lottery_controller.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 1: bidding_table_for_each_topic'''&lt;br /&gt;
&lt;br /&gt;
This method generates a bidding table for each topic within an assignment. It performs several operations to gather and organize data related to topics, bids, and teams. Here's a breakdown of what the code does:&lt;br /&gt;
&lt;br /&gt;
1. Fetch Assignment:&lt;br /&gt;
&lt;br /&gt;
*It retrieves the assignment with the specified params[:id] from the database and stores it in the @assignment instance variable.&lt;br /&gt;
&lt;br /&gt;
2. Fetch Topics:&lt;br /&gt;
&lt;br /&gt;
*It retrieves all sign-up topics associated with the assignment and stores them in the @topics instance variable.&lt;br /&gt;
&lt;br /&gt;
3. Fetch Bids and Assigned Teams:&lt;br /&gt;
&lt;br /&gt;
For each topic in @topics, it:&lt;br /&gt;
*Retrieves all bids associated with that topic and stores them in a hash, where the key is the topic's ID and the value is an array of bids with their associated teams and priorities.&lt;br /&gt;
*Retrieves teams that are not waitlisted for the topic and stores them in a hash, again using the topic's ID as the key and an array of teams as the value.&lt;br /&gt;
&lt;br /&gt;
4. Priority Count Calculation:&lt;br /&gt;
&lt;br /&gt;
*It dynamically calculates and updates the counts for each bid priority level (1, 2, and 3) for each topic. These counts are stored in instance variables named @count1, @count2, and @count3. These instance variables are hashes where the keys are topic IDs, and the values are counts for each priority level.&lt;br /&gt;
&lt;br /&gt;
5. Calculate Total Teams:&lt;br /&gt;
&lt;br /&gt;
*It determines the total number of teams across all topics in the assignment by counting distinct team IDs among all non-waitlisted teams for the specified topics.&lt;br /&gt;
&lt;br /&gt;
6. Calculate Priority Counts and Percentages:&lt;br /&gt;
&lt;br /&gt;
*It calls two helper methods, calculate_priority_counts and calculate_percentages, to calculate the total counts of teams at each priority level and the corresponding percentages. The results are stored in the @priority_counts and @percentages instance variables, respectively.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Prepares data for displaying the bidding details for each topic within an assignment.&lt;br /&gt;
  # It calculates the number of bids for each priority (1, 2, 3) per topic and also computes&lt;br /&gt;
  # the overall percentages of teams that received their first, second, and third choice.&lt;br /&gt;
  def bidding_table_for_each_topic&lt;br /&gt;
    @assignment = Assignment.find(params[:id])&lt;br /&gt;
    # Fetch all topics for the assignment&lt;br /&gt;
    @topics = @assignment.sign_up_topics&lt;br /&gt;
    # Fetch all bids for these topics&lt;br /&gt;
    @bids_by_topic = {}&lt;br /&gt;
    @assigned_teams_by_topic = {} # This will store the assigned teams for each topic&lt;br /&gt;
    @topics.each do |topic|&lt;br /&gt;
      # Assuming bids are stored with a topic_id, and each bid has a team associated with it&lt;br /&gt;
      @bids_by_topic[topic.id] = Bid.where(topic_id: topic.id).map { |bid| { team: bid.team, priority: bid.priority } }&lt;br /&gt;
      # Fetch teams that are not waitlisted for this topic&lt;br /&gt;
      @assigned_teams_by_topic[topic.id] = SignedUpTeam.where(topic_id: topic.id, is_waitlisted: false).map(&amp;amp;:team)&lt;br /&gt;
      # @count1[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 1 }&lt;br /&gt;
      # @count2[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 2 }&lt;br /&gt;
      # @count3[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 3 }       &lt;br /&gt;
&lt;br /&gt;
      # Dynamically initializing and updating @count1, @count2, and @count3&lt;br /&gt;
      (1..3).each do |priority|&lt;br /&gt;
        instance_variable_set(&amp;quot;@count#{priority}&amp;quot;, Hash.new(0)) unless instance_variable_defined?(&amp;quot;@count#{priority}&amp;quot;)&lt;br /&gt;
        instance_variable_get(&amp;quot;@count#{priority}&amp;quot;)[topic.id] = @bids_by_topic[topic.id].count { |bid| bid[:priority] == priority }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # Calculate the total number of teams and percentages after fetching bid details&lt;br /&gt;
    topic_ids = SignUpTopic.where(assignment_id: @assignment.id).pluck(:id)&lt;br /&gt;
    @total_teams = SignedUpTeam.where(topic_id: topic_ids).distinct.count(:team_id)&lt;br /&gt;
    @priority_counts = calculate_priority_counts(@assigned_teams_by_topic, @bids_by_topic)&lt;br /&gt;
    @percentages = calculate_percentages(@priority_counts, @total_teams)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 2: calculate_priority_counts'''&lt;br /&gt;
&lt;br /&gt;
1. Parameters&lt;br /&gt;
*assigned_teams_by_topic (Hash): A hash mapping each topic to an array of assigned teams.&lt;br /&gt;
*bids_by_topic (Hash): A hash mapping each topic to an array of bid objects, where each bid object is a hash containing team and priority information.&lt;br /&gt;
&lt;br /&gt;
2. Functionality&lt;br /&gt;
*Initial Setup: Initializes a hash priority_counts with keys 1, 2, and 3, each having an initial value of 0. These keys represent the priority levels, and their values count the number of teams assigned to each level.&lt;br /&gt;
&lt;br /&gt;
*Iterating Over Topics and Teams: Iterates over each topic and its associated teams found in assigned_teams_by_topic. For each team in a topic, the method searches bids_by_topic[topic_id] to find a bid made by the team.&lt;br /&gt;
&lt;br /&gt;
*Updating Priority Counts: If a bid is found, the method increments the count in priority_counts corresponding to the priority level in the bid. This process effectively tallies the number of teams assigned to each priority level.&lt;br /&gt;
&lt;br /&gt;
3. Returns&lt;br /&gt;
*priority_counts (Hash): A hash with keys 1, 2, and 3, where each key's value represents the count of teams assigned to that respective priority level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Calculates the count of assigned teams for each priority level (1, 2, 3) across all topics.&lt;br /&gt;
  # It checks each team associated with a topic and determines if the team's bid matches&lt;br /&gt;
  # one of the priority levels, incrementing the respective count if so.&lt;br /&gt;
  def calculate_priority_counts(assigned_teams_by_topic, bids_by_topic)&lt;br /&gt;
    priority_counts = { 1 =&amp;gt; 0, 2 =&amp;gt; 0, 3 =&amp;gt; 0 }&lt;br /&gt;
    assigned_teams_by_topic.each do |topic_id, teams|&lt;br /&gt;
      teams.each do |team|&lt;br /&gt;
        bid_info = bids_by_topic[topic_id].find { |bid| bid[:team] == team }&lt;br /&gt;
        priority_counts[bid_info[:priority]] += 1 if bid_info&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    priority_counts&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 3: calculate_percentages'''&lt;br /&gt;
&lt;br /&gt;
* This method calculates the percentages of teams that received their first, second, and third choice based on the counts of teams at each priority level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Calculates the percentages of teams that received their first, second, and third choice&lt;br /&gt;
  # based on the counts of teams at each priority level.&lt;br /&gt;
  def calculate_percentages(priority_counts, total_teams)&lt;br /&gt;
    priority_counts.transform_values { |count| (count.to_f / total_teams * 100).round(2) }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_each_topic.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:bidding_percentage.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt;Bidding Details for &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;!-- Displaying percentages in a more visually appealing way --&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;percentages&amp;quot; style=&amp;quot;margin-bottom: 20px; padding: 15px; border: 1px solid&lt;br /&gt;
#ccc; border-radius: 5px; background-color: #f9f9f9;&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;h4 style=&amp;quot;margin-bottom: 15px; border-bottom: 1px solid #eee;&lt;br /&gt;
padding-bottom: 10px;&amp;quot;&amp;gt;Percentage of Teams Getting Their Choices:&amp;lt;/h4&amp;gt;&lt;br /&gt;
  &amp;lt;ul style=&amp;quot;list-style: none; padding: 0;&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;#1 Choice:&amp;lt;/strong&amp;gt; &amp;lt;span style=&amp;quot;color: #4CAF50;&amp;quot;&amp;gt;&amp;lt;%= @percentages[1] || 0 %&amp;gt; %&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;#2 Choice:&amp;lt;/strong&amp;gt; &amp;lt;span style=&amp;quot;color: #FF9800;&amp;quot;&amp;gt;&amp;lt;%= @percentages[2] || 0 %&amp;gt; %&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;#3 Choice:&amp;lt;/strong&amp;gt; &amp;lt;span style=&amp;quot;color: #F44336;&amp;quot;&amp;gt;&amp;lt;%= @percentages[3] || 0 %&amp;gt; %&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;style&amp;gt;&lt;br /&gt;
.assigned-team {&lt;br /&gt;
  background-color: yellow; &lt;br /&gt;
  color: black;             &lt;br /&gt;
}&lt;br /&gt;
.bids-column {&lt;br /&gt;
    width: 100px; /* Adjust width as needed */&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/style&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table class=&amp;quot;table table-bordered table-hover&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;thead&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic Name&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic ID&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Bidding Teams&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#1 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#2 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#3 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;/thead&amp;gt;&lt;br /&gt;
  &amp;lt;tbody&amp;gt;&lt;br /&gt;
    &amp;lt;% @topics.each do |topic| %&amp;gt;&lt;br /&gt;
      &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.topic_name %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.id %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&lt;br /&gt;
          &amp;lt;% @bids_by_topic[topic.id].each do |bid_info| %&amp;gt;&lt;br /&gt;
            &amp;lt;% team = bid_info[:team] %&amp;gt;&lt;br /&gt;
            &amp;lt;% assigned_team = @assigned_teams_by_topic[topic.id].include?(team) %&amp;gt;&lt;br /&gt;
            &amp;lt;span class=&amp;quot;&amp;lt;%= assigned_team ? 'assigned-team' : '' %&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;%= team.name %&amp;gt; (#&amp;lt;%= bid_info[:priority] %&amp;gt;)&lt;br /&gt;
            &amp;lt;/span&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count1[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count1[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count2[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count2[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count3[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count3[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
      &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;% end %&amp;gt;&lt;br /&gt;
  &amp;lt;/tbody&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;javascript:history.back()&amp;quot;&amp;gt;Back&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
1. Test for Populating Bids and Assigned Teams:&lt;br /&gt;
*This test ensures that the bidding_table_for_each_topic method correctly populates bids and assigned teams for each topic.&lt;br /&gt;
*It checks if @bids_by_topic is populated correctly, verifying the length of bids for specific topics.&lt;br /&gt;
*It tests @assigned_teams_by_topic, ensuring it handles cases where topics have no teams.&lt;br /&gt;
&lt;br /&gt;
2. Test for Fetching All Topics:&lt;br /&gt;
*This test verifies that all topics for the assignment are fetched and stored in @topics.&lt;br /&gt;
&lt;br /&gt;
3. Test for Calculating Priority Counts:&lt;br /&gt;
*This test checks the calculation of priority counts for each topic.&lt;br /&gt;
*It compares the calculated priority counts against an expected set of values.&lt;br /&gt;
&lt;br /&gt;
4. Test for Calculating Percentages for Teams Getting Their Choices:&lt;br /&gt;
*This test ensures that the method correctly calculates the percentages of teams getting their preferred choices.&lt;br /&gt;
*It handles special cases where the expected percentages are not a number (NaN).&lt;br /&gt;
&lt;br /&gt;
Rspec Testing &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_each_topic.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe '#bidding_table_for_each_topic' do&lt;br /&gt;
    before :each do&lt;br /&gt;
      # Set the assignment id in the params&lt;br /&gt;
      params = ActionController::Parameters.new(id: assignment.id)&lt;br /&gt;
      allow(controller).to receive(:params).and_return(params)&lt;br /&gt;
    end&lt;br /&gt;
    it 'populates bids and assigned teams for each topic, handling topics with no teams' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
      # Check if @bids_by_topic is populated correctly&lt;br /&gt;
      expect(controller.instance_variable_get(:@bids_by_topic)[topic1.id].length).to eq(1)&lt;br /&gt;
      expect(controller.instance_variable_get(:@bids_by_topic)[topic2.id].length).to eq(1)&lt;br /&gt;
      # Check if @assigned_teams_by_topic is populated correctly, allowing for no teams&lt;br /&gt;
      assigned_teams_topic1 = controller.instance_variable_get(:@assigned_teams_by_topic)[topic1.id]&lt;br /&gt;
      if assigned_teams_topic1&lt;br /&gt;
        expect(assigned_teams_topic1.length).to(satisfy { |value| (value == 0) || (value == 1) })&lt;br /&gt;
      else&lt;br /&gt;
        expect(assigned_teams_topic1).to be_nil&lt;br /&gt;
      end&lt;br /&gt;
      # Check the counts of bids for each priority level&lt;br /&gt;
      # Ensure to adjust these based on what is set up in your test data&lt;br /&gt;
      expect(controller.instance_variable_get(:@count1)[topic1.id]).to eq(1)&lt;br /&gt;
      # assuming there is one bid with priority 1 for topic1&lt;br /&gt;
      expect(controller.instance_variable_get(:@count2)[topic1.id]).to eq(0)&lt;br /&gt;
      # assuming there are no bids with priority 2 for topic1&lt;br /&gt;
      expect(controller.instance_variable_get(:@count3)[topic1.id]).to eq(0)&lt;br /&gt;
      # assuming there are no bids with priority 3 for topic1&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'fetches all topics for the assignment' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
      expect(controller.instance_variable_get(:@topics)).to match_array([topic1, topic2, topic3, topic4])&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'correctly calculates priority counts for each topic' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
      # Assuming you have a way to know the expected counts for each priority&lt;br /&gt;
      expected_priority_counts = { 1 =&amp;gt; 0, &lt;br /&gt;
                                   2 =&amp;gt; 0, &lt;br /&gt;
                                   3 =&amp;gt; 0 }&lt;br /&gt;
  &lt;br /&gt;
      priority_counts = controller.instance_variable_get(:@priority_counts)&lt;br /&gt;
      expect(priority_counts).to eq(expected_priority_counts)&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'correctly calculates percentages for teams getting their choices' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
      # Assuming you have a way to know the expected percentages&lt;br /&gt;
      expected_percentages = { 1 =&amp;gt; Float::NAN, &lt;br /&gt;
                               2 =&amp;gt; Float::NAN, &lt;br /&gt;
                               3 =&amp;gt; Float::NAN }&lt;br /&gt;
  &lt;br /&gt;
      percentages = controller.instance_variable_get(:@percentages)&lt;br /&gt;
      expect(percentages[1].nan?).to be true if expected_percentages[1].nan?&lt;br /&gt;
      expect(percentages[2].nan?).to be true if expected_percentages[2].nan?&lt;br /&gt;
      expect(percentages[3].nan?).to be true if expected_percentages[3].nan?&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
&lt;br /&gt;
'''Github Repository: ''' https://github.com/Shreshth-Malik/expertiza&lt;br /&gt;
&lt;br /&gt;
== Testing Credentials ==&lt;br /&gt;
&lt;br /&gt;
username: instructor6&lt;br /&gt;
&lt;br /&gt;
password: password&lt;br /&gt;
&lt;br /&gt;
== Team == &lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Edward F. Gehringer (efg@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
'''Members'''&lt;br /&gt;
&lt;br /&gt;
Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shreshth Malik (smalik4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shuai Chen (schen76@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152756</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding (Phase2)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152756"/>
		<updated>2023-12-05T07:40:03Z</updated>

		<summary type="html">&lt;p&gt;Schen76: /* Team */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Motivation ==&lt;br /&gt;
&lt;br /&gt;
The bidding view is needed because we don’t have a way of finding out whether the bidding algorithm is running correctly.  This project is to add a bidding view to show how the topics are assigned to those teams who bid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Work Plan ==&lt;br /&gt;
&lt;br /&gt;
Based on the project's objectives and feedback received from our mentor, we have identified specific areas for improvement:&lt;br /&gt;
&lt;br /&gt;
1) Refactor variable names within methods such as &amp;quot;bidding_details&amp;quot; and variables like &amp;quot;Topic name&amp;quot; and &amp;quot;Bidding teams&amp;quot; to enhance clarity and specificity.&lt;br /&gt;
&lt;br /&gt;
2) Adjust capitalization for certain components, ensuring that only the first word is capitalized for consistency.&lt;br /&gt;
&lt;br /&gt;
3) Introduce calculations to determine percentages based on additional data, such as the total number of teams and the number of teams for each priority, within the &amp;quot;lottery_controller.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4) Conduct thorough testing of the modified controller and view to ensure optimal functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Newfeature.jpg | 888px]]&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
To add functionality for showing the percentages of the number of teams that got their #1, #2, and #3 choices. We can follow these high-level steps:&lt;br /&gt;
&lt;br /&gt;
'''Lottery_Controller:'''&lt;br /&gt;
&lt;br /&gt;
i) Calculate the Total Number of Teams: Before we can calculate percentages, we need to know the total number of teams that participated in the bidding process. This will be our denominator in the percentage calculation.&lt;br /&gt;
&lt;br /&gt;
ii) Calculate the Number of Teams for Each Priority: From our `bidding_details` method, we already have counts for how many teams bid on each topic as their #1, #2, and #3 choice (`@count1`, `@count2`, `@count3`). However, these counts are currently organized by topic. We would need to modify this to count how many teams got their #1, #2, and #3 choices as their assigned topic.&lt;br /&gt;
&lt;br /&gt;
iii) Calculate Percentages: Once we have the number of teams that got their #1, #2, and #3 choices, we can calculate the percentages by dividing these numbers by the total number of teams and multiplying by 100.&lt;br /&gt;
&lt;br /&gt;
'''Bidding_detail view:'''&lt;br /&gt;
&lt;br /&gt;
i) Update the View and Display Percentages: Above the table in our previous view, we can add a section to display these percentages.&lt;br /&gt;
&lt;br /&gt;
ii) Format the Display: We will use a bold heading for each percentage type and format the number to a fixed number of decimal places.&lt;br /&gt;
&lt;br /&gt;
iii) Ensure Responsiveness: Make sure the display of these percentages adjusts well to different screen sizes, maintaining readability and layout consistency. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code Effort ==&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; app/controllers/lottery_controller.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 1: bidding_table_for_each_topic'''&lt;br /&gt;
&lt;br /&gt;
This method generates a bidding table for each topic within an assignment. It performs several operations to gather and organize data related to topics, bids, and teams. Here's a breakdown of what the code does:&lt;br /&gt;
&lt;br /&gt;
1. Fetch Assignment:&lt;br /&gt;
&lt;br /&gt;
*It retrieves the assignment with the specified params[:id] from the database and stores it in the @assignment instance variable.&lt;br /&gt;
&lt;br /&gt;
2. Fetch Topics:&lt;br /&gt;
&lt;br /&gt;
*It retrieves all sign-up topics associated with the assignment and stores them in the @topics instance variable.&lt;br /&gt;
&lt;br /&gt;
3. Fetch Bids and Assigned Teams:&lt;br /&gt;
&lt;br /&gt;
For each topic in @topics, it:&lt;br /&gt;
*Retrieves all bids associated with that topic and stores them in a hash, where the key is the topic's ID and the value is an array of bids with their associated teams and priorities.&lt;br /&gt;
*Retrieves teams that are not waitlisted for the topic and stores them in a hash, again using the topic's ID as the key and an array of teams as the value.&lt;br /&gt;
&lt;br /&gt;
4. Priority Count Calculation:&lt;br /&gt;
&lt;br /&gt;
*It dynamically calculates and updates the counts for each bid priority level (1, 2, and 3) for each topic. These counts are stored in instance variables named @count1, @count2, and @count3. These instance variables are hashes where the keys are topic IDs, and the values are counts for each priority level.&lt;br /&gt;
&lt;br /&gt;
5. Calculate Total Teams:&lt;br /&gt;
&lt;br /&gt;
*It determines the total number of teams across all topics in the assignment by counting distinct team IDs among all non-waitlisted teams for the specified topics.&lt;br /&gt;
&lt;br /&gt;
6. Calculate Priority Counts and Percentages:&lt;br /&gt;
&lt;br /&gt;
*It calls two helper methods, calculate_priority_counts and calculate_percentages, to calculate the total counts of teams at each priority level and the corresponding percentages. The results are stored in the @priority_counts and @percentages instance variables, respectively.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Prepares data for displaying the bidding details for each topic within an assignment.&lt;br /&gt;
  # It calculates the number of bids for each priority (1, 2, 3) per topic and also computes&lt;br /&gt;
  # the overall percentages of teams that received their first, second, and third choice.&lt;br /&gt;
  def bidding_table_for_each_topic&lt;br /&gt;
    @assignment = Assignment.find(params[:id])&lt;br /&gt;
    # Fetch all topics for the assignment&lt;br /&gt;
    @topics = @assignment.sign_up_topics&lt;br /&gt;
    # Fetch all bids for these topics&lt;br /&gt;
    @bids_by_topic = {}&lt;br /&gt;
    @assigned_teams_by_topic = {} # This will store the assigned teams for each topic&lt;br /&gt;
    @topics.each do |topic|&lt;br /&gt;
      # Assuming bids are stored with a topic_id, and each bid has a team associated with it&lt;br /&gt;
      @bids_by_topic[topic.id] = Bid.where(topic_id: topic.id).map { |bid| { team: bid.team, priority: bid.priority } }&lt;br /&gt;
      # Fetch teams that are not waitlisted for this topic&lt;br /&gt;
      @assigned_teams_by_topic[topic.id] = SignedUpTeam.where(topic_id: topic.id, is_waitlisted: false).map(&amp;amp;:team)&lt;br /&gt;
      # @count1[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 1 }&lt;br /&gt;
      # @count2[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 2 }&lt;br /&gt;
      # @count3[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 3 }       &lt;br /&gt;
&lt;br /&gt;
      # Dynamically initializing and updating @count1, @count2, and @count3&lt;br /&gt;
      (1..3).each do |priority|&lt;br /&gt;
        instance_variable_set(&amp;quot;@count#{priority}&amp;quot;, Hash.new(0)) unless instance_variable_defined?(&amp;quot;@count#{priority}&amp;quot;)&lt;br /&gt;
        instance_variable_get(&amp;quot;@count#{priority}&amp;quot;)[topic.id] = @bids_by_topic[topic.id].count { |bid| bid[:priority] == priority }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # Calculate the total number of teams and percentages after fetching bid details&lt;br /&gt;
    topic_ids = SignUpTopic.where(assignment_id: @assignment.id).pluck(:id)&lt;br /&gt;
    @total_teams = SignedUpTeam.where(topic_id: topic_ids).distinct.count(:team_id)&lt;br /&gt;
    @priority_counts = calculate_priority_counts(@assigned_teams_by_topic, @bids_by_topic)&lt;br /&gt;
    @percentages = calculate_percentages(@priority_counts, @total_teams)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 2: calculate_priority_counts'''&lt;br /&gt;
&lt;br /&gt;
1. Parameters&lt;br /&gt;
*assigned_teams_by_topic (Hash): A hash mapping each topic to an array of assigned teams.&lt;br /&gt;
*bids_by_topic (Hash): A hash mapping each topic to an array of bid objects, where each bid object is a hash containing team and priority information.&lt;br /&gt;
&lt;br /&gt;
2. Functionality&lt;br /&gt;
*Initial Setup: Initializes a hash priority_counts with keys 1, 2, and 3, each having an initial value of 0. These keys represent the priority levels, and their values count the number of teams assigned to each level.&lt;br /&gt;
&lt;br /&gt;
*Iterating Over Topics and Teams: Iterates over each topic and its associated teams found in assigned_teams_by_topic. For each team in a topic, the method searches bids_by_topic[topic_id] to find a bid made by the team.&lt;br /&gt;
&lt;br /&gt;
*Updating Priority Counts: If a bid is found, the method increments the count in priority_counts corresponding to the priority level in the bid. This process effectively tallies the number of teams assigned to each priority level.&lt;br /&gt;
&lt;br /&gt;
3. Returns&lt;br /&gt;
*priority_counts (Hash): A hash with keys 1, 2, and 3, where each key's value represents the count of teams assigned to that respective priority level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Calculates the count of assigned teams for each priority level (1, 2, 3) across all topics.&lt;br /&gt;
  # It checks each team associated with a topic and determines if the team's bid matches&lt;br /&gt;
  # one of the priority levels, incrementing the respective count if so.&lt;br /&gt;
  def calculate_priority_counts(assigned_teams_by_topic, bids_by_topic)&lt;br /&gt;
    priority_counts = { 1 =&amp;gt; 0, 2 =&amp;gt; 0, 3 =&amp;gt; 0 }&lt;br /&gt;
    assigned_teams_by_topic.each do |topic_id, teams|&lt;br /&gt;
      teams.each do |team|&lt;br /&gt;
        bid_info = bids_by_topic[topic_id].find { |bid| bid[:team] == team }&lt;br /&gt;
        priority_counts[bid_info[:priority]] += 1 if bid_info&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    priority_counts&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 3: calculate_percentages'''&lt;br /&gt;
&lt;br /&gt;
* This method calculates the percentages of teams that received their first, second, and third choice based on the counts of teams at each priority level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Calculates the percentages of teams that received their first, second, and third choice&lt;br /&gt;
  # based on the counts of teams at each priority level.&lt;br /&gt;
  def calculate_percentages(priority_counts, total_teams)&lt;br /&gt;
    priority_counts.transform_values { |count| (count.to_f / total_teams * 100).round(2) }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_each_topic.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:bidding_percentage.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt;Bidding Details for &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;!-- Displaying percentages in a more visually appealing way --&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;percentages&amp;quot; style=&amp;quot;margin-bottom: 20px; padding: 15px; border: 1px solid #ccc; border-radius: 5px; background-color: #f9f9f9;&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;h4 style=&amp;quot;margin-bottom: 15px; border-bottom: 1px solid #eee; padding-bottom: 10px;&amp;quot;&amp;gt;Percentage of Teams Getting Their Choices:&amp;lt;/h4&amp;gt;&lt;br /&gt;
  &amp;lt;ul style=&amp;quot;list-style: none; padding: 0;&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;#1 Choice:&amp;lt;/strong&amp;gt; &amp;lt;span style=&amp;quot;color: #4CAF50;&amp;quot;&amp;gt;&amp;lt;%= @percentages[1] || 0 %&amp;gt; %&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;#2 Choice:&amp;lt;/strong&amp;gt; &amp;lt;span style=&amp;quot;color: #FF9800;&amp;quot;&amp;gt;&amp;lt;%= @percentages[2] || 0 %&amp;gt; %&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;#3 Choice:&amp;lt;/strong&amp;gt; &amp;lt;span style=&amp;quot;color: #F44336;&amp;quot;&amp;gt;&amp;lt;%= @percentages[3] || 0 %&amp;gt; %&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;style&amp;gt;&lt;br /&gt;
.assigned-team {&lt;br /&gt;
  background-color: yellow; &lt;br /&gt;
  color: black;             &lt;br /&gt;
}&lt;br /&gt;
.bids-column {&lt;br /&gt;
    width: 100px; /* Adjust width as needed */&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/style&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table class=&amp;quot;table table-bordered table-hover&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;thead&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic Name&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic ID&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Bidding Teams&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#1 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#2 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#3 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;/thead&amp;gt;&lt;br /&gt;
  &amp;lt;tbody&amp;gt;&lt;br /&gt;
    &amp;lt;% @topics.each do |topic| %&amp;gt;&lt;br /&gt;
      &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.topic_name %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.id %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&lt;br /&gt;
          &amp;lt;% @bids_by_topic[topic.id].each do |bid_info| %&amp;gt;&lt;br /&gt;
            &amp;lt;% team = bid_info[:team] %&amp;gt;&lt;br /&gt;
            &amp;lt;% assigned_team = @assigned_teams_by_topic[topic.id].include?(team) %&amp;gt;&lt;br /&gt;
            &amp;lt;span class=&amp;quot;&amp;lt;%= assigned_team ? 'assigned-team' : '' %&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;%= team.name %&amp;gt; (#&amp;lt;%= bid_info[:priority] %&amp;gt;)&lt;br /&gt;
            &amp;lt;/span&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count1[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count1[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count2[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count2[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count3[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count3[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
      &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;% end %&amp;gt;&lt;br /&gt;
  &amp;lt;/tbody&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;javascript:history.back()&amp;quot;&amp;gt;Back&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
Added Rspec Testing &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_each_topic.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe '#bidding_table_for_each_topic' do&lt;br /&gt;
    before :each do&lt;br /&gt;
      # Set the assignment id in the params&lt;br /&gt;
      params = ActionController::Parameters.new(id: assignment.id)&lt;br /&gt;
      allow(controller).to receive(:params).and_return(params)&lt;br /&gt;
    end&lt;br /&gt;
    it 'populates bids and assigned teams for each topic, handling topics with no teams' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
      # Check if @bids_by_topic is populated correctly&lt;br /&gt;
      expect(controller.instance_variable_get(:@bids_by_topic)[topic1.id].length).to eq(1)&lt;br /&gt;
      expect(controller.instance_variable_get(:@bids_by_topic)[topic2.id].length).to eq(1)&lt;br /&gt;
      # Check if @assigned_teams_by_topic is populated correctly, allowing for no teams&lt;br /&gt;
      assigned_teams_topic1 = controller.instance_variable_get(:@assigned_teams_by_topic)[topic1.id]&lt;br /&gt;
      if assigned_teams_topic1&lt;br /&gt;
        expect(assigned_teams_topic1.length).to(satisfy { |value| (value == 0) || (value == 1) })&lt;br /&gt;
      else&lt;br /&gt;
        expect(assigned_teams_topic1).to be_nil&lt;br /&gt;
      end&lt;br /&gt;
      # Check the counts of bids for each priority level&lt;br /&gt;
      # Ensure to adjust these based on what is set up in your test data&lt;br /&gt;
      expect(controller.instance_variable_get(:@count1)[topic1.id]).to eq(1)&lt;br /&gt;
      # assuming there is one bid with priority 1 for topic1&lt;br /&gt;
      expect(controller.instance_variable_get(:@count2)[topic1.id]).to eq(0)&lt;br /&gt;
      # assuming there are no bids with priority 2 for topic1&lt;br /&gt;
      expect(controller.instance_variable_get(:@count3)[topic1.id]).to eq(0)&lt;br /&gt;
      # assuming there are no bids with priority 3 for topic1&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'fetches all topics for the assignment' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
      expect(controller.instance_variable_get(:@topics)).to match_array([topic1, topic2, topic3, topic4])&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'correctly calculates priority counts for each topic' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
      # Assuming you have a way to know the expected counts for each priority&lt;br /&gt;
      expected_priority_counts = { 1 =&amp;gt; 0, &lt;br /&gt;
                                   2 =&amp;gt; 0, &lt;br /&gt;
                                   3 =&amp;gt; 0 }&lt;br /&gt;
  &lt;br /&gt;
      priority_counts = controller.instance_variable_get(:@priority_counts)&lt;br /&gt;
      expect(priority_counts).to eq(expected_priority_counts)&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'correctly calculates percentages for teams getting their choices' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
      # Assuming you have a way to know the expected percentages&lt;br /&gt;
      expected_percentages = { 1 =&amp;gt; Float::NAN, &lt;br /&gt;
                               2 =&amp;gt; Float::NAN, &lt;br /&gt;
                               3 =&amp;gt; Float::NAN }&lt;br /&gt;
  &lt;br /&gt;
      percentages = controller.instance_variable_get(:@percentages)&lt;br /&gt;
      expect(percentages[1].nan?).to be true if expected_percentages[1].nan?&lt;br /&gt;
      expect(percentages[2].nan?).to be true if expected_percentages[2].nan?&lt;br /&gt;
      expect(percentages[3].nan?).to be true if expected_percentages[3].nan?&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
According to the given test skeleton and the features we've implemented and to be implemented. Here are the testing ideas:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Context 1: When There Are No Bids or Assigned Teams'''&lt;br /&gt;
&lt;br /&gt;
Test 1: Check if we get empty arrays for bids and assigned teams after running the &amp;quot;bidding_details&amp;quot; method.&lt;br /&gt;
&lt;br /&gt;
Test 2: Check if the percentage of teams getting their #1, #2, and #3 choices are all 0.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Context 2: When There Are Bids and Assigned Teams for the Assignment'''&lt;br /&gt;
&lt;br /&gt;
Test 3: We would first set up a known distribution of bids across different priority levels. After executing the &amp;quot;bidding_details&amp;quot; method, the test verifies that the returned count of bids for each priority level matches the expected distribution set up in the test environment.&lt;br /&gt;
&lt;br /&gt;
Test 4: Ensure that the method correctly identifies and returns the assigned teams for each topic. In this test, the setup would include an assignment with pre-assigned teams to various topics. The &amp;quot;bidding_details&amp;quot; method is then called, and the test checks whether the method accurately returns the list of assigned teams for each topic, as per the test setup.&lt;br /&gt;
&lt;br /&gt;
Test 5: Check if all teams bidding on a different topic, they all get the topic they want, and the percentage of #1 is 100%, while #2 and #3 are 0s.&lt;br /&gt;
&lt;br /&gt;
Test 6: Check if all teams bidding on the same topic, only one team gets the topic they want, and the percentage of #1 is (1/teams)%, while #2 and #3 are 0s.&lt;br /&gt;
&lt;br /&gt;
Test 7: Check if a team is a first/second/third team to bid on some topic, that topic is finally assigned to this team. In this case, #1, #2, or #3 is a non-zero value.&lt;br /&gt;
&lt;br /&gt;
Test 8: Provide mocking data and we pre-calculate the percentage value of #1, #2 and #3, check if the calculated values are the same as ours.&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
&lt;br /&gt;
'''Github Repository: ''' https://github.com/Shreshth-Malik/expertiza&lt;br /&gt;
&lt;br /&gt;
== Team == &lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Edward F. Gehringer (efg@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
'''Members'''&lt;br /&gt;
&lt;br /&gt;
Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shreshth Malik (smalik4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shuai Chen (schen76@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152755</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding (Phase2)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152755"/>
		<updated>2023-12-05T07:36:00Z</updated>

		<summary type="html">&lt;p&gt;Schen76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Motivation ==&lt;br /&gt;
&lt;br /&gt;
The bidding view is needed because we don’t have a way of finding out whether the bidding algorithm is running correctly.  This project is to add a bidding view to show how the topics are assigned to those teams who bid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Work Plan ==&lt;br /&gt;
&lt;br /&gt;
Based on the project's objectives and feedback received from our mentor, we have identified specific areas for improvement:&lt;br /&gt;
&lt;br /&gt;
1) Refactor variable names within methods such as &amp;quot;bidding_details&amp;quot; and variables like &amp;quot;Topic name&amp;quot; and &amp;quot;Bidding teams&amp;quot; to enhance clarity and specificity.&lt;br /&gt;
&lt;br /&gt;
2) Adjust capitalization for certain components, ensuring that only the first word is capitalized for consistency.&lt;br /&gt;
&lt;br /&gt;
3) Introduce calculations to determine percentages based on additional data, such as the total number of teams and the number of teams for each priority, within the &amp;quot;lottery_controller.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4) Conduct thorough testing of the modified controller and view to ensure optimal functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Newfeature.jpg | 888px]]&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
To add functionality for showing the percentages of the number of teams that got their #1, #2, and #3 choices. We can follow these high-level steps:&lt;br /&gt;
&lt;br /&gt;
'''Lottery_Controller:'''&lt;br /&gt;
&lt;br /&gt;
i) Calculate the Total Number of Teams: Before we can calculate percentages, we need to know the total number of teams that participated in the bidding process. This will be our denominator in the percentage calculation.&lt;br /&gt;
&lt;br /&gt;
ii) Calculate the Number of Teams for Each Priority: From our `bidding_details` method, we already have counts for how many teams bid on each topic as their #1, #2, and #3 choice (`@count1`, `@count2`, `@count3`). However, these counts are currently organized by topic. We would need to modify this to count how many teams got their #1, #2, and #3 choices as their assigned topic.&lt;br /&gt;
&lt;br /&gt;
iii) Calculate Percentages: Once we have the number of teams that got their #1, #2, and #3 choices, we can calculate the percentages by dividing these numbers by the total number of teams and multiplying by 100.&lt;br /&gt;
&lt;br /&gt;
'''Bidding_detail view:'''&lt;br /&gt;
&lt;br /&gt;
i) Update the View and Display Percentages: Above the table in our previous view, we can add a section to display these percentages.&lt;br /&gt;
&lt;br /&gt;
ii) Format the Display: We will use a bold heading for each percentage type and format the number to a fixed number of decimal places.&lt;br /&gt;
&lt;br /&gt;
iii) Ensure Responsiveness: Make sure the display of these percentages adjusts well to different screen sizes, maintaining readability and layout consistency. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code Effort ==&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; app/controllers/lottery_controller.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 1: bidding_table_for_each_topic'''&lt;br /&gt;
&lt;br /&gt;
This method generates a bidding table for each topic within an assignment. It performs several operations to gather and organize data related to topics, bids, and teams. Here's a breakdown of what the code does:&lt;br /&gt;
&lt;br /&gt;
1. Fetch Assignment:&lt;br /&gt;
&lt;br /&gt;
*It retrieves the assignment with the specified params[:id] from the database and stores it in the @assignment instance variable.&lt;br /&gt;
&lt;br /&gt;
2. Fetch Topics:&lt;br /&gt;
&lt;br /&gt;
*It retrieves all sign-up topics associated with the assignment and stores them in the @topics instance variable.&lt;br /&gt;
&lt;br /&gt;
3. Fetch Bids and Assigned Teams:&lt;br /&gt;
&lt;br /&gt;
For each topic in @topics, it:&lt;br /&gt;
*Retrieves all bids associated with that topic and stores them in a hash, where the key is the topic's ID and the value is an array of bids with their associated teams and priorities.&lt;br /&gt;
*Retrieves teams that are not waitlisted for the topic and stores them in a hash, again using the topic's ID as the key and an array of teams as the value.&lt;br /&gt;
&lt;br /&gt;
4. Priority Count Calculation:&lt;br /&gt;
&lt;br /&gt;
*It dynamically calculates and updates the counts for each bid priority level (1, 2, and 3) for each topic. These counts are stored in instance variables named @count1, @count2, and @count3. These instance variables are hashes where the keys are topic IDs, and the values are counts for each priority level.&lt;br /&gt;
&lt;br /&gt;
5. Calculate Total Teams:&lt;br /&gt;
&lt;br /&gt;
*It determines the total number of teams across all topics in the assignment by counting distinct team IDs among all non-waitlisted teams for the specified topics.&lt;br /&gt;
&lt;br /&gt;
6. Calculate Priority Counts and Percentages:&lt;br /&gt;
&lt;br /&gt;
*It calls two helper methods, calculate_priority_counts and calculate_percentages, to calculate the total counts of teams at each priority level and the corresponding percentages. The results are stored in the @priority_counts and @percentages instance variables, respectively.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Prepares data for displaying the bidding details for each topic within an assignment.&lt;br /&gt;
  # It calculates the number of bids for each priority (1, 2, 3) per topic and also computes&lt;br /&gt;
  # the overall percentages of teams that received their first, second, and third choice.&lt;br /&gt;
  def bidding_table_for_each_topic&lt;br /&gt;
    @assignment = Assignment.find(params[:id])&lt;br /&gt;
    # Fetch all topics for the assignment&lt;br /&gt;
    @topics = @assignment.sign_up_topics&lt;br /&gt;
    # Fetch all bids for these topics&lt;br /&gt;
    @bids_by_topic = {}&lt;br /&gt;
    @assigned_teams_by_topic = {} # This will store the assigned teams for each topic&lt;br /&gt;
    @topics.each do |topic|&lt;br /&gt;
      # Assuming bids are stored with a topic_id, and each bid has a team associated with it&lt;br /&gt;
      @bids_by_topic[topic.id] = Bid.where(topic_id: topic.id).map { |bid| { team: bid.team, priority: bid.priority } }&lt;br /&gt;
      # Fetch teams that are not waitlisted for this topic&lt;br /&gt;
      @assigned_teams_by_topic[topic.id] = SignedUpTeam.where(topic_id: topic.id, is_waitlisted: false).map(&amp;amp;:team)&lt;br /&gt;
      # @count1[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 1 }&lt;br /&gt;
      # @count2[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 2 }&lt;br /&gt;
      # @count3[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 3 }       &lt;br /&gt;
&lt;br /&gt;
      # Dynamically initializing and updating @count1, @count2, and @count3&lt;br /&gt;
      (1..3).each do |priority|&lt;br /&gt;
        instance_variable_set(&amp;quot;@count#{priority}&amp;quot;, Hash.new(0)) unless instance_variable_defined?(&amp;quot;@count#{priority}&amp;quot;)&lt;br /&gt;
        instance_variable_get(&amp;quot;@count#{priority}&amp;quot;)[topic.id] = @bids_by_topic[topic.id].count { |bid| bid[:priority] == priority }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # Calculate the total number of teams and percentages after fetching bid details&lt;br /&gt;
    topic_ids = SignUpTopic.where(assignment_id: @assignment.id).pluck(:id)&lt;br /&gt;
    @total_teams = SignedUpTeam.where(topic_id: topic_ids).distinct.count(:team_id)&lt;br /&gt;
    @priority_counts = calculate_priority_counts(@assigned_teams_by_topic, @bids_by_topic)&lt;br /&gt;
    @percentages = calculate_percentages(@priority_counts, @total_teams)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 2: calculate_priority_counts'''&lt;br /&gt;
&lt;br /&gt;
1. Parameters&lt;br /&gt;
*assigned_teams_by_topic (Hash): A hash mapping each topic to an array of assigned teams.&lt;br /&gt;
*bids_by_topic (Hash): A hash mapping each topic to an array of bid objects, where each bid object is a hash containing team and priority information.&lt;br /&gt;
&lt;br /&gt;
2. Functionality&lt;br /&gt;
*Initial Setup: Initializes a hash priority_counts with keys 1, 2, and 3, each having an initial value of 0. These keys represent the priority levels, and their values count the number of teams assigned to each level.&lt;br /&gt;
&lt;br /&gt;
*Iterating Over Topics and Teams: Iterates over each topic and its associated teams found in assigned_teams_by_topic. For each team in a topic, the method searches bids_by_topic[topic_id] to find a bid made by the team.&lt;br /&gt;
&lt;br /&gt;
*Updating Priority Counts: If a bid is found, the method increments the count in priority_counts corresponding to the priority level in the bid. This process effectively tallies the number of teams assigned to each priority level.&lt;br /&gt;
&lt;br /&gt;
3. Returns&lt;br /&gt;
*priority_counts (Hash): A hash with keys 1, 2, and 3, where each key's value represents the count of teams assigned to that respective priority level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Calculates the count of assigned teams for each priority level (1, 2, 3) across all topics.&lt;br /&gt;
  # It checks each team associated with a topic and determines if the team's bid matches&lt;br /&gt;
  # one of the priority levels, incrementing the respective count if so.&lt;br /&gt;
  def calculate_priority_counts(assigned_teams_by_topic, bids_by_topic)&lt;br /&gt;
    priority_counts = { 1 =&amp;gt; 0, 2 =&amp;gt; 0, 3 =&amp;gt; 0 }&lt;br /&gt;
    assigned_teams_by_topic.each do |topic_id, teams|&lt;br /&gt;
      teams.each do |team|&lt;br /&gt;
        bid_info = bids_by_topic[topic_id].find { |bid| bid[:team] == team }&lt;br /&gt;
        priority_counts[bid_info[:priority]] += 1 if bid_info&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    priority_counts&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 3: calculate_percentages'''&lt;br /&gt;
&lt;br /&gt;
* This method calculates the percentages of teams that received their first, second, and third choice based on the counts of teams at each priority level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Calculates the percentages of teams that received their first, second, and third choice&lt;br /&gt;
  # based on the counts of teams at each priority level.&lt;br /&gt;
  def calculate_percentages(priority_counts, total_teams)&lt;br /&gt;
    priority_counts.transform_values { |count| (count.to_f / total_teams * 100).round(2) }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_each_topic.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:bidding_percentage.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt;Bidding Details for &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;!-- Displaying percentages in a more visually appealing way --&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;percentages&amp;quot; style=&amp;quot;margin-bottom: 20px; padding: 15px; border: 1px solid #ccc; border-radius: 5px; background-color: #f9f9f9;&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;h4 style=&amp;quot;margin-bottom: 15px; border-bottom: 1px solid #eee; padding-bottom: 10px;&amp;quot;&amp;gt;Percentage of Teams Getting Their Choices:&amp;lt;/h4&amp;gt;&lt;br /&gt;
  &amp;lt;ul style=&amp;quot;list-style: none; padding: 0;&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;#1 Choice:&amp;lt;/strong&amp;gt; &amp;lt;span style=&amp;quot;color: #4CAF50;&amp;quot;&amp;gt;&amp;lt;%= @percentages[1] || 0 %&amp;gt; %&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;#2 Choice:&amp;lt;/strong&amp;gt; &amp;lt;span style=&amp;quot;color: #FF9800;&amp;quot;&amp;gt;&amp;lt;%= @percentages[2] || 0 %&amp;gt; %&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;#3 Choice:&amp;lt;/strong&amp;gt; &amp;lt;span style=&amp;quot;color: #F44336;&amp;quot;&amp;gt;&amp;lt;%= @percentages[3] || 0 %&amp;gt; %&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;style&amp;gt;&lt;br /&gt;
.assigned-team {&lt;br /&gt;
  background-color: yellow; &lt;br /&gt;
  color: black;             &lt;br /&gt;
}&lt;br /&gt;
.bids-column {&lt;br /&gt;
    width: 100px; /* Adjust width as needed */&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/style&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table class=&amp;quot;table table-bordered table-hover&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;thead&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic Name&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic ID&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Bidding Teams&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#1 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#2 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#3 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;/thead&amp;gt;&lt;br /&gt;
  &amp;lt;tbody&amp;gt;&lt;br /&gt;
    &amp;lt;% @topics.each do |topic| %&amp;gt;&lt;br /&gt;
      &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.topic_name %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.id %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&lt;br /&gt;
          &amp;lt;% @bids_by_topic[topic.id].each do |bid_info| %&amp;gt;&lt;br /&gt;
            &amp;lt;% team = bid_info[:team] %&amp;gt;&lt;br /&gt;
            &amp;lt;% assigned_team = @assigned_teams_by_topic[topic.id].include?(team) %&amp;gt;&lt;br /&gt;
            &amp;lt;span class=&amp;quot;&amp;lt;%= assigned_team ? 'assigned-team' : '' %&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;%= team.name %&amp;gt; (#&amp;lt;%= bid_info[:priority] %&amp;gt;)&lt;br /&gt;
            &amp;lt;/span&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count1[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count1[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count2[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count2[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count3[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count3[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
      &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;% end %&amp;gt;&lt;br /&gt;
  &amp;lt;/tbody&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;javascript:history.back()&amp;quot;&amp;gt;Back&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
Added Rspec Testing &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_each_topic.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe '#bidding_table_for_each_topic' do&lt;br /&gt;
    before :each do&lt;br /&gt;
      # Set the assignment id in the params&lt;br /&gt;
      params = ActionController::Parameters.new(id: assignment.id)&lt;br /&gt;
      allow(controller).to receive(:params).and_return(params)&lt;br /&gt;
    end&lt;br /&gt;
    it 'populates bids and assigned teams for each topic, handling topics with no teams' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
      # Check if @bids_by_topic is populated correctly&lt;br /&gt;
      expect(controller.instance_variable_get(:@bids_by_topic)[topic1.id].length).to eq(1)&lt;br /&gt;
      expect(controller.instance_variable_get(:@bids_by_topic)[topic2.id].length).to eq(1)&lt;br /&gt;
      # Check if @assigned_teams_by_topic is populated correctly, allowing for no teams&lt;br /&gt;
      assigned_teams_topic1 = controller.instance_variable_get(:@assigned_teams_by_topic)[topic1.id]&lt;br /&gt;
      if assigned_teams_topic1&lt;br /&gt;
        expect(assigned_teams_topic1.length).to(satisfy { |value| (value == 0) || (value == 1) })&lt;br /&gt;
      else&lt;br /&gt;
        expect(assigned_teams_topic1).to be_nil&lt;br /&gt;
      end&lt;br /&gt;
      # Check the counts of bids for each priority level&lt;br /&gt;
      # Ensure to adjust these based on what is set up in your test data&lt;br /&gt;
      expect(controller.instance_variable_get(:@count1)[topic1.id]).to eq(1)&lt;br /&gt;
      # assuming there is one bid with priority 1 for topic1&lt;br /&gt;
      expect(controller.instance_variable_get(:@count2)[topic1.id]).to eq(0)&lt;br /&gt;
      # assuming there are no bids with priority 2 for topic1&lt;br /&gt;
      expect(controller.instance_variable_get(:@count3)[topic1.id]).to eq(0)&lt;br /&gt;
      # assuming there are no bids with priority 3 for topic1&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'fetches all topics for the assignment' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
      expect(controller.instance_variable_get(:@topics)).to match_array([topic1, topic2, topic3, topic4])&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'correctly calculates priority counts for each topic' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
      # Assuming you have a way to know the expected counts for each priority&lt;br /&gt;
      expected_priority_counts = { 1 =&amp;gt; 0, &lt;br /&gt;
                                   2 =&amp;gt; 0, &lt;br /&gt;
                                   3 =&amp;gt; 0 }&lt;br /&gt;
  &lt;br /&gt;
      priority_counts = controller.instance_variable_get(:@priority_counts)&lt;br /&gt;
      expect(priority_counts).to eq(expected_priority_counts)&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'correctly calculates percentages for teams getting their choices' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
      # Assuming you have a way to know the expected percentages&lt;br /&gt;
      expected_percentages = { 1 =&amp;gt; Float::NAN, &lt;br /&gt;
                               2 =&amp;gt; Float::NAN, &lt;br /&gt;
                               3 =&amp;gt; Float::NAN }&lt;br /&gt;
  &lt;br /&gt;
      percentages = controller.instance_variable_get(:@percentages)&lt;br /&gt;
      expect(percentages[1].nan?).to be true if expected_percentages[1].nan?&lt;br /&gt;
      expect(percentages[2].nan?).to be true if expected_percentages[2].nan?&lt;br /&gt;
      expect(percentages[3].nan?).to be true if expected_percentages[3].nan?&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
According to the given test skeleton and the features we've implemented and to be implemented. Here are the testing ideas:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Context 1: When There Are No Bids or Assigned Teams'''&lt;br /&gt;
&lt;br /&gt;
Test 1: Check if we get empty arrays for bids and assigned teams after running the &amp;quot;bidding_details&amp;quot; method.&lt;br /&gt;
&lt;br /&gt;
Test 2: Check if the percentage of teams getting their #1, #2, and #3 choices are all 0.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Context 2: When There Are Bids and Assigned Teams for the Assignment'''&lt;br /&gt;
&lt;br /&gt;
Test 3: We would first set up a known distribution of bids across different priority levels. After executing the &amp;quot;bidding_details&amp;quot; method, the test verifies that the returned count of bids for each priority level matches the expected distribution set up in the test environment.&lt;br /&gt;
&lt;br /&gt;
Test 4: Ensure that the method correctly identifies and returns the assigned teams for each topic. In this test, the setup would include an assignment with pre-assigned teams to various topics. The &amp;quot;bidding_details&amp;quot; method is then called, and the test checks whether the method accurately returns the list of assigned teams for each topic, as per the test setup.&lt;br /&gt;
&lt;br /&gt;
Test 5: Check if all teams bidding on a different topic, they all get the topic they want, and the percentage of #1 is 100%, while #2 and #3 are 0s.&lt;br /&gt;
&lt;br /&gt;
Test 6: Check if all teams bidding on the same topic, only one team gets the topic they want, and the percentage of #1 is (1/teams)%, while #2 and #3 are 0s.&lt;br /&gt;
&lt;br /&gt;
Test 7: Check if a team is a first/second/third team to bid on some topic, that topic is finally assigned to this team. In this case, #1, #2, or #3 is a non-zero value.&lt;br /&gt;
&lt;br /&gt;
Test 8: Provide mocking data and we pre-calculate the percentage value of #1, #2 and #3, check if the calculated values are the same as ours.&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
&lt;br /&gt;
'''Github Repository: ''' https://github.com/Shreshth-Malik/expertiza&lt;br /&gt;
&lt;br /&gt;
== Team == &lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Edward F. Gehringer (efg ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
'''Members'''&lt;br /&gt;
&lt;br /&gt;
Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shreshth Malik (smalik4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shuai Chen (schen76@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152754</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding (Phase2)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152754"/>
		<updated>2023-12-05T07:33:54Z</updated>

		<summary type="html">&lt;p&gt;Schen76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Motivation ==&lt;br /&gt;
&lt;br /&gt;
The bidding view is needed because we don’t have a way of finding out whether the bidding algorithm is running correctly.  This project is to add a bidding view to show how the topics are assigned to those teams who bid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Work Plan ==&lt;br /&gt;
&lt;br /&gt;
Based on the project's objectives and feedback received from our mentor, we have identified specific areas for improvement:&lt;br /&gt;
&lt;br /&gt;
1) Refactor variable names within methods such as &amp;quot;bidding_details&amp;quot; and variables like &amp;quot;Topic name&amp;quot; and &amp;quot;Bidding teams&amp;quot; to enhance clarity and specificity.&lt;br /&gt;
&lt;br /&gt;
2) Adjust capitalization for certain components, ensuring that only the first word is capitalized for consistency.&lt;br /&gt;
&lt;br /&gt;
3) Introduce calculations to determine percentages based on additional data, such as the total number of teams and the number of teams for each priority, within the &amp;quot;lottery_controller.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4) Conduct thorough testing of the modified controller and view to ensure optimal functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Newfeature.jpg | 888px]]&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
To add functionality for showing the percentages of the number of teams that got their #1, #2, and #3 choices. We can follow these high-level steps:&lt;br /&gt;
&lt;br /&gt;
'''Lottery_Controller:'''&lt;br /&gt;
&lt;br /&gt;
i) Calculate the Total Number of Teams: Before we can calculate percentages, we need to know the total number of teams that participated in the bidding process. This will be our denominator in the percentage calculation.&lt;br /&gt;
&lt;br /&gt;
ii) Calculate the Number of Teams for Each Priority: From our `bidding_details` method, we already have counts for how many teams bid on each topic as their #1, #2, and #3 choice (`@count1`, `@count2`, `@count3`). However, these counts are currently organized by topic. We would need to modify this to count how many teams got their #1, #2, and #3 choices as their assigned topic.&lt;br /&gt;
&lt;br /&gt;
iii) Calculate Percentages: Once we have the number of teams that got their #1, #2, and #3 choices, we can calculate the percentages by dividing these numbers by the total number of teams and multiplying by 100.&lt;br /&gt;
&lt;br /&gt;
'''Bidding_detail view:'''&lt;br /&gt;
&lt;br /&gt;
i) Update the View and Display Percentages: Above the table in our previous view, we can add a section to display these percentages.&lt;br /&gt;
&lt;br /&gt;
ii) Format the Display: We will use a bold heading for each percentage type and format the number to a fixed number of decimal places.&lt;br /&gt;
&lt;br /&gt;
iii) Ensure Responsiveness: Make sure the display of these percentages adjusts well to different screen sizes, maintaining readability and layout consistency. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code Effort ==&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; app/controllers/lottery_controller.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 1: bidding_table_for_each_topic'''&lt;br /&gt;
&lt;br /&gt;
This method generates a bidding table for each topic within an assignment. It performs several operations to gather and organize data related to topics, bids, and teams. Here's a breakdown of what the code does:&lt;br /&gt;
&lt;br /&gt;
1. Fetch Assignment:&lt;br /&gt;
&lt;br /&gt;
*It retrieves the assignment with the specified params[:id] from the database and stores it in the @assignment instance variable.&lt;br /&gt;
&lt;br /&gt;
2. Fetch Topics:&lt;br /&gt;
&lt;br /&gt;
*It retrieves all sign-up topics associated with the assignment and stores them in the @topics instance variable.&lt;br /&gt;
&lt;br /&gt;
3. Fetch Bids and Assigned Teams:&lt;br /&gt;
&lt;br /&gt;
For each topic in @topics, it:&lt;br /&gt;
*Retrieves all bids associated with that topic and stores them in a hash, where the key is the topic's ID and the value is an array of bids with their associated teams and priorities.&lt;br /&gt;
*Retrieves teams that are not waitlisted for the topic and stores them in a hash, again using the topic's ID as the key and an array of teams as the value.&lt;br /&gt;
&lt;br /&gt;
4. Priority Count Calculation:&lt;br /&gt;
&lt;br /&gt;
*It dynamically calculates and updates the counts for each bid priority level (1, 2, and 3) for each topic. These counts are stored in instance variables named @count1, @count2, and @count3. These instance variables are hashes where the keys are topic IDs, and the values are counts for each priority level.&lt;br /&gt;
&lt;br /&gt;
5. Calculate Total Teams:&lt;br /&gt;
&lt;br /&gt;
*It determines the total number of teams across all topics in the assignment by counting distinct team IDs among all non-waitlisted teams for the specified topics.&lt;br /&gt;
&lt;br /&gt;
6. Calculate Priority Counts and Percentages:&lt;br /&gt;
&lt;br /&gt;
*It calls two helper methods, calculate_priority_counts and calculate_percentages, to calculate the total counts of teams at each priority level and the corresponding percentages. The results are stored in the @priority_counts and @percentages instance variables, respectively.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Prepares data for displaying the bidding details for each topic within an assignment.&lt;br /&gt;
  # It calculates the number of bids for each priority (1, 2, 3) per topic and also computes&lt;br /&gt;
  # the overall percentages of teams that received their first, second, and third choice.&lt;br /&gt;
  def bidding_table_for_each_topic&lt;br /&gt;
    @assignment = Assignment.find(params[:id])&lt;br /&gt;
    # Fetch all topics for the assignment&lt;br /&gt;
    @topics = @assignment.sign_up_topics&lt;br /&gt;
    # Fetch all bids for these topics&lt;br /&gt;
    @bids_by_topic = {}&lt;br /&gt;
    @assigned_teams_by_topic = {} # This will store the assigned teams for each topic&lt;br /&gt;
    @topics.each do |topic|&lt;br /&gt;
      # Assuming bids are stored with a topic_id, and each bid has a team associated with it&lt;br /&gt;
      @bids_by_topic[topic.id] = Bid.where(topic_id: topic.id).map { |bid| { team: bid.team, priority: bid.priority } }&lt;br /&gt;
      # Fetch teams that are not waitlisted for this topic&lt;br /&gt;
      @assigned_teams_by_topic[topic.id] = SignedUpTeam.where(topic_id: topic.id, is_waitlisted: false).map(&amp;amp;:team)&lt;br /&gt;
      # @count1[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 1 }&lt;br /&gt;
      # @count2[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 2 }&lt;br /&gt;
      # @count3[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 3 }       &lt;br /&gt;
&lt;br /&gt;
      # Dynamically initializing and updating @count1, @count2, and @count3&lt;br /&gt;
      (1..3).each do |priority|&lt;br /&gt;
        instance_variable_set(&amp;quot;@count#{priority}&amp;quot;, Hash.new(0)) unless instance_variable_defined?(&amp;quot;@count#{priority}&amp;quot;)&lt;br /&gt;
        instance_variable_get(&amp;quot;@count#{priority}&amp;quot;)[topic.id] = @bids_by_topic[topic.id].count { |bid| bid[:priority] == priority }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # Calculate the total number of teams and percentages after fetching bid details&lt;br /&gt;
    topic_ids = SignUpTopic.where(assignment_id: @assignment.id).pluck(:id)&lt;br /&gt;
    @total_teams = SignedUpTeam.where(topic_id: topic_ids).distinct.count(:team_id)&lt;br /&gt;
    @priority_counts = calculate_priority_counts(@assigned_teams_by_topic, @bids_by_topic)&lt;br /&gt;
    @percentages = calculate_percentages(@priority_counts, @total_teams)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 2: calculate_priority_counts'''&lt;br /&gt;
&lt;br /&gt;
1. Parameters&lt;br /&gt;
*assigned_teams_by_topic (Hash): A hash mapping each topic to an array of assigned teams.&lt;br /&gt;
*bids_by_topic (Hash): A hash mapping each topic to an array of bid objects, where each bid object is a hash containing team and priority information.&lt;br /&gt;
&lt;br /&gt;
2. Functionality&lt;br /&gt;
*Initial Setup: Initializes a hash priority_counts with keys 1, 2, and 3, each having an initial value of 0. These keys represent the priority levels, and their values count the number of teams assigned to each level.&lt;br /&gt;
&lt;br /&gt;
*Iterating Over Topics and Teams: Iterates over each topic and its associated teams found in assigned_teams_by_topic. For each team in a topic, the method searches bids_by_topic[topic_id] to find a bid made by the team.&lt;br /&gt;
&lt;br /&gt;
*Updating Priority Counts: If a bid is found, the method increments the count in priority_counts corresponding to the priority level in the bid. This process effectively tallies the number of teams assigned to each priority level.&lt;br /&gt;
&lt;br /&gt;
3. Returns&lt;br /&gt;
*priority_counts (Hash): A hash with keys 1, 2, and 3, where each key's value represents the count of teams assigned to that respective priority level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Calculates the count of assigned teams for each priority level (1, 2, 3) across all topics.&lt;br /&gt;
  # It checks each team associated with a topic and determines if the team's bid matches&lt;br /&gt;
  # one of the priority levels, incrementing the respective count if so.&lt;br /&gt;
  def calculate_priority_counts(assigned_teams_by_topic, bids_by_topic)&lt;br /&gt;
    priority_counts = { 1 =&amp;gt; 0, 2 =&amp;gt; 0, 3 =&amp;gt; 0 }&lt;br /&gt;
    assigned_teams_by_topic.each do |topic_id, teams|&lt;br /&gt;
      teams.each do |team|&lt;br /&gt;
        bid_info = bids_by_topic[topic_id].find { |bid| bid[:team] == team }&lt;br /&gt;
        priority_counts[bid_info[:priority]] += 1 if bid_info&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    priority_counts&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''method 3: calculate_percentages'''&lt;br /&gt;
&lt;br /&gt;
* This method calculates the percentages of teams that received their first, second, and third choice based on the counts of teams at each priority level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Calculates the percentages of teams that received their first, second, and third choice&lt;br /&gt;
  # based on the counts of teams at each priority level.&lt;br /&gt;
  def calculate_percentages(priority_counts, total_teams)&lt;br /&gt;
    priority_counts.transform_values { |count| (count.to_f / total_teams * 100).round(2) }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_each_topic.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:bidding_percentage.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt;Bidding Details for &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;!-- Displaying percentages in a more visually appealing way --&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;percentages&amp;quot; style=&amp;quot;margin-bottom: 20px; padding: 15px; border: 1px solid #ccc; border-radius: 5px; background-color: #f9f9f9;&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;h4 style=&amp;quot;margin-bottom: 15px; border-bottom: 1px solid #eee; padding-bottom: 10px;&amp;quot;&amp;gt;Percentage of Teams Getting Their Choices:&amp;lt;/h4&amp;gt;&lt;br /&gt;
  &amp;lt;ul style=&amp;quot;list-style: none; padding: 0;&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;#1 Choice:&amp;lt;/strong&amp;gt; &amp;lt;span style=&amp;quot;color: #4CAF50;&amp;quot;&amp;gt;&amp;lt;%= @percentages[1] || 0 %&amp;gt; %&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;#2 Choice:&amp;lt;/strong&amp;gt; &amp;lt;span style=&amp;quot;color: #FF9800;&amp;quot;&amp;gt;&amp;lt;%= @percentages[2] || 0 %&amp;gt; %&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;#3 Choice:&amp;lt;/strong&amp;gt; &amp;lt;span style=&amp;quot;color: #F44336;&amp;quot;&amp;gt;&amp;lt;%= @percentages[3] || 0 %&amp;gt; %&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;style&amp;gt;&lt;br /&gt;
.assigned-team {&lt;br /&gt;
  background-color: yellow; &lt;br /&gt;
  color: black;             &lt;br /&gt;
}&lt;br /&gt;
.bids-column {&lt;br /&gt;
    width: 100px; /* Adjust width as needed */&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/style&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table class=&amp;quot;table table-bordered table-hover&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;thead&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic Name&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic ID&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Bidding Teams&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#1 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#2 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#3 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;/thead&amp;gt;&lt;br /&gt;
  &amp;lt;tbody&amp;gt;&lt;br /&gt;
    &amp;lt;% @topics.each do |topic| %&amp;gt;&lt;br /&gt;
      &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.topic_name %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.id %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&lt;br /&gt;
          &amp;lt;% @bids_by_topic[topic.id].each do |bid_info| %&amp;gt;&lt;br /&gt;
            &amp;lt;% team = bid_info[:team] %&amp;gt;&lt;br /&gt;
            &amp;lt;% assigned_team = @assigned_teams_by_topic[topic.id].include?(team) %&amp;gt;&lt;br /&gt;
            &amp;lt;span class=&amp;quot;&amp;lt;%= assigned_team ? 'assigned-team' : '' %&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;%= team.name %&amp;gt; (#&amp;lt;%= bid_info[:priority] %&amp;gt;)&lt;br /&gt;
            &amp;lt;/span&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count1[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count1[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count2[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count2[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count3[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count3[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
      &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;% end %&amp;gt;&lt;br /&gt;
  &amp;lt;/tbody&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;javascript:history.back()&amp;quot;&amp;gt;Back&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Added Rspec Testing &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_each_topic.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe '#bidding_table_for_each_topic' do&lt;br /&gt;
    before :each do&lt;br /&gt;
      # Set the assignment id in the params&lt;br /&gt;
      params = ActionController::Parameters.new(id: assignment.id)&lt;br /&gt;
      allow(controller).to receive(:params).and_return(params)&lt;br /&gt;
    end&lt;br /&gt;
    it 'populates bids and assigned teams for each topic, handling topics with no teams' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
      # Check if @bids_by_topic is populated correctly&lt;br /&gt;
      expect(controller.instance_variable_get(:@bids_by_topic)[topic1.id].length).to eq(1)&lt;br /&gt;
      expect(controller.instance_variable_get(:@bids_by_topic)[topic2.id].length).to eq(1)&lt;br /&gt;
      # Check if @assigned_teams_by_topic is populated correctly, allowing for no teams&lt;br /&gt;
      assigned_teams_topic1 = controller.instance_variable_get(:@assigned_teams_by_topic)[topic1.id]&lt;br /&gt;
      if assigned_teams_topic1&lt;br /&gt;
        expect(assigned_teams_topic1.length).to(satisfy { |value| (value == 0) || (value == 1) })&lt;br /&gt;
      else&lt;br /&gt;
        expect(assigned_teams_topic1).to be_nil&lt;br /&gt;
      end&lt;br /&gt;
      # Check the counts of bids for each priority level&lt;br /&gt;
      # Ensure to adjust these based on what is set up in your test data&lt;br /&gt;
      expect(controller.instance_variable_get(:@count1)[topic1.id]).to eq(1) # assuming there is one bid with priority 1 for topic1&lt;br /&gt;
      expect(controller.instance_variable_get(:@count2)[topic1.id]).to eq(0) # assuming there are no bids with priority 2 for topic1&lt;br /&gt;
      expect(controller.instance_variable_get(:@count3)[topic1.id]).to eq(0) # assuming there are no bids with priority 3 for topic1&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'fetches all topics for the assignment' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
      expect(controller.instance_variable_get(:@topics)).to match_array([topic1, topic2, topic3, topic4])&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'correctly calculates priority counts for each topic' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
      # Assuming you have a way to know the expected counts for each priority&lt;br /&gt;
      expected_priority_counts = { 1 =&amp;gt; 0, &lt;br /&gt;
                                   2 =&amp;gt; 0, &lt;br /&gt;
                                   3 =&amp;gt; 0 }&lt;br /&gt;
  &lt;br /&gt;
      priority_counts = controller.instance_variable_get(:@priority_counts)&lt;br /&gt;
      expect(priority_counts).to eq(expected_priority_counts)&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'correctly calculates percentages for teams getting their choices' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
      # Assuming you have a way to know the expected percentages&lt;br /&gt;
      expected_percentages = { 1 =&amp;gt; Float::NAN, &lt;br /&gt;
                               2 =&amp;gt; Float::NAN, &lt;br /&gt;
                               3 =&amp;gt; Float::NAN }&lt;br /&gt;
  &lt;br /&gt;
      percentages = controller.instance_variable_get(:@percentages)&lt;br /&gt;
      expect(percentages[1].nan?).to be true if expected_percentages[1].nan?&lt;br /&gt;
      expect(percentages[2].nan?).to be true if expected_percentages[2].nan?&lt;br /&gt;
      expect(percentages[3].nan?).to be true if expected_percentages[3].nan?&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
According to the given test skeleton and the features we've implemented and to be implemented. Here are the testing ideas:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Context 1: When There Are No Bids or Assigned Teams'''&lt;br /&gt;
&lt;br /&gt;
Test 1: Check if we get empty arrays for bids and assigned teams after running the &amp;quot;bidding_details&amp;quot; method.&lt;br /&gt;
&lt;br /&gt;
Test 2: Check if the percentage of teams getting their #1, #2, and #3 choices are all 0.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Context 2: When There Are Bids and Assigned Teams for the Assignment'''&lt;br /&gt;
&lt;br /&gt;
Test 3: We would first set up a known distribution of bids across different priority levels. After executing the &amp;quot;bidding_details&amp;quot; method, the test verifies that the returned count of bids for each priority level matches the expected distribution set up in the test environment.&lt;br /&gt;
&lt;br /&gt;
Test 4: Ensure that the method correctly identifies and returns the assigned teams for each topic. In this test, the setup would include an assignment with pre-assigned teams to various topics. The &amp;quot;bidding_details&amp;quot; method is then called, and the test checks whether the method accurately returns the list of assigned teams for each topic, as per the test setup.&lt;br /&gt;
&lt;br /&gt;
Test 5: Check if all teams bidding on a different topic, they all get the topic they want, and the percentage of #1 is 100%, while #2 and #3 are 0s.&lt;br /&gt;
&lt;br /&gt;
Test 6: Check if all teams bidding on the same topic, only one team gets the topic they want, and the percentage of #1 is (1/teams)%, while #2 and #3 are 0s.&lt;br /&gt;
&lt;br /&gt;
Test 7: Check if a team is a first/second/third team to bid on some topic, that topic is finally assigned to this team. In this case, #1, #2, or #3 is a non-zero value.&lt;br /&gt;
&lt;br /&gt;
Test 8: Provide mocking data and we pre-calculate the percentage value of #1, #2 and #3, check if the calculated values are the same as ours.&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
&lt;br /&gt;
'''Github Repository: ''' https://github.com/Shreshth-Malik/expertiza&lt;br /&gt;
&lt;br /&gt;
== Team == &lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Edward F. Gehringer (efg ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
'''Members'''&lt;br /&gt;
&lt;br /&gt;
Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shreshth Malik (smalik4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shuai Chen (schen76@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Bidding_percentage.png&amp;diff=152753</id>
		<title>File:Bidding percentage.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Bidding_percentage.png&amp;diff=152753"/>
		<updated>2023-12-05T07:33:26Z</updated>

		<summary type="html">&lt;p&gt;Schen76: Schen76 uploaded a new version of File:Bidding percentage.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Bidding_percentage.png&amp;diff=152752</id>
		<title>File:Bidding percentage.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Bidding_percentage.png&amp;diff=152752"/>
		<updated>2023-12-05T07:29:32Z</updated>

		<summary type="html">&lt;p&gt;Schen76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152750</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding (Phase2)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152750"/>
		<updated>2023-12-05T07:12:31Z</updated>

		<summary type="html">&lt;p&gt;Schen76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Motivation ==&lt;br /&gt;
&lt;br /&gt;
The bidding view is needed because we don’t have a way of finding out whether the bidding algorithm is running correctly.  This project is to add a bidding view to show how the topics are assigned to those teams who bid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Work Plan ==&lt;br /&gt;
&lt;br /&gt;
Based on the project's objectives and feedback received from our mentor, we have identified specific areas for improvement:&lt;br /&gt;
&lt;br /&gt;
1) Refactor variable names within methods such as &amp;quot;bidding_details&amp;quot; and variables like &amp;quot;Topic name&amp;quot; and &amp;quot;Bidding teams&amp;quot; to enhance clarity and specificity.&lt;br /&gt;
&lt;br /&gt;
2) Adjust capitalization for certain components, ensuring that only the first word is capitalized for consistency.&lt;br /&gt;
&lt;br /&gt;
3) Introduce calculations to determine percentages based on additional data, such as the total number of teams and the number of teams for each priority, within the &amp;quot;lottery_controller.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4) Conduct thorough testing of the modified controller and view to ensure optimal functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Newfeature.jpg | 888px]]&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
To add functionality for showing the percentages of the number of teams that got their #1, #2, and #3 choices. We can follow these high-level steps:&lt;br /&gt;
&lt;br /&gt;
'''Lottery_Controller:'''&lt;br /&gt;
&lt;br /&gt;
i) Calculate the Total Number of Teams: Before we can calculate percentages, we need to know the total number of teams that participated in the bidding process. This will be our denominator in the percentage calculation.&lt;br /&gt;
&lt;br /&gt;
ii) Calculate the Number of Teams for Each Priority: From our `bidding_details` method, we already have counts for how many teams bid on each topic as their #1, #2, and #3 choice (`@count1`, `@count2`, `@count3`). However, these counts are currently organized by topic. We would need to modify this to count how many teams got their #1, #2, and #3 choices as their assigned topic.&lt;br /&gt;
&lt;br /&gt;
iii) Calculate Percentages: Once we have the number of teams that got their #1, #2, and #3 choices, we can calculate the percentages by dividing these numbers by the total number of teams and multiplying by 100.&lt;br /&gt;
&lt;br /&gt;
'''Bidding_detail view:'''&lt;br /&gt;
&lt;br /&gt;
i) Update the View and Display Percentages: Above the table in our previous view, we can add a section to display these percentages.&lt;br /&gt;
&lt;br /&gt;
ii) Format the Display: We will use a bold heading for each percentage type and format the number to a fixed number of decimal places.&lt;br /&gt;
&lt;br /&gt;
iii) Ensure Responsiveness: Make sure the display of these percentages adjusts well to different screen sizes, maintaining readability and layout consistency. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code Effort ==&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; app/controllers/lottery_controller.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
method 1: bidding_table_for_each_topic&lt;br /&gt;
&lt;br /&gt;
This method generates a bidding table for each topic within an assignment. It performs several operations to gather and organize data related to topics, bids, and teams. Here's a breakdown of what the code does:&lt;br /&gt;
&lt;br /&gt;
1. Fetch Assignment:&lt;br /&gt;
&lt;br /&gt;
*It retrieves the assignment with the specified params[:id] from the database and stores it in the @assignment instance variable.&lt;br /&gt;
&lt;br /&gt;
2. Fetch Topics:&lt;br /&gt;
&lt;br /&gt;
*It retrieves all sign-up topics associated with the assignment and stores them in the @topics instance variable.&lt;br /&gt;
&lt;br /&gt;
3. Fetch Bids and Assigned Teams:&lt;br /&gt;
&lt;br /&gt;
For each topic in @topics, it:&lt;br /&gt;
*Retrieves all bids associated with that topic and stores them in a hash, where the key is the topic's ID and the value is an array of bids with their associated teams and priorities.&lt;br /&gt;
*Retrieves teams that are not waitlisted for the topic and stores them in a hash, again using the topic's ID as the key and an array of teams as the value.&lt;br /&gt;
&lt;br /&gt;
4. Priority Count Calculation:&lt;br /&gt;
&lt;br /&gt;
*It dynamically calculates and updates the counts for each bid priority level (1, 2, and 3) for each topic. These counts are stored in instance variables named @count1, @count2, and @count3. These instance variables are hashes where the keys are topic IDs, and the values are counts for each priority level.&lt;br /&gt;
&lt;br /&gt;
5. Calculate Total Teams:&lt;br /&gt;
&lt;br /&gt;
*It determines the total number of teams across all topics in the assignment by counting distinct team IDs among all non-waitlisted teams for the specified topics.&lt;br /&gt;
&lt;br /&gt;
6. Calculate Priority Counts and Percentages:&lt;br /&gt;
&lt;br /&gt;
*It calls two helper methods, calculate_priority_counts and calculate_percentages, to calculate the total counts of teams at each priority level and the corresponding percentages. The results are stored in the @priority_counts and @percentages instance variables, respectively.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Prepares data for displaying the bidding details for each topic within an assignment.&lt;br /&gt;
  # It calculates the number of bids for each priority (1, 2, 3) per topic and also computes&lt;br /&gt;
  # the overall percentages of teams that received their first, second, and third choice.&lt;br /&gt;
  def bidding_table_for_each_topic&lt;br /&gt;
    @assignment = Assignment.find(params[:id])&lt;br /&gt;
    # Fetch all topics for the assignment&lt;br /&gt;
    @topics = @assignment.sign_up_topics&lt;br /&gt;
    # Fetch all bids for these topics&lt;br /&gt;
    @bids_by_topic = {}&lt;br /&gt;
    @assigned_teams_by_topic = {} # This will store the assigned teams for each topic&lt;br /&gt;
    @topics.each do |topic|&lt;br /&gt;
      # Assuming bids are stored with a topic_id, and each bid has a team associated with it&lt;br /&gt;
      @bids_by_topic[topic.id] = Bid.where(topic_id: topic.id).map { |bid| { team: bid.team, priority: bid.priority } }&lt;br /&gt;
      # Fetch teams that are not waitlisted for this topic&lt;br /&gt;
      @assigned_teams_by_topic[topic.id] = SignedUpTeam.where(topic_id: topic.id, is_waitlisted: false).map(&amp;amp;:team)&lt;br /&gt;
      # @count1[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 1 }&lt;br /&gt;
      # @count2[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 2 }&lt;br /&gt;
      # @count3[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 3 }       &lt;br /&gt;
&lt;br /&gt;
      # Dynamically initializing and updating @count1, @count2, and @count3&lt;br /&gt;
      (1..3).each do |priority|&lt;br /&gt;
        instance_variable_set(&amp;quot;@count#{priority}&amp;quot;, Hash.new(0)) unless instance_variable_defined?(&amp;quot;@count#{priority}&amp;quot;)&lt;br /&gt;
        instance_variable_get(&amp;quot;@count#{priority}&amp;quot;)[topic.id] = @bids_by_topic[topic.id].count { |bid| bid[:priority] == priority }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # Calculate the total number of teams and percentages after fetching bid details&lt;br /&gt;
    topic_ids = SignUpTopic.where(assignment_id: @assignment.id).pluck(:id)&lt;br /&gt;
    @total_teams = SignedUpTeam.where(topic_id: topic_ids).distinct.count(:team_id)&lt;br /&gt;
    @priority_counts = calculate_priority_counts(@assigned_teams_by_topic, @bids_by_topic)&lt;br /&gt;
    @percentages = calculate_percentages(@priority_counts, @total_teams)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
method 2: calculate_priority_counts&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Calculates the count of assigned teams for each priority level (1, 2, 3) across all topics.&lt;br /&gt;
  # It checks each team associated with a topic and determines if the team's bid matches&lt;br /&gt;
  # one of the priority levels, incrementing the respective count if so.&lt;br /&gt;
  def calculate_priority_counts(assigned_teams_by_topic, bids_by_topic)&lt;br /&gt;
    priority_counts = { 1 =&amp;gt; 0, 2 =&amp;gt; 0, 3 =&amp;gt; 0 }&lt;br /&gt;
    assigned_teams_by_topic.each do |topic_id, teams|&lt;br /&gt;
      teams.each do |team|&lt;br /&gt;
        bid_info = bids_by_topic[topic_id].find { |bid| bid[:team] == team }&lt;br /&gt;
        priority_counts[bid_info[:priority]] += 1 if bid_info&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    priority_counts&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
method 3: calculate_percentages&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Calculates the percentages of teams that received their first, second, and third choice&lt;br /&gt;
  # based on the counts of teams at each priority level.&lt;br /&gt;
  def calculate_percentages(priority_counts, total_teams)&lt;br /&gt;
    priority_counts.transform_values { |count| (count.to_f / total_teams * 100).round(2) }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_each_topic.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt;Bidding Details for &amp;lt;%= @assignment.name %&amp;gt;&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;!-- Displaying percentages in a more visually appealing way --&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;percentages&amp;quot; style=&amp;quot;margin-bottom: 20px; padding: 15px; border: 1px solid #ccc; border-radius: 5px; background-color: #f9f9f9;&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;h4 style=&amp;quot;margin-bottom: 15px; border-bottom: 1px solid #eee; padding-bottom: 10px;&amp;quot;&amp;gt;Percentage of Teams Getting Their Choices:&amp;lt;/h4&amp;gt;&lt;br /&gt;
  &amp;lt;ul style=&amp;quot;list-style: none; padding: 0;&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;#1 Choice:&amp;lt;/strong&amp;gt; &amp;lt;span style=&amp;quot;color: #4CAF50;&amp;quot;&amp;gt;&amp;lt;%= @percentages[1] || 0 %&amp;gt; %&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;#2 Choice:&amp;lt;/strong&amp;gt; &amp;lt;span style=&amp;quot;color: #FF9800;&amp;quot;&amp;gt;&amp;lt;%= @percentages[2] || 0 %&amp;gt; %&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;#3 Choice:&amp;lt;/strong&amp;gt; &amp;lt;span style=&amp;quot;color: #F44336;&amp;quot;&amp;gt;&amp;lt;%= @percentages[3] || 0 %&amp;gt; %&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;style&amp;gt;&lt;br /&gt;
.assigned-team {&lt;br /&gt;
  background-color: yellow; &lt;br /&gt;
  color: black;             &lt;br /&gt;
}&lt;br /&gt;
.bids-column {&lt;br /&gt;
    width: 100px; /* Adjust width as needed */&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/style&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table class=&amp;quot;table table-bordered table-hover&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;thead&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic Name&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Topic ID&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;Bidding Teams&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#1 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#2 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;th&amp;gt;#3 bids&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;/thead&amp;gt;&lt;br /&gt;
  &amp;lt;tbody&amp;gt;&lt;br /&gt;
    &amp;lt;% @topics.each do |topic| %&amp;gt;&lt;br /&gt;
      &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.topic_name %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= topic.id %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&lt;br /&gt;
          &amp;lt;% @bids_by_topic[topic.id].each do |bid_info| %&amp;gt;&lt;br /&gt;
            &amp;lt;% team = bid_info[:team] %&amp;gt;&lt;br /&gt;
            &amp;lt;% assigned_team = @assigned_teams_by_topic[topic.id].include?(team) %&amp;gt;&lt;br /&gt;
            &amp;lt;span class=&amp;quot;&amp;lt;%= assigned_team ? 'assigned-team' : '' %&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;%= team.name %&amp;gt; (#&amp;lt;%= bid_info[:priority] %&amp;gt;)&lt;br /&gt;
            &amp;lt;/span&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count1[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count1[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count2[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count2[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td class=&amp;quot;bids-column&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;% if @count3[topic.id] != 0%&amp;gt;&lt;br /&gt;
            &amp;lt;%= @count3[topic.id] %&amp;gt;&lt;br /&gt;
          &amp;lt;%else%&amp;gt;&lt;br /&gt;
            &amp;amp;ndash;&lt;br /&gt;
          &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;/td&amp;gt;&lt;br /&gt;
      &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;% end %&amp;gt;&lt;br /&gt;
  &amp;lt;/tbody&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;javascript:history.back()&amp;quot;&amp;gt;Back&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Added Rspec Testing &amp;lt;code&amp;gt; app/views/lottery/bidding_table_for_each_topic.html.erb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe '#bidding_table_for_each_topic' do&lt;br /&gt;
    before :each do&lt;br /&gt;
      # Set the assignment id in the params&lt;br /&gt;
      params = ActionController::Parameters.new(id: assignment.id)&lt;br /&gt;
      allow(controller).to receive(:params).and_return(params)&lt;br /&gt;
    end&lt;br /&gt;
    it 'populates bids and assigned teams for each topic, handling topics with no teams' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
      # Check if @bids_by_topic is populated correctly&lt;br /&gt;
      expect(controller.instance_variable_get(:@bids_by_topic)[topic1.id].length).to eq(1)&lt;br /&gt;
      expect(controller.instance_variable_get(:@bids_by_topic)[topic2.id].length).to eq(1)&lt;br /&gt;
      # Check if @assigned_teams_by_topic is populated correctly, allowing for no teams&lt;br /&gt;
      assigned_teams_topic1 = controller.instance_variable_get(:@assigned_teams_by_topic)[topic1.id]&lt;br /&gt;
      if assigned_teams_topic1&lt;br /&gt;
        expect(assigned_teams_topic1.length).to(satisfy { |value| (value == 0) || (value == 1) })&lt;br /&gt;
      else&lt;br /&gt;
        expect(assigned_teams_topic1).to be_nil&lt;br /&gt;
      end&lt;br /&gt;
      # Check the counts of bids for each priority level&lt;br /&gt;
      # Ensure to adjust these based on what is set up in your test data&lt;br /&gt;
      expect(controller.instance_variable_get(:@count1)[topic1.id]).to eq(1) # assuming there is one bid with priority 1 for topic1&lt;br /&gt;
      expect(controller.instance_variable_get(:@count2)[topic1.id]).to eq(0) # assuming there are no bids with priority 2 for topic1&lt;br /&gt;
      expect(controller.instance_variable_get(:@count3)[topic1.id]).to eq(0) # assuming there are no bids with priority 3 for topic1&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'fetches all topics for the assignment' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
      expect(controller.instance_variable_get(:@topics)).to match_array([topic1, topic2, topic3, topic4])&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    it 'correctly calculates priority counts for each topic' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
      # Assuming you have a way to know the expected counts for each priority&lt;br /&gt;
      expected_priority_counts = { 1 =&amp;gt; 0, &lt;br /&gt;
                                   2 =&amp;gt; 0, &lt;br /&gt;
                                   3 =&amp;gt; 0 }&lt;br /&gt;
  &lt;br /&gt;
      priority_counts = controller.instance_variable_get(:@priority_counts)&lt;br /&gt;
      expect(priority_counts).to eq(expected_priority_counts)&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    it 'correctly calculates percentages for teams getting their choices' do&lt;br /&gt;
      controller.bidding_table_for_each_topic&lt;br /&gt;
  &lt;br /&gt;
      # Assuming you have a way to know the expected percentages&lt;br /&gt;
      expected_percentages = { 1 =&amp;gt; Float::NAN, &lt;br /&gt;
                               2 =&amp;gt; Float::NAN, &lt;br /&gt;
                               3 =&amp;gt; Float::NAN }&lt;br /&gt;
  &lt;br /&gt;
      percentages = controller.instance_variable_get(:@percentages)&lt;br /&gt;
      expect(percentages[1].nan?).to be true if expected_percentages[1].nan?&lt;br /&gt;
      expect(percentages[2].nan?).to be true if expected_percentages[2].nan?&lt;br /&gt;
      expect(percentages[3].nan?).to be true if expected_percentages[3].nan?&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
According to the given test skeleton and the features we've implemented and to be implemented. Here are the testing ideas:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Context 1: When There Are No Bids or Assigned Teams'''&lt;br /&gt;
&lt;br /&gt;
Test 1: Check if we get empty arrays for bids and assigned teams after running the &amp;quot;bidding_details&amp;quot; method.&lt;br /&gt;
&lt;br /&gt;
Test 2: Check if the percentage of teams getting their #1, #2, and #3 choices are all 0.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Context 2: When There Are Bids and Assigned Teams for the Assignment'''&lt;br /&gt;
&lt;br /&gt;
Test 3: We would first set up a known distribution of bids across different priority levels. After executing the &amp;quot;bidding_details&amp;quot; method, the test verifies that the returned count of bids for each priority level matches the expected distribution set up in the test environment.&lt;br /&gt;
&lt;br /&gt;
Test 4: Ensure that the method correctly identifies and returns the assigned teams for each topic. In this test, the setup would include an assignment with pre-assigned teams to various topics. The &amp;quot;bidding_details&amp;quot; method is then called, and the test checks whether the method accurately returns the list of assigned teams for each topic, as per the test setup.&lt;br /&gt;
&lt;br /&gt;
Test 5: Check if all teams bidding on a different topic, they all get the topic they want, and the percentage of #1 is 100%, while #2 and #3 are 0s.&lt;br /&gt;
&lt;br /&gt;
Test 6: Check if all teams bidding on the same topic, only one team gets the topic they want, and the percentage of #1 is (1/teams)%, while #2 and #3 are 0s.&lt;br /&gt;
&lt;br /&gt;
Test 7: Check if a team is a first/second/third team to bid on some topic, that topic is finally assigned to this team. In this case, #1, #2, or #3 is a non-zero value.&lt;br /&gt;
&lt;br /&gt;
Test 8: Provide mocking data and we pre-calculate the percentage value of #1, #2 and #3, check if the calculated values are the same as ours.&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
&lt;br /&gt;
'''Github Repository: ''' https://github.com/Shreshth-Malik/expertiza&lt;br /&gt;
&lt;br /&gt;
== Team == &lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Edward F. Gehringer (efg ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
'''Members'''&lt;br /&gt;
&lt;br /&gt;
Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shreshth Malik (smalik4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shuai Chen (schen76@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152735</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding (Phase2)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152735"/>
		<updated>2023-12-05T06:40:21Z</updated>

		<summary type="html">&lt;p&gt;Schen76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Motivation ==&lt;br /&gt;
&lt;br /&gt;
The bidding view is needed because we don’t have a way of finding out whether the bidding algorithm is running correctly.  This project is to add a bidding view to show how the topics are assigned to those teams who bid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Work Plan ==&lt;br /&gt;
&lt;br /&gt;
Based on the project's objectives and feedback received from our mentor, we have identified specific areas for improvement:&lt;br /&gt;
&lt;br /&gt;
1) Refactor variable names within methods such as &amp;quot;bidding_details&amp;quot; and variables like &amp;quot;Topic name&amp;quot; and &amp;quot;Bidding teams&amp;quot; to enhance clarity and specificity.&lt;br /&gt;
&lt;br /&gt;
2) Adjust capitalization for certain components, ensuring that only the first word is capitalized for consistency.&lt;br /&gt;
&lt;br /&gt;
3) Introduce calculations to determine percentages based on additional data, such as the total number of teams and the number of teams for each priority, within the &amp;quot;lottery_controller.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4) Conduct thorough testing of the modified controller and view to ensure optimal functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Newfeature.jpg | 888px]]&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
To add functionality for showing the percentages of the number of teams that got their #1, #2, and #3 choices. We can follow these high-level steps:&lt;br /&gt;
&lt;br /&gt;
'''Lottery_Controller:'''&lt;br /&gt;
&lt;br /&gt;
i) Calculate the Total Number of Teams: Before we can calculate percentages, we need to know the total number of teams that participated in the bidding process. This will be our denominator in the percentage calculation.&lt;br /&gt;
&lt;br /&gt;
ii) Calculate the Number of Teams for Each Priority: From our `bidding_details` method, we already have counts for how many teams bid on each topic as their #1, #2, and #3 choice (`@count1`, `@count2`, `@count3`). However, these counts are currently organized by topic. We would need to modify this to count how many teams got their #1, #2, and #3 choices as their assigned topic.&lt;br /&gt;
&lt;br /&gt;
iii) Calculate Percentages: Once we have the number of teams that got their #1, #2, and #3 choices, we can calculate the percentages by dividing these numbers by the total number of teams and multiplying by 100.&lt;br /&gt;
&lt;br /&gt;
'''Bidding_detail view:'''&lt;br /&gt;
&lt;br /&gt;
i) Update the View and Display Percentages: Above the table in our previous view, we can add a section to display these percentages.&lt;br /&gt;
&lt;br /&gt;
ii) Format the Display: We will use a bold heading for each percentage type and format the number to a fixed number of decimal places.&lt;br /&gt;
&lt;br /&gt;
iii) Ensure Responsiveness: Make sure the display of these percentages adjusts well to different screen sizes, maintaining readability and layout consistency. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code Effort ==&lt;br /&gt;
&lt;br /&gt;
Change in &amp;lt;code&amp;gt; lottery_controller.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
method 1: bidding_table_for_each_topic&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Prepares data for displaying the bidding details for each topic within an assignment.&lt;br /&gt;
  # It calculates the number of bids for each priority (1, 2, 3) per topic and also computes&lt;br /&gt;
  # the overall percentages of teams that received their first, second, and third choice.&lt;br /&gt;
  def bidding_table_for_each_topic&lt;br /&gt;
    @assignment = Assignment.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    # Fetch all topics for the assignment&lt;br /&gt;
    @topics = @assignment.sign_up_topics&lt;br /&gt;
  &lt;br /&gt;
    @count1 = Hash.new(0)&lt;br /&gt;
    @count2 = Hash.new(0)&lt;br /&gt;
    @count3 = Hash.new(0)&lt;br /&gt;
    # Fetch all bids for these topics&lt;br /&gt;
    @bids_by_topic = {}&lt;br /&gt;
    @assigned_teams_by_topic = {}  # This will store the assigned teams for each topic&lt;br /&gt;
    @topics.each do |topic|&lt;br /&gt;
      # Assuming bids are stored with a topic_id, and each bid has a team associated with it&lt;br /&gt;
      @bids_by_topic[topic.id] = Bid.where(topic_id: topic.id).map do |bid|&lt;br /&gt;
        { team: bid.team, priority: bid.priority }&lt;br /&gt;
      end&lt;br /&gt;
      # Fetch teams that are not waitlisted for this topic&lt;br /&gt;
      @assigned_teams_by_topic[topic.id] = SignedUpTeam.where(topic_id: topic.id, is_waitlisted: false).map(&amp;amp;:team)&lt;br /&gt;
      @count1[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 1 }&lt;br /&gt;
      @count2[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 2 }&lt;br /&gt;
      @count3[topic.id] += @bids_by_topic[topic.id].count { |bid| bid[:priority] == 3 }       &lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
    # Calculate the total number of teams and percentages after fetching bid details&lt;br /&gt;
    topic_ids = SignUpTopic.where(assignment_id: @assignment.id).pluck(:id)&lt;br /&gt;
    @total_teams = SignedUpTeam.where(topic_id: topic_ids).distinct.count(:team_id)&lt;br /&gt;
    @priority_counts = calculate_priority_counts(@assigned_teams_by_topic, @bids_by_topic)&lt;br /&gt;
    @percentages = calculate_percentages(@priority_counts, @total_teams)&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
method 2: calculate_priority_counts&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Calculates the count of assigned teams for each priority level (1, 2, 3) across all topics.&lt;br /&gt;
  # It checks each team associated with a topic and determines if the team's bid matches&lt;br /&gt;
  # one of the priority levels, incrementing the respective count if so.&lt;br /&gt;
  def calculate_priority_counts(assigned_teams_by_topic, bids_by_topic)&lt;br /&gt;
    priority_counts = { 1 =&amp;gt; 0, 2 =&amp;gt; 0, 3 =&amp;gt; 0 }&lt;br /&gt;
    assigned_teams_by_topic.each do |topic_id, teams|&lt;br /&gt;
      teams.each do |team|&lt;br /&gt;
        bid_info = bids_by_topic[topic_id].find { |bid| bid[:team] == team }&lt;br /&gt;
        priority_counts[bid_info[:priority]] += 1 if bid_info&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    priority_counts&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
method 3: calculate_percentages&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Calculates the percentages of teams that received their first, second, and third choice&lt;br /&gt;
  # based on the counts of teams at each priority level.&lt;br /&gt;
  def calculate_percentages(priority_counts, total_teams)&lt;br /&gt;
    priority_counts.transform_values { |count| (count.to_f / total_teams * 100).round(2) }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
According to the given test skeleton and the features we've implemented and to be implemented. Here are the testing ideas:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Context 1: When There Are No Bids or Assigned Teams'''&lt;br /&gt;
&lt;br /&gt;
Test 1: Check if we get empty arrays for bids and assigned teams after running the &amp;quot;bidding_details&amp;quot; method.&lt;br /&gt;
&lt;br /&gt;
Test 2: Check if the percentage of teams getting their #1, #2, and #3 choices are all 0.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Context 2: When There Are Bids and Assigned Teams for the Assignment'''&lt;br /&gt;
&lt;br /&gt;
Test 3: We would first set up a known distribution of bids across different priority levels. After executing the &amp;quot;bidding_details&amp;quot; method, the test verifies that the returned count of bids for each priority level matches the expected distribution set up in the test environment.&lt;br /&gt;
&lt;br /&gt;
Test 4: Ensure that the method correctly identifies and returns the assigned teams for each topic. In this test, the setup would include an assignment with pre-assigned teams to various topics. The &amp;quot;bidding_details&amp;quot; method is then called, and the test checks whether the method accurately returns the list of assigned teams for each topic, as per the test setup.&lt;br /&gt;
&lt;br /&gt;
Test 5: Check if all teams bidding on a different topic, they all get the topic they want, and the percentage of #1 is 100%, while #2 and #3 are 0s.&lt;br /&gt;
&lt;br /&gt;
Test 6: Check if all teams bidding on the same topic, only one team gets the topic they want, and the percentage of #1 is (1/teams)%, while #2 and #3 are 0s.&lt;br /&gt;
&lt;br /&gt;
Test 7: Check if a team is a first/second/third team to bid on some topic, that topic is finally assigned to this team. In this case, #1, #2, or #3 is a non-zero value.&lt;br /&gt;
&lt;br /&gt;
Test 8: Provide mocking data and we pre-calculate the percentage value of #1, #2 and #3, check if the calculated values are the same as ours.&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
&lt;br /&gt;
'''Github Repository: ''' https://github.com/Shreshth-Malik/expertiza&lt;br /&gt;
&lt;br /&gt;
== Team == &lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Edward F. Gehringer (efg ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
'''Members'''&lt;br /&gt;
&lt;br /&gt;
Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shreshth Malik (smalik4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shuai Chen (schen76@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152525</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding (Phase2)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152525"/>
		<updated>2023-12-05T03:03:59Z</updated>

		<summary type="html">&lt;p&gt;Schen76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Motivation ==&lt;br /&gt;
&lt;br /&gt;
The bidding view was needed because we didn’t have a way of finding out whether the bidding algorithm was running correctly.  This project is to add tests and determine whether the algorithm is running correctly, and, if not, debug it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Work Plan ==&lt;br /&gt;
&lt;br /&gt;
Based on the project's objectives and feedback received from our mentor, we have identified specific areas for improvement:&lt;br /&gt;
&lt;br /&gt;
i) Refactor variable names within methods such as &amp;quot;bidding_details&amp;quot; and variables like &amp;quot;Topic name&amp;quot; and &amp;quot;Bidding teams&amp;quot; to enhance clarity and specificity.&lt;br /&gt;
&lt;br /&gt;
ii) Adjust capitalization for certain components, ensuring that only the first word is capitalized for consistency.&lt;br /&gt;
&lt;br /&gt;
iii) Introduce calculations to determine percentages based on additional data, such as the total number of teams and the number of teams for each priority, within the &amp;quot;lottery_controller.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iv) Conduct thorough testing of the modified controller and view to ensure optimal functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Newfeature.jpg | 888px]]&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
To add functionality for showing the percentages of the number of teams that got their #1, #2, and #3 choices. We can follow these high-level steps:&lt;br /&gt;
&lt;br /&gt;
'''Lottery_Controller:'''&lt;br /&gt;
&lt;br /&gt;
i) Calculate the Total Number of Teams: Before we can calculate percentages, we need to know the total number of teams that participated in the bidding process. This will be our denominator in the percentage calculation.&lt;br /&gt;
&lt;br /&gt;
ii) Calculate the Number of Teams for Each Priority: From our `bidding_details` method, we already have counts for how many teams bid on each topic as their #1, #2, and #3 choice (`@count1`, `@count2`, `@count3`). However, these counts are currently organized by topic. We would need to modify this to count how many teams got their #1, #2, and #3 choices as their assigned topic.&lt;br /&gt;
&lt;br /&gt;
iii) Calculate Percentages: Once we have the number of teams that got their #1, #2, and #3 choices, we can calculate the percentages by dividing these numbers by the total number of teams and multiplying by 100.&lt;br /&gt;
&lt;br /&gt;
'''Bidding_detail view:'''&lt;br /&gt;
&lt;br /&gt;
i) Update the View and Display Percentages: Above the table in our previous view, we can add a section to display these percentages.&lt;br /&gt;
&lt;br /&gt;
ii) Format the Display: We will use a bold heading for each percentage type and format the number to a fixed number of decimal places.&lt;br /&gt;
&lt;br /&gt;
iii) Ensure Responsiveness: Make sure the display of these percentages adjusts well to different screen sizes, maintaining readability and layout consistency. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
According to the given test skeleton and the features we've implemented and to be implemented. Here are the testing ideas:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Context 1: When There Are No Bids or Assigned Teams'''&lt;br /&gt;
&lt;br /&gt;
Test 1: Check if we get empty arrays for bids and assigned teams after running the &amp;quot;bidding_details&amp;quot; method.&lt;br /&gt;
&lt;br /&gt;
Test 2: Check if the percentage of teams getting their #1, #2, and #3 choices are all 0.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Context 2: When There Are Bids and Assigned Teams for the Assignment'''&lt;br /&gt;
&lt;br /&gt;
Test 3: We would first set up a known distribution of bids across different priority levels. After executing the &amp;quot;bidding_details&amp;quot; method, the test verifies that the returned count of bids for each priority level matches the expected distribution set up in the test environment.&lt;br /&gt;
&lt;br /&gt;
Test 4: Ensure that the method correctly identifies and returns the assigned teams for each topic. In this test, the setup would include an assignment with pre-assigned teams to various topics. The &amp;quot;bidding_details&amp;quot; method is then called, and the test checks whether the method accurately returns the list of assigned teams for each topic, as per the test setup.&lt;br /&gt;
&lt;br /&gt;
Test 5: Check if all teams bidding on a different topic, they all get the topic they want, and the percentage of #1 is 100%, while #2 and #3 are 0s.&lt;br /&gt;
&lt;br /&gt;
Test 6: Check if all teams bidding on the same topic, only one team gets the topic they want, and the percentage of #1 is (1/teams)%, while #2 and #3 are 0s.&lt;br /&gt;
&lt;br /&gt;
Test 7: Check if a team is a first/second/third team to bid on some topic, that topic is finally assigned to this team. In this case, #1, #2, or #3 is a non-zero value.&lt;br /&gt;
&lt;br /&gt;
Test 8: Provide mocking data and we pre-calculate the percentage value of #1, #2 and #3, check if the calculated values are the same as ours.&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
&lt;br /&gt;
'''Github Repository: ''' https://github.com/Shreshth-Malik/expertiza&lt;br /&gt;
&lt;br /&gt;
== Team == &lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Edward F. Gehringer (efg ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
'''Members'''&lt;br /&gt;
&lt;br /&gt;
Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shreshth Malik (smalik4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shuai Chen (schen76@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152496</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding (Phase2)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=152496"/>
		<updated>2023-12-05T02:54:48Z</updated>

		<summary type="html">&lt;p&gt;Schen76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Design Doc ==&lt;br /&gt;
&lt;br /&gt;
==== 1. Work Plan ====&lt;br /&gt;
&lt;br /&gt;
Based on the project's objectives and feedback received from our mentor, we have identified specific areas for improvement:&lt;br /&gt;
&lt;br /&gt;
i) Refactor variable names within methods such as &amp;quot;bidding_details&amp;quot; and variables like &amp;quot;Topic name&amp;quot; and &amp;quot;Bidding teams&amp;quot; to enhance clarity and specificity.&lt;br /&gt;
&lt;br /&gt;
ii) Adjust capitalization for certain components, ensuring that only the first word is capitalized for consistency.&lt;br /&gt;
&lt;br /&gt;
iii) Introduce calculations to determine percentages based on additional data, such as the total number of teams and the number of teams for each priority, within the &amp;quot;lottery_controller.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iv) Conduct thorough testing of the modified controller and view to ensure optimal functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Newfeature.jpg | 888px]]&lt;br /&gt;
&lt;br /&gt;
==== 2. Design ====&lt;br /&gt;
&lt;br /&gt;
To add functionality for showing the percentages of the number of teams that got their #1, #2, and #3 choices. We can follow these high-level steps:&lt;br /&gt;
&lt;br /&gt;
'''Lottery_Controller:'''&lt;br /&gt;
&lt;br /&gt;
i) Calculate the Total Number of Teams: Before we can calculate percentages, we need to know the total number of teams that participated in the bidding process. This will be our denominator in the percentage calculation.&lt;br /&gt;
&lt;br /&gt;
ii) Calculate the Number of Teams for Each Priority: From our `bidding_details` method, we already have counts for how many teams bid on each topic as their #1, #2, and #3 choice (`@count1`, `@count2`, `@count3`). However, these counts are currently organized by topic. We would need to modify this to count how many teams got their #1, #2, and #3 choices as their assigned topic.&lt;br /&gt;
&lt;br /&gt;
iii) Calculate Percentages: Once we have the number of teams that got their #1, #2, and #3 choices, we can calculate the percentages by dividing these numbers by the total number of teams and multiplying by 100.&lt;br /&gt;
&lt;br /&gt;
'''Bidding_detail view:'''&lt;br /&gt;
&lt;br /&gt;
i) Update the View and Display Percentages: Above the table in our previous view, we can add a section to display these percentages.&lt;br /&gt;
&lt;br /&gt;
ii) Format the Display: We will use a bold heading for each percentage type and format the number to a fixed number of decimal places.&lt;br /&gt;
&lt;br /&gt;
iii) Ensure Responsiveness: Make sure the display of these percentages adjusts well to different screen sizes, maintaining readability and layout consistency. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 3. Test Plan ====&lt;br /&gt;
&lt;br /&gt;
According to the given test skeleton and the features we've implemented and to be implemented. Here are the testing ideas:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Context 1: When There Are No Bids or Assigned Teams'''&lt;br /&gt;
&lt;br /&gt;
Test 1: Check if we get empty arrays for bids and assigned teams after running the &amp;quot;bidding_details&amp;quot; method.&lt;br /&gt;
&lt;br /&gt;
Test 2: Check if the percentage of teams getting their #1, #2, and #3 choices are all 0.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Context 2: When There Are Bids and Assigned Teams for the Assignment'''&lt;br /&gt;
&lt;br /&gt;
Test 3: We would first set up a known distribution of bids across different priority levels. After executing the &amp;quot;bidding_details&amp;quot; method, the test verifies that the returned count of bids for each priority level matches the expected distribution set up in the test environment.&lt;br /&gt;
&lt;br /&gt;
Test 4: Ensure that the method correctly identifies and returns the assigned teams for each topic. In this test, the setup would include an assignment with pre-assigned teams to various topics. The &amp;quot;bidding_details&amp;quot; method is then called, and the test checks whether the method accurately returns the list of assigned teams for each topic, as per the test setup.&lt;br /&gt;
&lt;br /&gt;
Test 5: Check if all teams bidding on a different topic, they all get the topic they want, and the percentage of #1 is 100%, while #2 and #3 are 0s.&lt;br /&gt;
&lt;br /&gt;
Test 6: Check if all teams bidding on the same topic, only one team gets the topic they want, and the percentage of #1 is (1/teams)%, while #2 and #3 are 0s.&lt;br /&gt;
&lt;br /&gt;
Test 7: Check if a team is a first/second/third team to bid on some topic, that topic is finally assigned to this team. In this case, #1, #2, or #3 is a non-zero value.&lt;br /&gt;
&lt;br /&gt;
Test 8: Provide mocking data and we pre-calculate the percentage value of #1, #2 and #3, check if the calculated values are the same as ours.&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
&lt;br /&gt;
'''Github Repository: ''' https://github.com/Shreshth-Malik/expertiza&lt;br /&gt;
&lt;br /&gt;
== Team == &lt;br /&gt;
'''Mentor'''&lt;br /&gt;
&lt;br /&gt;
Edward F. Gehringer (efg ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
'''Members'''&lt;br /&gt;
&lt;br /&gt;
Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shreshth Malik (smalik4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Shuai Chen (schen76@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=151714</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding (Phase2)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=151714"/>
		<updated>2023-11-16T03:48:56Z</updated>

		<summary type="html">&lt;p&gt;Schen76: /* 1. Work Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Design Doc ==&lt;br /&gt;
&lt;br /&gt;
==== 1. Work Plan ====&lt;br /&gt;
&lt;br /&gt;
Based on the project's objectives and feedback received from our mentor, we have identified specific areas for improvement:&lt;br /&gt;
&lt;br /&gt;
i) Refactor variable names within methods such as &amp;quot;bidding_details&amp;quot; and variables like &amp;quot;Topic name&amp;quot; and &amp;quot;Bidding teams&amp;quot; to enhance clarity and specificity.&lt;br /&gt;
&lt;br /&gt;
ii) Adjust capitalization for certain components, ensuring that only the first word is capitalized for consistency.&lt;br /&gt;
&lt;br /&gt;
iii) Introduce calculations to determine percentages based on additional data, such as the total number of teams and the number of teams for each priority, within the &amp;quot;lottery_controller.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iv) Conduct thorough testing of the modified controller and view to ensure optimal functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Newfeature.jpg | 888px]]&lt;br /&gt;
&lt;br /&gt;
==== 2. Design ====&lt;br /&gt;
&lt;br /&gt;
To add functionality for showing the percentages of the number of teams that got their #1, #2, and #3 choices. We can follow these high-level steps:&lt;br /&gt;
&lt;br /&gt;
'''Lottery_Controller:'''&lt;br /&gt;
&lt;br /&gt;
i) Calculate the Total Number of Teams: Before we can calculate percentages, we need to know the total number of teams that participated in the bidding process. This will be our denominator in the percentage calculation.&lt;br /&gt;
&lt;br /&gt;
ii) Calculate the Number of Teams for Each Priority: From our `bidding_details` method, we already have counts for how many teams bid on each topic as their #1, #2, and #3 choice (`@count1`, `@count2`, `@count3`). However, these counts are currently organized by topic. We would need to modify this to count how many teams got their #1, #2, and #3 choices as their assigned topic.&lt;br /&gt;
&lt;br /&gt;
iii) Calculate Percentages: Once we have the number of teams that got their #1, #2, and #3 choices, we can calculate the percentages by dividing these numbers by the total number of teams and multiplying by 100.&lt;br /&gt;
&lt;br /&gt;
'''Bidding_detail view:'''&lt;br /&gt;
&lt;br /&gt;
i) Update the View and Display Percentages: Above the table in our previous view, we can add a section to display these percentages.&lt;br /&gt;
&lt;br /&gt;
ii) Format the Display: We will use a bold heading for each percentage type and format the number to a fixed number of decimal places.&lt;br /&gt;
&lt;br /&gt;
iii) Ensure Responsiveness: Make sure the display of these percentages adjusts well to different screen sizes, maintaining readability and layout consistency. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 3. Test Plan ====&lt;br /&gt;
&lt;br /&gt;
According to the given test skeleton and the features we've implemented and to be implemented. Here are the testing ideas:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Context 1: When There Are No Bids or Assigned Teams'''&lt;br /&gt;
&lt;br /&gt;
Test 1: Check if we get empty arrays for bids and assigned teams after running the &amp;quot;bidding_details&amp;quot; method.&lt;br /&gt;
&lt;br /&gt;
Test 2: Check if the percentage of teams getting their #1, #2, and #3 choices are all 0.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Context 2: When There Are Bids and Assigned Teams for the Assignment'''&lt;br /&gt;
&lt;br /&gt;
Test 3: We would first set up a known distribution of bids across different priority levels. After executing the &amp;quot;bidding_details&amp;quot; method, the test verifies that the returned count of bids for each priority level matches the expected distribution set up in the test environment.&lt;br /&gt;
&lt;br /&gt;
Test 4: Ensure that the method correctly identifies and returns the assigned teams for each topic. In this test, the setup would include an assignment with pre-assigned teams to various topics. The &amp;quot;bidding_details&amp;quot; method is then called, and the test checks whether the method accurately returns the list of assigned teams for each topic, as per the test setup.&lt;br /&gt;
&lt;br /&gt;
Test 5: Check if all teams bidding on a different topic, they all get the topic they want, and the percentage of #1 is 100%, while #2 and #3 are 0s.&lt;br /&gt;
&lt;br /&gt;
Test 6: Check if all teams bidding on the same topic, only one team gets the topic they want, and the percentage of #1 is (1/teams)%, while #2 and #3 are 0s.&lt;br /&gt;
&lt;br /&gt;
Test 7: Check if a team is a first/second/third team to bid on some topic, that topic is finally assigned to this team. In this case, #1, #2, or #3 is a non-zero value.&lt;br /&gt;
&lt;br /&gt;
Test 8: Provide mocking data and we pre-calculate the percentage value of #1, #2 and #3, check if the calculated values are the same as ours.&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Newfeature.jpg&amp;diff=151712</id>
		<title>File:Newfeature.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Newfeature.jpg&amp;diff=151712"/>
		<updated>2023-11-16T03:47:58Z</updated>

		<summary type="html">&lt;p&gt;Schen76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023&amp;diff=151706</id>
		<title>CSC/ECE 517 Fall 2023</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023&amp;diff=151706"/>
		<updated>2023-11-16T03:43:43Z</updated>

		<summary type="html">&lt;p&gt;Schen76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[CSC/ECE 517 Fall 2023 - E2350. Allow reviewers to bid on what to review]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2351. Finish mentor management for assignments without topics]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2352. Fix &amp;quot;Back&amp;quot; link on “New Late Policy” page]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2353. Further refactoring and improvement of review mapping helper]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2355. Improving Search Facility In Expertiza]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2356. Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2357. Refactor sign_up_sheet_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2358. Refactor student_quizzes_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2359. Refactor user_controller.rb, user.rb, and its child classes]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding (Phase2)]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2361. Create a page to create and update a Questionnaire in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2362. Create a page to edit an Assignment's due date in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2363. Create a UI for Assignment Edit page &amp;quot;Etc&amp;quot; tab in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2364. Create a UI for Course's &amp;amp; Assignment's &amp;quot;Add Participants&amp;quot; page]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2365. Create a user interface for Questionnaire in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2387. Reimplement Teams backend (Phase 2)]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2366. Reimplement assignment model and assignment controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2366. Reimplement assignment model and assignment controller (Phase 2)]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2367. Reimplement participants_controller.rb, participants.rb and its child classes]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2368. Reimplement of due_date.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2369. Reimplement duties controller.rb and badges controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2370. Reimplement join team requests controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2371. Reimplement quiz_questionnaires_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2373. Reimplementation of teams controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2373. Reimplement teams_controllers.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2374. Reimplement the Question hierarchy]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2375. Reimplement Waitlists]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2376. Reimplement student_quizzes_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2379. Reimplement authorization_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2380. Reimplement frontend for Courses]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2381. Reimplement frontend for Assignments]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2382. Optimizing the LatePoliciesController]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2383. Grading Audit Trail]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2384. Reimplement user_controller.rb, user.rb and its child classes]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2385. Create a Courses User interface in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2386. Reimplement teams_users backend]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2377. Reimplement impersonating users (functionality within impersonate_controller.rb)]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - NTX-1 Adding Snapshot Controller/API and CRDs]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - NTX-2 Observability and Debuggability]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - NTX-3 Usability and Security]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - NTX-4 Extend NDB Operator capabilities to support Postgres HA]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - G2350. Add GitLab support for using GraphQL to query user metrics 1]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - G2352. Add GitLab support for using GraphQL to query repository information]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2375. Refactor classes relating to signing up for topics]]&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023&amp;diff=151705</id>
		<title>CSC/ECE 517 Fall 2023</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023&amp;diff=151705"/>
		<updated>2023-11-16T03:43:32Z</updated>

		<summary type="html">&lt;p&gt;Schen76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[CSC/ECE 517 Fall 2023 - E2350. Allow reviewers to bid on what to review]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2351. Finish mentor management for assignments without topics]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2352. Fix &amp;quot;Back&amp;quot; link on “New Late Policy” page]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2353. Further refactoring and improvement of review mapping helper]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2355. Improving Search Facility In Expertiza]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2356. Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2357. Refactor sign_up_sheet_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2358. Refactor student_quizzes_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2359. Refactor user_controller.rb, user.rb, and its child classes]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding(Phase2)]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2361. Create a page to create and update a Questionnaire in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2362. Create a page to edit an Assignment's due date in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2363. Create a UI for Assignment Edit page &amp;quot;Etc&amp;quot; tab in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2364. Create a UI for Course's &amp;amp; Assignment's &amp;quot;Add Participants&amp;quot; page]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2365. Create a user interface for Questionnaire in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2387. Reimplement Teams backend (Phase 2)]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2366. Reimplement assignment model and assignment controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2366. Reimplement assignment model and assignment controller (Phase 2)]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2367. Reimplement participants_controller.rb, participants.rb and its child classes]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2368. Reimplement of due_date.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2369. Reimplement duties controller.rb and badges controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2370. Reimplement join team requests controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2371. Reimplement quiz_questionnaires_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2373. Reimplementation of teams controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2373. Reimplement teams_controllers.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2374. Reimplement the Question hierarchy]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2375. Reimplement Waitlists]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2376. Reimplement student_quizzes_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2379. Reimplement authorization_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2380. Reimplement frontend for Courses]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2381. Reimplement frontend for Assignments]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2382. Optimizing the LatePoliciesController]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2383. Grading Audit Trail]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2384. Reimplement user_controller.rb, user.rb and its child classes]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2385. Create a Courses User interface in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2386. Reimplement teams_users backend]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2377. Reimplement impersonating users (functionality within impersonate_controller.rb)]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - NTX-1 Adding Snapshot Controller/API and CRDs]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - NTX-2 Observability and Debuggability]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - NTX-3 Usability and Security]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - NTX-4 Extend NDB Operator capabilities to support Postgres HA]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - G2350. Add GitLab support for using GraphQL to query user metrics 1]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - G2352. Add GitLab support for using GraphQL to query repository information]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2375. Refactor classes relating to signing up for topics]]&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023&amp;diff=151704</id>
		<title>CSC/ECE 517 Fall 2023</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023&amp;diff=151704"/>
		<updated>2023-11-16T03:42:57Z</updated>

		<summary type="html">&lt;p&gt;Schen76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[CSC/ECE 517 Fall 2023 - E2350. Allow reviewers to bid on what to review]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2351. Finish mentor management for assignments without topics]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2352. Fix &amp;quot;Back&amp;quot; link on “New Late Policy” page]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2353. Further refactoring and improvement of review mapping helper]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2355. Improving Search Facility In Expertiza]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2356. Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2357. Refactor sign_up_sheet_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2358. Refactor student_quizzes_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2359. Refactor user_controller.rb, user.rb, and its child classes]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding]]&lt;br /&gt;
* [[CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2361. Create a page to create and update a Questionnaire in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2362. Create a page to edit an Assignment's due date in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2363. Create a UI for Assignment Edit page &amp;quot;Etc&amp;quot; tab in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2364. Create a UI for Course's &amp;amp; Assignment's &amp;quot;Add Participants&amp;quot; page]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2365. Create a user interface for Questionnaire in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2387. Reimplement Teams backend (Phase 2)]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2366. Reimplement assignment model and assignment controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2366. Reimplement assignment model and assignment controller (Phase 2)]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2367. Reimplement participants_controller.rb, participants.rb and its child classes]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2368. Reimplement of due_date.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2369. Reimplement duties controller.rb and badges controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2370. Reimplement join team requests controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2371. Reimplement quiz_questionnaires_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2373. Reimplementation of teams controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2373. Reimplement teams_controllers.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2374. Reimplement the Question hierarchy]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2375. Reimplement Waitlists]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2376. Reimplement student_quizzes_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2379. Reimplement authorization_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2380. Reimplement frontend for Courses]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2381. Reimplement frontend for Assignments]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2382. Optimizing the LatePoliciesController]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2383. Grading Audit Trail]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2384. Reimplement user_controller.rb, user.rb and its child classes]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2385. Create a Courses User interface in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2386. Reimplement teams_users backend]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2377. Reimplement impersonating users (functionality within impersonate_controller.rb)]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - NTX-1 Adding Snapshot Controller/API and CRDs]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - NTX-2 Observability and Debuggability]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - NTX-3 Usability and Security]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - NTX-4 Extend NDB Operator capabilities to support Postgres HA]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - G2350. Add GitLab support for using GraphQL to query user metrics 1]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - G2352. Add GitLab support for using GraphQL to query repository information]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2375. Refactor classes relating to signing up for topics]]&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=151700</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding (Phase2)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=151700"/>
		<updated>2023-11-16T03:41:52Z</updated>

		<summary type="html">&lt;p&gt;Schen76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Design Doc ==&lt;br /&gt;
&lt;br /&gt;
==== 1. Work Plan ====&lt;br /&gt;
&lt;br /&gt;
Based on the project's objectives and feedback received from our mentor, we have identified specific areas for improvement:&lt;br /&gt;
&lt;br /&gt;
i) Refactor variable names within methods such as &amp;quot;bidding_details&amp;quot; and variables like &amp;quot;Topic name&amp;quot; and &amp;quot;Bidding teams&amp;quot; to enhance clarity and specificity.&lt;br /&gt;
&lt;br /&gt;
ii) Adjust capitalization for certain components, ensuring that only the first word is capitalized for consistency.&lt;br /&gt;
&lt;br /&gt;
iii) Introduce calculations to determine percentages based on additional data, such as the total number of teams and the number of teams for each priority, within the &amp;quot;lottery_controller.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iv) Conduct thorough testing of the modified controller and view to ensure optimal functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 2. Design ====&lt;br /&gt;
&lt;br /&gt;
To add functionality for showing the percentages of the number of teams that got their #1, #2, and #3 choices. We can follow these high-level steps:&lt;br /&gt;
&lt;br /&gt;
'''Lottery_Controller:'''&lt;br /&gt;
&lt;br /&gt;
i) Calculate the Total Number of Teams: Before we can calculate percentages, we need to know the total number of teams that participated in the bidding process. This will be our denominator in the percentage calculation.&lt;br /&gt;
&lt;br /&gt;
ii) Calculate the Number of Teams for Each Priority: From our `bidding_details` method, we already have counts for how many teams bid on each topic as their #1, #2, and #3 choice (`@count1`, `@count2`, `@count3`). However, these counts are currently organized by topic. We would need to modify this to count how many teams got their #1, #2, and #3 choices as their assigned topic.&lt;br /&gt;
&lt;br /&gt;
iii) Calculate Percentages: Once we have the number of teams that got their #1, #2, and #3 choices, we can calculate the percentages by dividing these numbers by the total number of teams and multiplying by 100.&lt;br /&gt;
&lt;br /&gt;
'''Bidding_detail view:'''&lt;br /&gt;
&lt;br /&gt;
i) Update the View and Display Percentages: Above the table in our previous view, we can add a section to display these percentages.&lt;br /&gt;
&lt;br /&gt;
ii) Format the Display: We will use a bold heading for each percentage type and format the number to a fixed number of decimal places.&lt;br /&gt;
&lt;br /&gt;
iii) Ensure Responsiveness: Make sure the display of these percentages adjusts well to different screen sizes, maintaining readability and layout consistency. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 3. Test Plan ====&lt;br /&gt;
&lt;br /&gt;
According to the given test skeleton and the features we've implemented and to be implemented. Here are the testing ideas:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Context 1: When There Are No Bids or Assigned Teams'''&lt;br /&gt;
&lt;br /&gt;
Test 1: Check if we get empty arrays for bids and assigned teams after running the &amp;quot;bidding_details&amp;quot; method.&lt;br /&gt;
&lt;br /&gt;
Test 2: Check if the percentage of teams getting their #1, #2, and #3 choices are all 0.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Context 2: When There Are Bids and Assigned Teams for the Assignment'''&lt;br /&gt;
&lt;br /&gt;
Test 3: We would first set up a known distribution of bids across different priority levels. After executing the &amp;quot;bidding_details&amp;quot; method, the test verifies that the returned count of bids for each priority level matches the expected distribution set up in the test environment.&lt;br /&gt;
&lt;br /&gt;
Test 4: Ensure that the method correctly identifies and returns the assigned teams for each topic. In this test, the setup would include an assignment with pre-assigned teams to various topics. The &amp;quot;bidding_details&amp;quot; method is then called, and the test checks whether the method accurately returns the list of assigned teams for each topic, as per the test setup.&lt;br /&gt;
&lt;br /&gt;
Test 5: Check if all teams bidding on a different topic, they all get the topic they want, and the percentage of #1 is 100%, while #2 and #3 are 0s.&lt;br /&gt;
&lt;br /&gt;
Test 6: Check if all teams bidding on the same topic, only one team gets the topic they want, and the percentage of #1 is (1/teams)%, while #2 and #3 are 0s.&lt;br /&gt;
&lt;br /&gt;
Test 7: Check if a team is a first/second/third team to bid on some topic, that topic is finally assigned to this team. In this case, #1, #2, or #3 is a non-zero value.&lt;br /&gt;
&lt;br /&gt;
Test 8: Provide mocking data and we pre-calculate the percentage value of #1, #2 and #3, check if the calculated values are the same as ours.&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=151617</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding (Phase2)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=151617"/>
		<updated>2023-11-16T02:41:03Z</updated>

		<summary type="html">&lt;p&gt;Schen76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Design Doc ==&lt;br /&gt;
&lt;br /&gt;
==== 1. Work Plan ====&lt;br /&gt;
&lt;br /&gt;
Based on the project's objectives and feedback received from our mentor, we have identified specific areas for improvement:&lt;br /&gt;
&lt;br /&gt;
i) Refactor variable names within methods such as &amp;quot;bidding_details&amp;quot; and variables like &amp;quot;Topic name&amp;quot; and &amp;quot;Bidding teams&amp;quot; to enhance clarity and specificity.&lt;br /&gt;
&lt;br /&gt;
ii) Adjust capitalization for certain components, ensuring that only the first word is capitalized for consistency.&lt;br /&gt;
&lt;br /&gt;
iii) Introduce calculations to determine percentages based on additional data, such as the total number of teams and the number of teams for each priority, within the &amp;quot;lottery_controller.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iv) Conduct thorough testing of the modified controller and view to ensure optimal functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 2. Design ====&lt;br /&gt;
&lt;br /&gt;
To add functionality for showing the percentages of the number of teams that got their #1, #2, and #3 choices. We can follow these high-level steps:&lt;br /&gt;
&lt;br /&gt;
'''Lottery_Controller:'''&lt;br /&gt;
&lt;br /&gt;
i) Calculate the Total Number of Teams: Before we can calculate percentages, we need to know the total number of teams that participated in the bidding process. This will be our denominator in the percentage calculation.&lt;br /&gt;
&lt;br /&gt;
ii) Calculate the Number of Teams for Each Priority: From our `bidding_details` method, we already have counts for how many teams bid on each topic as their #1, #2, and #3 choice (`@count1`, `@count2`, `@count3`). However, these counts are currently organized by topic. We would need to modify this to count how many teams got their #1, #2, and #3 choices as their assigned topic.&lt;br /&gt;
&lt;br /&gt;
iii) Calculate Percentages: Once we have the number of teams that got their #1, #2, and #3 choices, we can calculate the percentages by dividing these numbers by the total number of teams and multiplying by 100.&lt;br /&gt;
&lt;br /&gt;
'''Bidding_detail view:'''&lt;br /&gt;
&lt;br /&gt;
i) Update the View and Display Percentages: Above the table in our previous view, we can add a section to display these percentages.&lt;br /&gt;
&lt;br /&gt;
ii) Format the Display: We will use a bold heading for each percentage type and format the number to a fixed number of decimal places.&lt;br /&gt;
&lt;br /&gt;
iii) Ensure Responsiveness: Make sure the display of these percentages adjusts well to different screen sizes, maintaining readability and layout consistency. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== 3. Test Plan ====&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=151613</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding (Phase2)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=151613"/>
		<updated>2023-11-16T02:38:53Z</updated>

		<summary type="html">&lt;p&gt;Schen76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Design Doc ==&lt;br /&gt;
&lt;br /&gt;
''' 1. Work Plan '''&lt;br /&gt;
&lt;br /&gt;
Based on the project's objectives and feedback received from our mentor, we have identified specific areas for improvement:&lt;br /&gt;
&lt;br /&gt;
i) Refactor variable names within methods such as &amp;quot;bidding_details&amp;quot; and variables like &amp;quot;Topic name&amp;quot; and &amp;quot;Bidding teams&amp;quot; to enhance clarity and specificity.&lt;br /&gt;
&lt;br /&gt;
ii) Adjust capitalization for certain components, ensuring that only the first word is capitalized for consistency.&lt;br /&gt;
&lt;br /&gt;
iii) Introduce calculations to determine percentages based on additional data, such as the total number of teams and the number of teams for each priority, within the &amp;quot;lottery_controller.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iv) Conduct thorough testing of the modified controller and view to ensure optimal functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''' 2. Design '''&lt;br /&gt;
&lt;br /&gt;
To add functionality for showing the percentages of the number of teams that got their #1, #2, and #3 choices. We can follow these high-level steps:&lt;br /&gt;
&lt;br /&gt;
Lottery_Controller:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
i) Calculate the Total Number of Teams: Before we can calculate percentages, we need to know the total number of teams that participated in the bidding process. This will be our denominator in the percentage calculation.&lt;br /&gt;
&lt;br /&gt;
ii) Calculate the Number of Teams for Each Priority: From our `bidding_details` method, we already have counts for how many teams bid on each topic as their #1, #2, and #3 choice (`@count1`, `@count2`, `@count3`). However, these counts are currently organized by topic. We would need to modify this to count how many teams got their #1, #2, and #3 choices as their assigned topic.&lt;br /&gt;
&lt;br /&gt;
iii) Calculate Percentages: Once we have the number of teams that got their #1, #2, and #3 choices, we can calculate the percentages by dividing these numbers by the total number of teams and multiplying by 100.&lt;br /&gt;
&lt;br /&gt;
Bidding_detail view:&lt;br /&gt;
&lt;br /&gt;
i) Update the View and Display Percentages: Above the table in our previous view, we can add a section to display these percentages.&lt;br /&gt;
&lt;br /&gt;
ii) Format the Display: We will use a bold heading for each percentage type and format the number to a fixed number of decimal places.&lt;br /&gt;
&lt;br /&gt;
iii) Ensure Responsiveness: Make sure the display of these percentages adjusts well to different screen sizes, maintaining readability and layout consistency. &lt;br /&gt;
&lt;br /&gt;
''' 3. Test Plan '''&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=151610</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding (Phase2)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding_(Phase2)&amp;diff=151610"/>
		<updated>2023-11-16T02:36:52Z</updated>

		<summary type="html">&lt;p&gt;Schen76: Created page with &amp;quot; == Design Doc ==  ''' 1. Work Plan '''  Based on the project's objectives and feedback received from our mentor, we have identified specific areas for improvement:  i) Refact...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Design Doc ==&lt;br /&gt;
&lt;br /&gt;
''' 1. Work Plan '''&lt;br /&gt;
&lt;br /&gt;
Based on the project's objectives and feedback received from our mentor, we have identified specific areas for improvement:&lt;br /&gt;
&lt;br /&gt;
i) Refactor variable names within methods such as &amp;quot;bidding_details&amp;quot; and variables like &amp;quot;Topic name&amp;quot; and &amp;quot;Bidding teams&amp;quot; to enhance clarity and specificity.&lt;br /&gt;
&lt;br /&gt;
ii) Adjust capitalization for certain components, ensuring that only the first word is capitalized for consistency.&lt;br /&gt;
&lt;br /&gt;
iii) Introduce calculations to determine percentages based on additional data, such as the total number of teams and the number of teams for each priority, within the &amp;quot;lottery_controller.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iv) Conduct thorough testing of the modified controller and view to ensure optimal functionality.&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding&amp;diff=151169</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding&amp;diff=151169"/>
		<updated>2023-11-06T16:30:55Z</updated>

		<summary type="html">&lt;p&gt;Schen76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
When topics are opened up for bidding, students can see how “hot” each topic is by the color it has on their topic list. However, instructors have no way to view the bidding process except by impersonating students. Furthermore, when the bidding assignment algorithm is run, there is no way to verify that it did in fact assign teams to topics they had chosen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Previous Work ==&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE_517_Spring_2022_-_E2245:_View_for_results_of_bidding]]&lt;br /&gt;
&lt;br /&gt;
== Accomplishments ==&lt;br /&gt;
&lt;br /&gt;
This project added a &amp;quot;View Bidding Details&amp;quot; when the instructor enables the &amp;quot;bidding for topics&amp;quot; feature. By clicking it, it redirects us to a new page, where shows the following details of bidding:&lt;br /&gt;
&lt;br /&gt;
*Topic Name&lt;br /&gt;
*Bidding Teams&lt;br /&gt;
*Bidding Order&lt;br /&gt;
*The number of bidding a topic gets&lt;br /&gt;
&lt;br /&gt;
Also, for each topic, the team that wins the bidding will be highlighted with a yellow background color so that the instructor can easily find out which team each topic is assigned to.&lt;br /&gt;
&lt;br /&gt;
The button leads to a page that contains bidding information for the assignment. It displays the number of #1, #2, and #3 bids on a specific topic, the teams that bid and priority of their bid, and the name of the team that got assigned the topic is highlighted. &lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_button.png ‎| 888px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details.png ‎| 888px]]&lt;br /&gt;
&lt;br /&gt;
'''Files Involved:'''&lt;br /&gt;
&lt;br /&gt;
The files to be worked upon are:&lt;br /&gt;
&lt;br /&gt;
*./app/controllers/lottering_controller.rb&lt;br /&gt;
*./app/views/lottery/bidding_details.ntml.erb&lt;br /&gt;
*./app/assignments/edit/_topics.html.erb&lt;br /&gt;
*./spec/controllers/lottery_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
*Richard Li  rli14@ncsu.edu&lt;br /&gt;
*Shreshth Malik  smalik4@ncsu.edu&lt;br /&gt;
*Shuai Chen  schen76@ncsu.edu&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Implemented Code ==&lt;br /&gt;
&lt;br /&gt;
'''1. Lottering Controller'''&lt;br /&gt;
&lt;br /&gt;
File: ./app/controllers/lottering_controller.rb&lt;br /&gt;
&lt;br /&gt;
Method: &amp;quot;bidding_details&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''The controller for fetching topics and bids.'''&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details_controller.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
'''2. Bidding Details View'''&lt;br /&gt;
&lt;br /&gt;
File: ./app/views/lottery/bidding_details.ntml.erb&lt;br /&gt;
&lt;br /&gt;
'''Added a button and corresponding JavaScript which toggles its visibility based on “Enable bidding for topics?” checkbox.'''&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details_view.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
'''3. The button of View Bidding Details'''&lt;br /&gt;
&lt;br /&gt;
File: ./app/assignments/edit/_topics.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:View_bidding_button.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
File: ./spec/controllers/lottery_controller.spec.rb&lt;br /&gt;
&lt;br /&gt;
'''4. RSpec Testing on &amp;quot;bidding_details&amp;quot; Method'''&lt;br /&gt;
&lt;br /&gt;
File: ./spec/controllers/lottery_controller.spec.rb&lt;br /&gt;
&lt;br /&gt;
[[File:Rspec_testing.png | 888px]]&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding&amp;diff=151168</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding&amp;diff=151168"/>
		<updated>2023-11-06T16:29:15Z</updated>

		<summary type="html">&lt;p&gt;Schen76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
When topics are opened up for bidding, students can see how “hot” each topic is by the color it has on their topic list. However, instructors have no way to view the bidding process except by impersonating students. Furthermore, when the bidding assignment algorithm is run, there is no way to verify that it did in fact assign teams to topics they had chosen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Previous Work ==&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE_517_Spring_2022_-_E2245:_View_for_results_of_bidding]]&lt;br /&gt;
&lt;br /&gt;
== Accomplishments ==&lt;br /&gt;
&lt;br /&gt;
This project added a &amp;quot;View Bidding Details&amp;quot; when the instructor enables the &amp;quot;bidding for topics&amp;quot; feature. By clicking it, it redirects us to a new page, where shows the following details of bidding:&lt;br /&gt;
&lt;br /&gt;
*Topic Name&lt;br /&gt;
*Bidding Teams&lt;br /&gt;
*Bidding Order&lt;br /&gt;
*The number of bidding a topic gets&lt;br /&gt;
&lt;br /&gt;
Also, for each topic, the team that wins the bidding will be highlighted with a yellow background color so that the instructor can easily find out which team each topic is assigned to.&lt;br /&gt;
&lt;br /&gt;
The button leads to a page that contains bidding information for the assignment. It displays the number of #1, #2, and #3 bids on a specific topic, the teams that bid and priority of their bid, and the name of the team that got assigned the topic is highlighted. &lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_button.png ‎| 888px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details.png ‎| 888px]]&lt;br /&gt;
&lt;br /&gt;
'''Files Involved:'''&lt;br /&gt;
&lt;br /&gt;
The files to be worked upon are:&lt;br /&gt;
&lt;br /&gt;
*./app/controllers/lottering_controller.rb&lt;br /&gt;
*./app/views/lottery/bidding_details.ntml.erb&lt;br /&gt;
*./app/assignments/edit/_topics.html.erb&lt;br /&gt;
*./spec/controllers/lottery_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
*Richard Li  rli14@ncsu.edu&lt;br /&gt;
*Shreshth Malik  smalik4@ncsu.edu&lt;br /&gt;
*Shuai Chen  schen76@ncsu.edu&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Implemented Code ==&lt;br /&gt;
&lt;br /&gt;
'''1. Lottering Controller'''&lt;br /&gt;
&lt;br /&gt;
File: ./app/controllers/lottering_controller.rb&lt;br /&gt;
&lt;br /&gt;
Method: &amp;quot;bidding_details&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''Fetching topics and bids.'''&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details_controller.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
'''2. Bidding Details View'''&lt;br /&gt;
&lt;br /&gt;
File: ./app/views/lottery/bidding_details.ntml.erb&lt;br /&gt;
&lt;br /&gt;
'''Added a button and corresponding JavaScript which toggles its visibility based on “Enable bidding for topics?” checkbox.'''&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details_view.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
'''3. The button of View Bidding Details'''&lt;br /&gt;
&lt;br /&gt;
File: ./app/assignments/edit/_topics.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:View_bidding_button.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
File: ./spec/controllers/lottery_controller.spec.rb&lt;br /&gt;
&lt;br /&gt;
'''4. RSpec Testing on &amp;quot;bidding_details&amp;quot; Method'''&lt;br /&gt;
&lt;br /&gt;
File: ./spec/controllers/lottery_controller.spec.rb&lt;br /&gt;
&lt;br /&gt;
'''RSpec Testing on &amp;quot;bidding_details&amp;quot; method'''&lt;br /&gt;
&lt;br /&gt;
[[File:Rspec_testing.png | 888px]]&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding&amp;diff=151167</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding&amp;diff=151167"/>
		<updated>2023-11-06T16:26:13Z</updated>

		<summary type="html">&lt;p&gt;Schen76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
When topics are opened up for bidding, students can see how “hot” each topic is by the color it has on their topic list. However, instructors have no way to view the bidding process except by impersonating students. Furthermore, when the bidding assignment algorithm is run, there is no way to verify that it did in fact assign teams to topics they had chosen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Previous Work ==&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE_517_Spring_2022_-_E2245:_View_for_results_of_bidding]]&lt;br /&gt;
&lt;br /&gt;
== Accomplishments ==&lt;br /&gt;
&lt;br /&gt;
This project added a &amp;quot;View Bidding Details&amp;quot; when the instructor enables the &amp;quot;bidding for topics&amp;quot; feature. By clicking it, it redirects us to a new page, where shows the following details of bidding:&lt;br /&gt;
&lt;br /&gt;
*Topic Name&lt;br /&gt;
*Bidding Teams&lt;br /&gt;
*Bidding Order&lt;br /&gt;
*The number of bidding a topic gets&lt;br /&gt;
&lt;br /&gt;
Also, for each topic, the team that wins the bidding will be highlighted with a yellow background color so that the instructor can easily find out which team each topic is assigned to.&lt;br /&gt;
&lt;br /&gt;
The button leads to a page that contains bidding information for the assignment. It displays the number of #1, #2, and #3 bids on a specific topic, the teams that bid and priority of their bid, and the name of the team that got assigned the topic is highlighted. &lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_button.png ‎| 888px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details.png ‎| 888px]]&lt;br /&gt;
&lt;br /&gt;
'''Files Involved:'''&lt;br /&gt;
&lt;br /&gt;
The files to be worked upon are:&lt;br /&gt;
&lt;br /&gt;
*./app/controllers/lottering_controller.rb&lt;br /&gt;
*./app/views/lottery/bidding_details.ntml.erb&lt;br /&gt;
*./app/assignments/edit/_topics.html.erb&lt;br /&gt;
*./spec/controllers/lottery_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
*Richard Li  rli14@ncsu.edu&lt;br /&gt;
*Shreshth Malik  smalik4@ncsu.edu&lt;br /&gt;
*Shuai Chen  schen76@ncsu.edu&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Implemented Code ==&lt;br /&gt;
&lt;br /&gt;
'''1. Lottering Controller'''&lt;br /&gt;
&lt;br /&gt;
File: ./app/controllers/lottering_controller.rb&lt;br /&gt;
&lt;br /&gt;
Method: &amp;quot;bidding_details&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details_controller.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
'''2. Bidding Details View'''&lt;br /&gt;
&lt;br /&gt;
File: ./app/views/lottery/bidding_details.ntml.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details_view.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
'''3. The button of View Bidding Details'''&lt;br /&gt;
&lt;br /&gt;
File: ./app/assignments/edit/_topics.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:View_bidding_button.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
File: ./spec/controllers/lottery_controller.spec.rb&lt;br /&gt;
&lt;br /&gt;
'''4. RSpec Testing on &amp;quot;bidding_details&amp;quot; Method'''&lt;br /&gt;
&lt;br /&gt;
File: ./spec/controllers/lottery_controller.spec.rb&lt;br /&gt;
&lt;br /&gt;
[[File:Rspec_testing.png | 888px]]&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023&amp;diff=151134</id>
		<title>CSC/ECE 517 Fall 2023</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023&amp;diff=151134"/>
		<updated>2023-11-05T23:56:43Z</updated>

		<summary type="html">&lt;p&gt;Schen76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[CSC/ECE 517 Fall 2023 - E2350. Allow reviewers to bid on what to review]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2351. Finish mentor management for assignments without topics]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2353. Further refactoring and improvement of review mapping helper]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2355. Improving Search Facility In Expertiza]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2356. Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2357. Refactor sign_up_sheet_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2358. Refactor student_quizzes_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2359. Refactor user_controller.rb, user.rb, and its child classes]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2361. Create a page to create and update a Questionnaire in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2362. Create a page to edit an Assignment's due date in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2363. Create a UI for Assignment Edit page &amp;quot;Etc&amp;quot; tab in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2364. Create a UI for Course's &amp;amp; Assignment's &amp;quot;Add Participants&amp;quot; page]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2365. Create a user interface for Questionnaire in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2366. Reimplement assignment model and assignment controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2367. Reimplement participants_controller.rb, participants.rb and its child classes]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2368. Reimplement of due_date.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2369. Reimplement duties controller.rb and badges controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2370. Reimplement join team requests controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2371. Reimplement quiz_questionnaires_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2373. Reimplementation of teams controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2374. Reimplement the Question hierarchy]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2375. Reimplement Waitlists]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - NTX-2 Observability and Debuggability]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - NTX-4 Extend NDB Operator capabilities to support Postgres HA]]&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023-E2360._View_for_Results_of_Bidding&amp;diff=151133</id>
		<title>CSC/ECE 517 Fall 2023-E2360. View for Results of Bidding</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023-E2360._View_for_Results_of_Bidding&amp;diff=151133"/>
		<updated>2023-11-05T23:54:25Z</updated>

		<summary type="html">&lt;p&gt;Schen76: Blanked the page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding&amp;diff=151132</id>
		<title>CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding&amp;diff=151132"/>
		<updated>2023-11-05T23:54:03Z</updated>

		<summary type="html">&lt;p&gt;Schen76: Created page with &amp;quot;== Expertiza ==  [http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor t...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
When topics are opened up for bidding, students can see how “hot” each topic is by the color it has on their topic list. However, instructors have no way to view the bidding process except by impersonating students. Furthermore, when the bidding assignment algorithm is run, there is no way to verify that it did in fact assign teams to topics they had chosen.&lt;br /&gt;
&lt;br /&gt;
== Accomplishments ==&lt;br /&gt;
&lt;br /&gt;
This project added a &amp;quot;View Bidding Details&amp;quot; when the instructor enables the &amp;quot;bidding for topics&amp;quot; feature. By clicking it, it redirects us to a new page, where shows the following details of bidding:&lt;br /&gt;
&lt;br /&gt;
*Topic Name&lt;br /&gt;
*Bidding Teams&lt;br /&gt;
*Bidding Order&lt;br /&gt;
*The number of bidding a topic gets&lt;br /&gt;
&lt;br /&gt;
Also, for each topic, the team that wins the bidding will be highlighted with a yellow background color so that the instructor can easily find out which team each topic is assigned to.&lt;br /&gt;
&lt;br /&gt;
The button leads to a page that contains bidding information for the assignment. It displays the number of #1, #2, and #3 bids on a specific topic, the teams that bid and priority of their bid, and the name of the team that got assigned the topic is highlighted. &lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_button.png ‎| 888px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details.png ‎| 888px]]&lt;br /&gt;
&lt;br /&gt;
'''Files Involved:'''&lt;br /&gt;
&lt;br /&gt;
The files to be worked upon are:&lt;br /&gt;
&lt;br /&gt;
*./app/controllers/lottering_controller.rb&lt;br /&gt;
*./app/views/lottery/bidding_details.ntml.erb&lt;br /&gt;
*./app/assignments/edit/_topics.html.erb&lt;br /&gt;
*./spec/controllers/lottery_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
*Richard Li  rli14@ncsu.edu&lt;br /&gt;
*Shreshth Malik  smalik4@ncsu.edu&lt;br /&gt;
*Shuai Chen  schen76@ncsu.edu&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Implemented Code ==&lt;br /&gt;
&lt;br /&gt;
'''1. Lottering Controller'''&lt;br /&gt;
&lt;br /&gt;
File: ./app/controllers/lottering_controller.rb&lt;br /&gt;
&lt;br /&gt;
Method: &amp;quot;bidding_details&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details_controller.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
'''2. Bidding Details View'''&lt;br /&gt;
&lt;br /&gt;
File: ./app/views/lottery/bidding_details.ntml.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details_view.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
'''3. The button of View Bidding Details'''&lt;br /&gt;
&lt;br /&gt;
File: ./app/assignments/edit/_topics.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:View_bidding_button.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
File: ./spec/controllers/lottery_controller.spec.rb&lt;br /&gt;
&lt;br /&gt;
'''4. RSpec Testing on &amp;quot;bidding_details&amp;quot; Method'''&lt;br /&gt;
&lt;br /&gt;
File: ./spec/controllers/lottery_controller.spec.rb&lt;br /&gt;
&lt;br /&gt;
[[File:Rspec_testing.png | 888px]]&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023&amp;diff=151131</id>
		<title>CSC/ECE 517 Fall 2023</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023&amp;diff=151131"/>
		<updated>2023-11-05T23:53:46Z</updated>

		<summary type="html">&lt;p&gt;Schen76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[CSC/ECE 517 Fall 2023 - E2358. Refactor student_quizzes_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2351. Finish mentor management for assignments without topics]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2356. Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2359. Refactor user_controller.rb, user.rb, and its child classes]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2360. View for Results of Bidding]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2367. Reimplement participants_controller.rb, participants.rb and its child classes]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2355. Improving Search Facility In Expertiza]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2365. Create a user interface for Questionnaire in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2364. Create a UI for Course's &amp;amp; Assignment's &amp;quot;Add Participants&amp;quot; page]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2361. Create a page to create and update a Questionnaire in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2362. Create a page to edit an Assignment's due date in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2363. Create a UI for Assignment Edit page &amp;quot;Etc&amp;quot; tab in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2375. Reimplement Waitlists]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2357. Refactor sign_up_sheet_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2366. Reimplement assignment model and assignment controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2368. Reimplement of due_date.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2370. Reimplement join team requests controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2371. Reimplement quiz_questionnaires_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2369. Reimplement duties controller.rb and badges controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2353. Further refactoring and improvement of review mapping helper]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2373. Reimplementation of teams controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2374. Reimplement the Question hierarchy]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - NTX-2 Observability and Debuggability]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2350. Allow reviewers to bid on what to review]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - NTX-4 Extend NDB Operator capabilities to support Postgres HA]]&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023-E2360._View_for_Results_of_Bidding&amp;diff=151130</id>
		<title>CSC/ECE 517 Fall 2023-E2360. View for Results of Bidding</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023-E2360._View_for_Results_of_Bidding&amp;diff=151130"/>
		<updated>2023-11-05T23:51:10Z</updated>

		<summary type="html">&lt;p&gt;Schen76: Created page with &amp;quot;== Expertiza ==  [http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor t...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
When topics are opened up for bidding, students can see how “hot” each topic is by the color it has on their topic list. However, instructors have no way to view the bidding process except by impersonating students. Furthermore, when the bidding assignment algorithm is run, there is no way to verify that it did in fact assign teams to topics they had chosen.&lt;br /&gt;
&lt;br /&gt;
== Accomplishments ==&lt;br /&gt;
&lt;br /&gt;
This project added a &amp;quot;View Bidding Details&amp;quot; when the instructor enables the &amp;quot;bidding for topics&amp;quot; feature. By clicking it, it redirects us to a new page, where shows the following details of bidding:&lt;br /&gt;
&lt;br /&gt;
*Topic Name&lt;br /&gt;
*Bidding Teams&lt;br /&gt;
*Bidding Order&lt;br /&gt;
*The number of bidding a topic gets&lt;br /&gt;
&lt;br /&gt;
Also, for each topic, the team that wins the bidding will be highlighted with a yellow background color so that the instructor can easily find out which team each topic is assigned to.&lt;br /&gt;
&lt;br /&gt;
The button leads to a page that contains bidding information for the assignment. It displays the number of #1, #2, and #3 bids on a specific topic, the teams that bid and priority of their bid, and the name of the team that got assigned the topic is highlighted. &lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_button.png ‎| 888px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details.png ‎| 888px]]&lt;br /&gt;
&lt;br /&gt;
'''Files Involved:'''&lt;br /&gt;
&lt;br /&gt;
The files to be worked upon are:&lt;br /&gt;
&lt;br /&gt;
*./app/controllers/lottering_controller.rb&lt;br /&gt;
*./app/views/lottery/bidding_details.ntml.erb&lt;br /&gt;
*./app/assignments/edit/_topics.html.erb&lt;br /&gt;
*./spec/controllers/lottery_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''Team Members'''&lt;br /&gt;
&lt;br /&gt;
*Richard Li  rli14@ncsu.edu&lt;br /&gt;
*Shreshth Malik  smalik4@ncsu.edu&lt;br /&gt;
*Shuai Chen  schen76@ncsu.edu&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Implemented Code ==&lt;br /&gt;
&lt;br /&gt;
'''1. Lottering Controller'''&lt;br /&gt;
&lt;br /&gt;
File: ./app/controllers/lottering_controller.rb&lt;br /&gt;
&lt;br /&gt;
Method: &amp;quot;bidding_details&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details_controller.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
'''2. Bidding Details View'''&lt;br /&gt;
&lt;br /&gt;
File: ./app/views/lottery/bidding_details.ntml.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_details_view.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
'''3. The button of View Bidding Details'''&lt;br /&gt;
&lt;br /&gt;
File: ./app/assignments/edit/_topics.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:View_bidding_button.png | 888px]]&lt;br /&gt;
&lt;br /&gt;
File: ./spec/controllers/lottery_controller.spec.rb&lt;br /&gt;
&lt;br /&gt;
'''4. RSpec Testing on &amp;quot;bidding_details&amp;quot; Method'''&lt;br /&gt;
&lt;br /&gt;
File: ./spec/controllers/lottery_controller.spec.rb&lt;br /&gt;
&lt;br /&gt;
[[File:Rspec_testing.png | 888px]]&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Rspec_testing.png&amp;diff=151129</id>
		<title>File:Rspec testing.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Rspec_testing.png&amp;diff=151129"/>
		<updated>2023-11-05T23:50:10Z</updated>

		<summary type="html">&lt;p&gt;Schen76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:View_bidding_button.png&amp;diff=151128</id>
		<title>File:View bidding button.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:View_bidding_button.png&amp;diff=151128"/>
		<updated>2023-11-05T23:47:44Z</updated>

		<summary type="html">&lt;p&gt;Schen76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Bidding_details_view.png&amp;diff=151127</id>
		<title>File:Bidding details view.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Bidding_details_view.png&amp;diff=151127"/>
		<updated>2023-11-05T23:45:13Z</updated>

		<summary type="html">&lt;p&gt;Schen76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Bidding_details_controller.png&amp;diff=151126</id>
		<title>File:Bidding details controller.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Bidding_details_controller.png&amp;diff=151126"/>
		<updated>2023-11-05T23:42:41Z</updated>

		<summary type="html">&lt;p&gt;Schen76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Bidding_details.png&amp;diff=151125</id>
		<title>File:Bidding details.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Bidding_details.png&amp;diff=151125"/>
		<updated>2023-11-05T23:16:20Z</updated>

		<summary type="html">&lt;p&gt;Schen76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Bidding_button.png&amp;diff=151124</id>
		<title>File:Bidding button.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Bidding_button.png&amp;diff=151124"/>
		<updated>2023-11-05T23:13:17Z</updated>

		<summary type="html">&lt;p&gt;Schen76: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Schen76</name></author>
	</entry>
</feed>