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

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
 
(32 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Expertiza ==
== Introduction ==
[http://expertiza.ncsu.edu/ Expertiza] is an open-source web application built on Ruby on Rails that enables instructors to create customized assignments with topic lists for students to choose from. It facilitates team formation, allowing students to collaborate on assignments and projects. Expertiza supports peer review processes where students can provide feedback on each other's submissions across various document formats, including URLs and wiki pages. This freely available platform provides a flexible and comprehensive solution for managing assignments, teamwork, and peer evaluations.
The [http://expertiza.ncsu.edu/ Expertiza] project is a dynamic collaboration between students and faculty at NC State University, built on the Ruby on Rails platform. It serves as a hub for fostering cooperative learning and academic collaboration, offering a suite of tools for efficient course and assignment management.
 
Expertiza empowers instructors with comprehensive control over the learning process, providing insights into various academic facets such as user profiles, courses, assignments, questionnaires, and reviews. With its user-friendly interface and innovative features, Expertiza revolutionizes collaborative learning, facilitating seamless topic creation, group formation, and peer review. Join us in embracing the transformative potential of digital collaboration to redefine the educational experience.
 
== Problem Statement: ==
===Current Problem===
*Instructors using Expertiza lack comprehensive visibility into the bidding process, impeding their ability to discern the most sought-after topics by teams and the prioritization of choices, leading to inefficient allocation of projects.
 
===Key Deficiencies===
*The absence of essential details, such as which teams have bid on specific topics and the percentage of teams assigning their top-choice projects, results in instructors resorting to cumbersome workarounds, hindering effective management and allocation of projects.
 
===Proposed Solution===
*Enhancing Expertiza's interface with a dedicated view for instructors to access detailed statistics on topic bids, including priority rankings, team names, total bids, and the percentage of teams selecting each topic as their top choice. This solution aims to streamline workflow, empower instructors with valuable insights, and facilitate fair and efficient project allocation.
 
== Previous Implementations ==
#[https://github.com/Shreshth-Malik/expertiza E2360 Github Repository]
#[https://github.com/expertiza/expertiza/pull/2659 E2360 Pull Request]
#[https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2360._View_for_Results_of_Bidding E2360 Wiki Page]
#[https://www.youtube.com/watch?v=pGmHyqLj7PM Demo Video]
 
=== E2410 Current Implementation ===
#[https://github.com/saisanthoshG/expertiza Github Repository]
#[https://github.com/expertiza/expertiza/pull/2795 E2410 Pull Request]
#[https://youtu.be/g9DzKE5otSU Demo Video]
 
=== Issues With Previous Implementation ===
# There's a risk of repeating logic related to bidding across different parts of the application.
# UI elements and logic are intertwined within the controller, which is not ideal for MVC patterns.
# CSS styles are hard-coded in views, which should be abstracted to CSS files.
# Missing error handling could cause unhandled exceptions for nonexistent bids or topics.
# The UI lacks dynamic feedback mechanisms like AJAX updates for user interactions.
 
 
== Project Goal ==
 
The goal of this project is to enhance the Expertiza bidding system, making it more intuitive and efficient for both instructors and students. Our primary focus areas include:
 
*'''Clarity and Visibility:''' We aim to clearly present bidding results, featuring distinct columns for bid priorities and detailed team bid information.
 
*'''Separation of Concerns:''' Based on prior feedback, the bidding logic will be separated from the assignment controller to improve system maintainability and adhere to the Single Responsibility Principle.
 
*'''Enhanced Logic and Navigation:''' The project will introduce refined logic for calculating preferred choice percentages to ensure fairness in topic assignments. Additionally, bidding results will be moved to a dedicated page, improving the user experience by providing a focused and intuitive navigation by adding tooltip to show percentage calculation.
 
The UI/UX will be redesigned to minimize clutter, ensuring that information is visible only when necessary and enhancing the overall usability of the interface.
 
By achieving these objectives, we intend to significantly improve the bidding system in Expertiza, ensuring it is a more effective tool for educational environments.
 
== Design ==


== Introduction ==
The enhanced workflow in Expertiza enables instructors to manage and review student topic bids efficiently. With the new implementation, instructors visit the Assignments page, select an assignment, and activate the Topics tab to manage topics and enable bidding. A newly added "Show bids by priority" button takes users to a comprehensive bidding summary view. This view categorizes and displays detailed bid information, such as the number and percentage of first-choice bids, offering a clear visualization of students' preferences and facilitating fairer topic assignments.
We will be improving the UI for bidding view to appear less cluttered.
We're refactoring the assignment_controller.rb in Expertiza, adding a bidding_logic_controller.rb with a seperate method "topic_wise_bidding_teams" enhancing its codebase to adhere to design principles, improving readability, and reducing redundancy.


=== Sequence Diagram for Bidding Process ===


==Problem Statement==
[[File:Sequence Diagramb.jpeg|frameless|upright=3]]
The reimplementation project entails:


==Plan for Reimplementation of GradesController==
* Instructors can activate topic bidding with a single checkbox.
* The "Show bids by priority" button leads to a detailed summary view.
* Bids are categorized by priority, displaying #1, #2, and #3 bids.
* The percentage of first-choice bids is clearly presented.
* Bidding teams are listed for complete transparency.


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


#<b>Improving Bidding View:</b>
=== Current Flow ===
Files: app/views/assignments/edit/_topics.html.erb ⁠, ⁠app/views/assignments/n , bidding_details.html.erb
Consolidate the bidding details summary view into a single table for improved clarity and organization. Implement interactive features such as modals or tooltips to provide additional context or information.


#<b>Meaningful Method Names:</b>
* Go to the assignments section, we have created a dummy a assignment, "Test OODD", click edit icon next to it.
Files: app/controllers/assignment_controller.rb ⁠, ⁠ app/models/assignment.rb ⁠, ⁠ app/models/team.rb ⁠, ⁠ app/models/bid.rb ⁠
[[File:2410 1.jpeg|frameless|upright=3]]
Review existing method names and replace generic or unclear names with descriptive ones that accurately reflect their purpose and functionality ensuring consistency.


#<b>⁠Adherence to Design Principles:</b>
* Now make sure the "has topics" checkbox is selected.
Files: app/controllers/assignment_controller.rb ⁠, ⁠ app/models/assignment.rb ⁠, ⁠ app/models/team.rb ⁠, ⁠ app/models/bid.rb ⁠
[[File:24104.jpeg|frameless|upright=3]]
Refactor code segments to eliminate redundancy and promote code reusability. Stick to the design principles listed below.  
   
   
== Design Principles ==
* Now go to Topics section and click "Show bids by priority" button.
[[File:Topics_bid_button.jpg|frameless|upright=3]]
 
* Here you will be able to view various stats of the bidding,like the topics with their IDs, their respective topic names, number of teams that have put that specific topic as their 1st 2nd and 3rd priority bid, along with the names of those teams, the total number of bids and finally the percentage of teams that put the specific topic as their first bid. We can also see the tooltip for the calculation of the percentages when we hover over the percentages.
[[File:Tooltip.png|frameless|upright=3]]
 
=== Flow of the Bidding Process ===
* The instructor logs in to Expertiza with instructor credentials.
* They navigate to the Assignments page.
* An assignment is selected from the list and opened for editing.
* The instructor checks the "Has Topics" checkbox to activate the Topics tab.
* The Topics tab is then accessed to add a new topic.
* A new topic is created by filling out the new topic form and submitting it.
* This action updates the topic list, and students can begin bidding, assigning their 1st, 2nd, and 3rd priorities to topics.
* To view the bidding details, the instructor clicks the "Show bids by priority" button on the topics page.
 
== Implementation Details ==
=== Files Modified During the implementation ===
 
* assignments_controller.rb
* lottery_controller.rb
* assignment.rb
* bid.rb
* team.rb
* assignment_helper.rb
* _topics.html.erb
* bidding_details.html.erb
* _bid_summary_partial.html.erb
 
=== New functions that are implemented ===
====1. Display bidding summary based on priority details ====
==== [https://github.com/expertiza/expertiza/commit/92a7f87eaa07853678c0c922ce147a5e71c20661 Method for bidding analysis] ====
File : <code> app/controllers/lottery_controller.rb </code>
 
Functionality:
 
* Added `calculate_bidding_summary_based_on_priority` method to `lottery_controller` for aggregating bid data per topic.
* Prepares data for displaying the bidding details for each topic within an assignment.
* It calculates the number of bids for each priority (1, 2, 3) per topic and also computes
* The overall percentages of teams that received their first, second, and third choice.
* This method is responsible for calculating the bidding table data for an assignment.
* Computes the count of assigned teams for each priority level (1, 2, 3) across all topics.
* It checks each team associated with a topic and determines if the team's bid matches
 
[[File:Lottery_controller.jpeg|frameless|upright=3]]
 
===2. Background Color according to percentage===
====[https://github.com/expertiza/expertiza/commit/f111f8cc4edd9ebb904237fad185ab86eb4a4a86 Method for background color] ====
 
File : <code> app/helpers/lottery_helper.rb </code>
 
Functionality:
* Light red for low percentages
* Light orange for medium percentages
* Light green for high percentages
* No background if outside range
[[File:2_color.jpg|frameless|upright=3]]
 
===3. Button to show bids by priority===
==== [https://github.com/expertiza/expertiza/commit/11f7b788f6f8bca8dbbfb9477873db07823fc8e9 Button view] ====
File : <code> app/views/assignments/edit/_topics.html.erb </code>
 
Functionality:
 
*  ⁠Button to visit the seperate page to view the results of bidding
[[File:3_button.jpg|frameless|upright=3]]
 
===4. Bidding Summary Table ===
==== [https://github.com/expertiza/expertiza/commit/b798b78c8c6b649caa139044635b05ecd446a62e Summary Table] ====
File : <code> app/views/lottery/calculate_bidding_summary_based_on_priority.html.erb </code>
 
Functionality:
 
* View topics with their IDs,
* View topic names
* View number of teams that have bid on that specific topic as their 1st 2nd and 3rd priority bid,
* View the names of those teams
* View the total number of bids and finally the percentage of teams that put the specific topic as their first bid.
* View the percentage of first bids with tooltip and custom background
[[File:App-models-bid.rb.jpg|frameless|upright=3]]
 
== Accomplishment ==
Our recent project milestones have successfully optimized the topic bidding system in Expertiza. These enhancements focus on improving the instructor's user experience and providing comprehensive insights into student preferences during the topic selection process. The new features not only simplify the instructors' interaction with the system but also bring to light the trending topics that resonate most with students.
 
[[File:Topics_bid_button.jpg|frameless|upright=3]]
 
In this updated interface, instructors now have the ability to enable topic bidding with a simple checkbox selection, adding efficiency to the setup process. The interface also introduces a new button, "Show bids by priority," which serves as a gateway to a more detailed bid analysis. This new feature simplifies the instructor's oversight of the bidding process, consolidating all the necessary information in one place and enabling quick adjustments to topics based on student interest.
 
[[File:Tooltip.png|frameless|upright=3]]
 
Here, instructors can view the entire landscape of student bids in an organized and informative manner. The page lists topics alongside detailed bid data, such as the number of first, second, and third priority bids, total bids, and the teams that have placed those bids. It also features a calculated percentage of first-choice bids for each topic, providing immediate insight into student preferences. A tooltip offers a quick reference for understanding the calculation behind these percentages, ensuring transparency. This visualization tool allows instructors to discern which topics are trending and which may require additional promotion or reevaluation, streamlining the decision-making process without the need to switch between different views.
 
== Test Plan ==
 
=== Manual Testing ===
 
Follow these instructions to manually test the below functionality:
 
* Navigate to the assignments page and click on the pencil icon next to the 'Test OODD' assignment.
* Confirm that the 'Has Topics' checkbox is selected on the general assignment settings page.
* Move to the 'Topics' tab and check the 'Enable bidding for topics' option.
* Add a new topic for students to bid on by clicking the 'New Topic' button and entering relevant details.
* Log in as a student and bid on the new topic, choosing the priority level for the bid.
* Return to the 'Topics' tab as an instructor to view the updated bidding table with bids and priorities listed.
* Confirm that the total number of bids and the number of #1, #2, and #3 bids are displayed correctly for each topic.
* Check the background color coding (green, yellow, red) in the bidding table that reflects the intensity of bids for visual verification.
 
===RSpec Testing===
 
The lottery_controller_spec.rb has existing automated rspec tests in place. Furthermore following tests were added to the code to ensure the functionality is working as expected and thereby increasing code coverage:-
 
*'''Test for the method calculate_bidding_summary_based_on_priority in lottery_controller:'''
The test verifies that the calculate_bidding_summary_based_on_priority method accurately computes and returns a structured summary of bids for topics within an assignment, detailing the number of first, second, and third priority bids, total bids, the percentage of first priority bids, and the teams bidding on each topic.
<pre>describe '#calculate_bidding_summary_based_on_priority' do
    it 'calculates and returns bidding summary data for topics' do
      # Setup test data
      assignment = create(:assignment)
      topic = create(:topic, assignment: assignment)
      team = create(:team, assignment: assignment)
      bid = create(:bid, topic: topic, team: team, priority: 1)
      team_name = create(:team_name, team: team)
 
      allow(Assignment).to receive(:find).with(assignment.id).and_return(assignment)
      allow(assignment).to receive(:sign_up_topics).and_return([topic])
      allow(topic).to receive_message_chain(:bids, :includes).and_return([bid])
      allow(bid).to receive_message_chain(:team, :name).and_return(team_name)
 
      # Mock params
      params = { id: assignment.id }
      allow(controller).to receive(:params).and_return(params)
 
      # Expected data structure from calculate_bidding_summary_based_on_priority
      expected_topic_data = [
        {
          id: topic.id,
          name: topic.topic_name,
          first_bids: 1,
          second_bids: 0,
          third_bids: 0,
          total_bids: 1,
          percentage_first: 100.0,
          bidding_teams: [team_name]
        }
      ]
 
      # Call the method
      controller.instance_variable_set(:@assignment, assignment)
      expect(controller.calculate_bidding_summary_based_on_priority).to eq(expected_topic_data)
    end
  end
</pre>
 
The given test case, #calculate_bidding_summary_based_on_priority, is designed to verify the correct calculation and return of bidding summary data for topics within an assignment. It tests the scenario where a team has placed a bid with the highest priority on a topic. The setup involves creating mock instances of an assignment, a topic under that assignment, a team assigned to the topic, and a bid indicating the team's priority. The test confirms that the method accurately computes the total number of bids and the percentage of first-choice bids, and it ensures that the team's name is correctly associated with the bid in the summary. This case is crucial for the test plan as it ensures that the bidding summary accurately reflects student preferences and priorities in the bidding process, which is integral to the fair assignment of topics.


==== Single Responsibility Principle (SRP): ====
*'''Test for background color helper method:'''
*Each action in the GradesController will be responsible for a specific task related to managing grades.
The test suite for LotteryHelper#background_color_by_percentage method checks that it returns appropriate CSS background colors for low, medium, and high percentage values, and defaults to no background when the percentage is out of the 0-100% range.
*Actions will be refactored to separate concerns such as data retrieval, computation, and view rendering.
<pre>
*For example, the `view` action will focus solely on retrieving grading data and rendering the grading report.


==== Don't Repeat Yourself (DRY) Principle: ====
  # Assuming your helper module is in the helpers folder
*Code duplication in the GradesController will be eliminated by extracting common functionality into helper methods or modules.
  RSpec.describe LotteryHelper, type: :helper do
*Repetitive logic, such as retrieving questions or calculating penalties, will be refactored to promote code reusability and maintainability.
  # Test for low percentage range
  describe '#background_color_by_percentage' do
    it 'returns light red for low percentages' do
      expect(helper.background_color_by_percentage(10)).to eq('background-color: #ffcccc;')
    end


==== Dependency Inversion Principle (DIP): ====
    # Test for medium percentage range
*The GradesController will depend on abstractions, interfaces, or higher-level modules instead of concrete implementations.
    it 'returns light orange for medium percentages' do
*Dependency injection or inversion of control will be used to decouple the controller from specific database or service implementations.
      expect(helper.background_color_by_percentage(50)).to eq('background-color: #ffcc99;')
    end


    # Test for high percentage range
    it 'returns light green for high percentages' do
      expect(helper.background_color_by_percentage(80)).to eq('background-color: #ccffcc;')
    end
    # Test for percentage out of range
    it 'returns no background for percentages out of range' do
      expect(helper.background_color_by_percentage(101)).to eq('background-color: none;')
      expect(helper.background_color_by_percentage(-1)).to eq('background-color: none;')
    end
  end
end
</pre>
The test suite for the `LotteryHelper` module’s `#background_color_by_percentage` method ensures that the UI consistently displays the correct color codes for varying percentage ranges. It confirms that percentages within defined thresholds are mapped to specific background colors: light red for low, light orange for medium, and light green for high values. Additionally, it tests the method's response to percentages outside the 0-100% range, expecting no background color to be applied, thereby validating the method’s reliability in handling edge cases. This is a critical part of our test plan to ensure visual consistency and user-friendly feedback within the application.
== Demo Video ==
You can watch this [https://youtu.be/g9DzKE5otSU Demonstration Video]for a detailed demonstration of the project.


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


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

Latest revision as of 01:35, 24 April 2024

Introduction

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

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

Problem Statement:

Current Problem

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

Key Deficiencies

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

Proposed Solution

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

Previous Implementations

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

E2410 Current Implementation

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

Issues With Previous Implementation

  1. There's a risk of repeating logic related to bidding across different parts of the application.
  2. UI elements and logic are intertwined within the controller, which is not ideal for MVC patterns.
  3. CSS styles are hard-coded in views, which should be abstracted to CSS files.
  4. Missing error handling could cause unhandled exceptions for nonexistent bids or topics.
  5. The UI lacks dynamic feedback mechanisms like AJAX updates for user interactions.


Project Goal

The goal of this project is to enhance the Expertiza bidding system, making it more intuitive and efficient for both instructors and students. Our primary focus areas include:

  • Clarity and Visibility: We aim to clearly present bidding results, featuring distinct columns for bid priorities and detailed team bid information.
  • Separation of Concerns: Based on prior feedback, the bidding logic will be separated from the assignment controller to improve system maintainability and adhere to the Single Responsibility Principle.
  • Enhanced Logic and Navigation: The project will introduce refined logic for calculating preferred choice percentages to ensure fairness in topic assignments. Additionally, bidding results will be moved to a dedicated page, improving the user experience by providing a focused and intuitive navigation by adding tooltip to show percentage calculation.

The UI/UX will be redesigned to minimize clutter, ensuring that information is visible only when necessary and enhancing the overall usability of the interface.

By achieving these objectives, we intend to significantly improve the bidding system in Expertiza, ensuring it is a more effective tool for educational environments.

Design

The enhanced workflow in Expertiza enables instructors to manage and review student topic bids efficiently. With the new implementation, instructors visit the Assignments page, select an assignment, and activate the Topics tab to manage topics and enable bidding. A newly added "Show bids by priority" button takes users to a comprehensive bidding summary view. This view categorizes and displays detailed bid information, such as the number and percentage of first-choice bids, offering a clear visualization of students' preferences and facilitating fairer topic assignments.

Sequence Diagram for Bidding Process

  • Instructors can activate topic bidding with a single checkbox.
  • The "Show bids by priority" button leads to a detailed summary view.
  • Bids are categorized by priority, displaying #1, #2, and #3 bids.
  • The percentage of first-choice bids is clearly presented.
  • Bidding teams are listed for complete transparency.


Current Flow

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

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

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

  • Here you will be able to view various stats of the bidding,like the topics with their IDs, their respective topic names, number of teams that have put that specific topic as their 1st 2nd and 3rd priority bid, along with the names of those teams, the total number of bids and finally the percentage of teams that put the specific topic as their first bid. We can also see the tooltip for the calculation of the percentages when we hover over the percentages.

Flow of the Bidding Process

  • The instructor logs in to Expertiza with instructor credentials.
  • They navigate to the Assignments page.
  • An assignment is selected from the list and opened for editing.
  • The instructor checks the "Has Topics" checkbox to activate the Topics tab.
  • The Topics tab is then accessed to add a new topic.
  • A new topic is created by filling out the new topic form and submitting it.
  • This action updates the topic list, and students can begin bidding, assigning their 1st, 2nd, and 3rd priorities to topics.
  • To view the bidding details, the instructor clicks the "Show bids by priority" button on the topics page.

Implementation Details

Files Modified During the implementation

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

New functions that are implemented

1. Display bidding summary based on priority details

Method for bidding analysis

File : app/controllers/lottery_controller.rb

Functionality:

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

2. Background Color according to percentage

Method for background color

File : app/helpers/lottery_helper.rb

Functionality:

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

3. Button to show bids by priority

Button view

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

Functionality:

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

4. Bidding Summary Table

Summary Table

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

Functionality:

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

Accomplishment

Our recent project milestones have successfully optimized the topic bidding system in Expertiza. These enhancements focus on improving the instructor's user experience and providing comprehensive insights into student preferences during the topic selection process. The new features not only simplify the instructors' interaction with the system but also bring to light the trending topics that resonate most with students.

In this updated interface, instructors now have the ability to enable topic bidding with a simple checkbox selection, adding efficiency to the setup process. The interface also introduces a new button, "Show bids by priority," which serves as a gateway to a more detailed bid analysis. This new feature simplifies the instructor's oversight of the bidding process, consolidating all the necessary information in one place and enabling quick adjustments to topics based on student interest.

Here, instructors can view the entire landscape of student bids in an organized and informative manner. The page lists topics alongside detailed bid data, such as the number of first, second, and third priority bids, total bids, and the teams that have placed those bids. It also features a calculated percentage of first-choice bids for each topic, providing immediate insight into student preferences. A tooltip offers a quick reference for understanding the calculation behind these percentages, ensuring transparency. This visualization tool allows instructors to discern which topics are trending and which may require additional promotion or reevaluation, streamlining the decision-making process without the need to switch between different views.

Test Plan

Manual Testing

Follow these instructions to manually test the below functionality:

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

RSpec Testing

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

  • Test for the method calculate_bidding_summary_based_on_priority in lottery_controller:

The test verifies that the calculate_bidding_summary_based_on_priority method accurately computes and returns a structured summary of bids for topics within an assignment, detailing the number of first, second, and third priority bids, total bids, the percentage of first priority bids, and the teams bidding on each topic.

describe '#calculate_bidding_summary_based_on_priority' do
    it 'calculates and returns bidding summary data for topics' do
      # Setup test data
      assignment = create(:assignment)
      topic = create(:topic, assignment: assignment)
      team = create(:team, assignment: assignment)
      bid = create(:bid, topic: topic, team: team, priority: 1)
      team_name = create(:team_name, team: team)

      allow(Assignment).to receive(:find).with(assignment.id).and_return(assignment)
      allow(assignment).to receive(:sign_up_topics).and_return([topic])
      allow(topic).to receive_message_chain(:bids, :includes).and_return([bid])
      allow(bid).to receive_message_chain(:team, :name).and_return(team_name)

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

      # Expected data structure from calculate_bidding_summary_based_on_priority
      expected_topic_data = [
        {
          id: topic.id,
          name: topic.topic_name,
          first_bids: 1,
          second_bids: 0,
          third_bids: 0,
          total_bids: 1,
          percentage_first: 100.0,
          bidding_teams: [team_name]
        }
      ]

      # Call the method
      controller.instance_variable_set(:@assignment, assignment)
      expect(controller.calculate_bidding_summary_based_on_priority).to eq(expected_topic_data)
    end
  end

The given test case, #calculate_bidding_summary_based_on_priority, is designed to verify the correct calculation and return of bidding summary data for topics within an assignment. It tests the scenario where a team has placed a bid with the highest priority on a topic. The setup involves creating mock instances of an assignment, a topic under that assignment, a team assigned to the topic, and a bid indicating the team's priority. The test confirms that the method accurately computes the total number of bids and the percentage of first-choice bids, and it ensures that the team's name is correctly associated with the bid in the summary. This case is crucial for the test plan as it ensures that the bidding summary accurately reflects student preferences and priorities in the bidding process, which is integral to the fair assignment of topics.

  • Test for background color helper method:

The test suite for LotteryHelper#background_color_by_percentage method checks that it returns appropriate CSS background colors for low, medium, and high percentage values, and defaults to no background when the percentage is out of the 0-100% range.


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

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

    # Test for high percentage range
    it 'returns light green for high percentages' do
      expect(helper.background_color_by_percentage(80)).to eq('background-color: #ccffcc;')
    end

    # Test for percentage out of range
    it 'returns no background for percentages out of range' do
      expect(helper.background_color_by_percentage(101)).to eq('background-color: none;')
      expect(helper.background_color_by_percentage(-1)).to eq('background-color: none;')
    end
  end
end

The test suite for the `LotteryHelper` module’s `#background_color_by_percentage` method ensures that the UI consistently displays the correct color codes for varying percentage ranges. It confirms that percentages within defined thresholds are mapped to specific background colors: light red for low, light orange for medium, and light green for high values. Additionally, it tests the method's response to percentages outside the 0-100% range, expecting no background color to be applied, thereby validating the method’s reliability in handling edge cases. This is a critical part of our test plan to ensure visual consistency and user-friendly feedback within the application.

Demo Video

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

Team

Mentor:

  • Anvitha Reddy Gutha (agutha@ncsu.edu)

Members:

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

References