<?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=Akumarm</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=Akumarm"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Akumarm"/>
	<updated>2026-08-17T12:42:20Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2538_Reimplementing_Questionnaire_Page_in_Expertiza&amp;diff=164753</id>
		<title>CSC/ECE 517 Spring 2025 - E2538 Reimplementing Questionnaire Page in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2538_Reimplementing_Questionnaire_Page_in_Expertiza&amp;diff=164753"/>
		<updated>2025-04-22T21:45:26Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: /* Edit Rubric */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E2538 Reimplementing Questionnaire Page==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
Expertiza is an open-source web application currently built using [http://rubyonrails.org/ Ruby on Rails] and led by [https://www.csc.ncsu.edu/people/efg Dr. Edward Gehringer]. Designed for educational use, it enables instructors to manage assignments, rubrics, and participants, as well as assign grades and monitor student progress. Students can submit various types of learning objects, form teams, conduct peer evaluations, and review feedback from both peers and instructors. Originally developed at NC State, Expertiza is now used in select courses there and by faculty at other institutions, offering a flexible platform to enhance active learning and feedback in academic settings.&lt;br /&gt;
&lt;br /&gt;
The reimplementation of Expertiza aims to mimic and enhance the application’s existing functionality with clean, well-structured code, while transitioning to a front-end application written in React and Typescipt integrated with a Ruby on Rails back-end.&lt;br /&gt;
&lt;br /&gt;
==Project Overview==&lt;br /&gt;
The goal of this project is to implement the Questionnaire Management Dashboard and Create/Edit Rubric pages in Expertiza by reimplementing its frontend using React with TypeScript, while integrating it with the existing Ruby on Rails backend APIs in the reimplementation backend repo. The new implementation will improve user experience, maintainability, and scalability while preserving core functionalities.&lt;br /&gt;
&lt;br /&gt;
This project covers:&lt;br /&gt;
&lt;br /&gt;
* Developing a React-based UI for managing questionnaire rubrics.&lt;br /&gt;
&lt;br /&gt;
* Enabling navigation to a new page when clicking the &amp;quot;+&amp;quot; button to create a specific rubric for a questionnaire type.&lt;br /&gt;
&lt;br /&gt;
* Ensuring seamless API integration with the reimplementation backend repo.&lt;br /&gt;
&lt;br /&gt;
* Managing user sessions and authentication securely.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
While adhering to the following best practices: &lt;br /&gt;
&lt;br /&gt;
*&amp;lt;strong&amp;gt;Component Reusability (DRY Principle)&amp;lt;/strong&amp;gt;: Design reusable and modular components to avoid duplication and simplify maintenance, adhering to the &amp;quot;Don't Repeat Yourself&amp;quot; principle.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;strong&amp;gt;Separation of Concerns&amp;lt;/strong&amp;gt;: Keep the UI, state management, and business logic separated. Use container components for state and logic and presentational components for rendering.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;strong&amp;gt;Responsive and Accessible Design&amp;lt;/strong&amp;gt;: Ensure the UI adapts to different devices and meets accessibility standards (e.g., ARIA roles, keyboard navigation, and proper contrast).&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;strong&amp;gt;Type Safety with TypeScript&amp;lt;/strong&amp;gt;: Use TypeScript interfaces and types to ensure data consistency, reduce runtime errors.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;strong&amp;gt;Single Responsibility Principle&amp;lt;/strong&amp;gt;: Each component or function should have a single, well-defined purpose to improve clarity, testability, and scalability.&lt;br /&gt;
&lt;br /&gt;
==What Needs to be Done?==&lt;br /&gt;
===Questionnaire Management Dashboard===&lt;br /&gt;
&lt;br /&gt;
Displays a list of questionnaire types (Review, Metareview, Author Feedback, etc.)&lt;br /&gt;
* Each questionnaire type has a &amp;quot;+&amp;quot; button, which, when clicked, navigates to a new page for creating a specific rubric for that questionnaire type.&lt;br /&gt;
* Data is fetched dynamically from the backend.&lt;br /&gt;
&lt;br /&gt;
[[File:Picx1x.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
===Create/Edit Rubric Page===&lt;br /&gt;
&lt;br /&gt;
This page is displayed when a user clicks the &amp;quot;+&amp;quot; button from the dashboard.&lt;br /&gt;
&lt;br /&gt;
Allows users to:&lt;br /&gt;
* Enter a name for the rubric.&lt;br /&gt;
* Define min/max item scores.&lt;br /&gt;
* Set the review visibility (private/public).&lt;br /&gt;
* Add criteria for evaluation.&lt;br /&gt;
* Submit the form to create a new rubric for the selected questionnaire type.&lt;br /&gt;
&lt;br /&gt;
[[File:Picx2x.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
==Backend Integration==&lt;br /&gt;
&lt;br /&gt;
The frontend interacts with several key resources exposed by the backend through a RESTful API. The structure of each model's associated database table lets us define Typescript interfaces, transform request/response payloads and promote type safety.&lt;br /&gt;
&lt;br /&gt;
===Models===&lt;br /&gt;
&lt;br /&gt;
====Questionnaire====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;Questionnaire&amp;lt;/code&amp;gt; model forms the foundation of the Create/Edit form functionality, storing necessary attributes for each questionnaire. These fields are used to construct a form for editing or creating a rubric and to prepopulate the form when editing an existing rubric. &lt;br /&gt;
&lt;br /&gt;
The backend database also includes a table of &amp;lt;code&amp;gt;questionnaire_types&amp;lt;/code&amp;gt;, access to which would allow the Questionnaire Management Dashboard to dynamically render all available categories of questionnaires and enable users to initiate the creation process based on a selected type. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Attribute !! Description&lt;br /&gt;
|-&lt;br /&gt;
| id || Unique identifier for the questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| name || The name/title of the questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| instructor_id || Foreign key referencing the instructor who created it&lt;br /&gt;
|-&lt;br /&gt;
| private || Boolean indicating if the questionnaire is private&lt;br /&gt;
|-&lt;br /&gt;
| min_question_score || Minimum score that can be given to any question&lt;br /&gt;
|-&lt;br /&gt;
| max_question_score || Maximum score that can be given to any question&lt;br /&gt;
|-&lt;br /&gt;
| questionnaire_type || The type/category of questionnaire (e.g., Survey, Teammate Review)&lt;br /&gt;
|-&lt;br /&gt;
| display_type || Field for specifying how to display the questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| instruction_loc || Field for custom instructions location or reference&lt;br /&gt;
|-&lt;br /&gt;
| created_at || Timestamp of questionnaire creation&lt;br /&gt;
|-&lt;br /&gt;
| updated_at || Timestamp of last update&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Item====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;Item&amp;lt;/code&amp;gt; model represents individual items (or questions) within a questionnaire and includes attributes that should be included when adding an item to a particular questionnaire.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Attribute !! Description&lt;br /&gt;
|-&lt;br /&gt;
| id || Unique identifier for the item&lt;br /&gt;
|-&lt;br /&gt;
| txt || The text of the item/question&lt;br /&gt;
|-&lt;br /&gt;
| weight || The relative importance or weight of the item&lt;br /&gt;
|-&lt;br /&gt;
| seq || The sequence/order of the item in the questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| question_type || Foreign key referencing the type of question&lt;br /&gt;
|-&lt;br /&gt;
| size || Size attribute for text-based answers (e.g., text area size)&lt;br /&gt;
|-&lt;br /&gt;
| alternatives || Possible answer choices (comma-separated for multiple-choice)&lt;br /&gt;
|-&lt;br /&gt;
| break_before || Boolean indicating whether to insert a page break before the item&lt;br /&gt;
|-&lt;br /&gt;
| max_label || Optional label for the maximum scale value&lt;br /&gt;
|-&lt;br /&gt;
| min_label || Optional label for the minimum scale value&lt;br /&gt;
|-&lt;br /&gt;
| created_at || Timestamp of item creation&lt;br /&gt;
|-&lt;br /&gt;
| updated_at || Timestamp of last update&lt;br /&gt;
|-&lt;br /&gt;
| questionnaire_id || Foreign key referencing the associated questionnaire&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===API Endpoints===&lt;br /&gt;
&lt;br /&gt;
To facilitate interaction with the backend, the frontend uses a pre-configured &amp;lt;code&amp;gt;axiosClient&amp;lt;/code&amp;gt;, which abstracts the base API URL and port number. This client is defined in the &amp;lt;code&amp;gt;utils/axios_client.ts&amp;lt;/code&amp;gt; file and reused throughout the project for API communication. For questionnaire management, several key API routes are accessed using this client. For example, &amp;lt;code&amp;gt;GET /questionnaires/:id&amp;lt;/code&amp;gt; fetches detailed data for editing a selected questionnaire. When creating or updating a questionnaire, the application uses &amp;lt;code&amp;gt;POST /questionnaires&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PUT /questionnaires/:id&amp;lt;/code&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
! HTTP Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| GET || /questionnaires || Fetches a list of all questionnaires&lt;br /&gt;
|-&lt;br /&gt;
| GET || /questionnaires/:id || Fetches a specific questionnaire by ID&lt;br /&gt;
|-&lt;br /&gt;
| POST || /questionnaires || Creates a new questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| PUT || /questionnaires/:id || Updates an existing questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| DELETE || /questionnaires/:id || Deletes a specific questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| GET || /questions || Retrieves a list of all questions (items)&lt;br /&gt;
|-&lt;br /&gt;
| GET || /questions/:id || Retrieves a specific item, along with its rendered display&lt;br /&gt;
|-&lt;br /&gt;
| POST || /questions || Creates a new item for a questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| PUT || /questions/:id || Updates an existing item&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
===User Interface===&lt;br /&gt;
&lt;br /&gt;
====Manage Questionnaires====&lt;br /&gt;
&lt;br /&gt;
To navigate to the Questionnaire Management Dashboard, &amp;lt;strong&amp;gt;Questionnaire&amp;lt;/strong&amp;gt; from the &amp;lt;strong&amp;gt;Manage&amp;lt;/strong&amp;gt; dropdown from any page on Expertiza.&lt;br /&gt;
&lt;br /&gt;
To be consistent with other management pages (for Users, Courses, Assignements) in the reimplementation front end, a table of questionnaires belonging to the logged-in instructor is visible on the page. From this page, you may create, edit, or delete a questionnaire. &lt;br /&gt;
&lt;br /&gt;
To create a new questionnaire, click on the &amp;lt;strong&amp;gt;Create&amp;lt;/strong&amp;gt; button in the top left corner of the page. &lt;br /&gt;
&lt;br /&gt;
[[File:ManagementDashboard.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
====Type Selection====&lt;br /&gt;
&lt;br /&gt;
When the &amp;lt;strong&amp;gt;Create&amp;lt;/strong&amp;gt; button is selected from the top of the Questionnaire Management Dashboard, a pop-up appears with the available questionnaire types. To create a questionnaire of a given type, select the &amp;lt;strong&amp;gt;&amp;quot;+&amp;quot;&amp;lt;/strong&amp;gt; botton in the row of the desired type. &lt;br /&gt;
&lt;br /&gt;
[[File:TypeSelection.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
====Questionnaire Form====&lt;br /&gt;
&lt;br /&gt;
Once a type has been selected, the user is directed to the appropriate form to create a questionnaire of the selected type. The user can include a variable number of items to the questionnaire at the time of creation. The required fields for an item is determined by the item type. For example, a scale type item required minimum and maximum values for its scale. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire Form.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once a form field has been touched, the application alerts the user of missing required fields. Failure to provide appropriate values will prevent form submission. &lt;br /&gt;
&lt;br /&gt;
[[File:Screenshot 2025-04-22 at 10.12.22 AM.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Upon successful submission, the newly-created questionnaire will appear in the list of questionnaires in the Questionnaire Management Dashboard. &lt;br /&gt;
&lt;br /&gt;
[[File:Editquestionnaireselect.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To edit a questionnaire, select the edit icon next to the questionnaire you want to edit. You will be directed to a form with the existing questionnaire and items filled in. &lt;br /&gt;
&lt;br /&gt;
[[File:Editquestionnaire.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
===QuestionnaireUtils.ts===&lt;br /&gt;
The &amp;lt;code&amp;gt;QuestionnaireUtils.ts&amp;lt;/code&amp;gt; file serves as a utility module for handling questionnaire-related functionality in the application, including interfaces, data transformation methods, and back-end data retrieval. This file helps maintain clear separation of concerns, type safety, and adherence to design principles such as the Single Responsibility Principle (SRP).&lt;br /&gt;
&lt;br /&gt;
===QuestionnaireForm.tsx===&lt;br /&gt;
The &amp;lt;code&amp;gt;QuestionnaireForm.tsx&amp;lt;/code&amp;gt; file is a React component that provides a form interface for creating or editing questionnaires. It integrates with Formik for form state management and validation, utilizing React Bootstrap for UI elements.&lt;br /&gt;
&lt;br /&gt;
The form fields are strongly typed using Formik's &amp;lt;code&amp;gt;Field&amp;lt;/code&amp;gt; components and the &amp;lt;code&amp;gt;QuestionnaireFormValues&amp;lt;/code&amp;gt; interface, ensuring that the data entered by the user adheres to the correct structure.&lt;br /&gt;
*&amp;lt;strong&amp;gt;Name&amp;lt;/strong&amp;gt;: A text field for entering the questionnaire name.&lt;br /&gt;
*&amp;lt;strong&amp;gt;Type&amp;lt;/strong&amp;gt;: A hidden input used to specify the type of the questionnaire selected from the Questionnaire Management Dashboard and to be passed to the back-end.&lt;br /&gt;
*&amp;lt;strong&amp;gt;Private&amp;lt;/strong&amp;gt;: A checkbox to indicate whether the questionnaire is private.&lt;br /&gt;
*&amp;lt;strong&amp;gt;Minimum/Maximum Question Scores&amp;lt;/strong&amp;gt;: Numeric fields for setting the minimum and maximum scores for questions.&lt;br /&gt;
&lt;br /&gt;
The form delegates the responsibility of handling questionnaire items to the &amp;lt;code&amp;gt;QuestionnaireItemsFieldArray&amp;lt;/code&amp;gt; component, which allows users to add or remove items dynamically and keeps each component focused on a single responsibility.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===QuestionnaireTypes.tsx===&lt;br /&gt;
This component renders a table that displays different types of questionnaires. Each row provides an action to navigate to the corresponding creation page for the selected questionnaire type. The &amp;lt;code&amp;gt;Table&amp;lt;/code&amp;gt; component from &amp;lt;code&amp;gt;components/Table/Table&amp;lt;/code&amp;gt; is used in adherence with the DRY Principle and the provided design guidelines.&lt;br /&gt;
&lt;br /&gt;
==Code Changes Summary==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File !! Method / Function !! Before !! After / Changes Introduced !! Commit Summary&lt;br /&gt;
|-&lt;br /&gt;
| App.tsx || Routing to /questionnaire and /edit-questionnaire || Not defined or incomplete || Added `ProtectedRoute` wrappers and proper routing to `Questionnaire` and `EditQuestionnaire` || Updated App.tsx&lt;br /&gt;
|-&lt;br /&gt;
| Questionnaire.tsx || render(), type grouping || Basic list display || Grouped by type, added &amp;quot;+&amp;quot; button for creating new rubrics || Update Questionnaire.tsx&lt;br /&gt;
|-&lt;br /&gt;
| Questionnaire.tsx || Add rubric handler || Not implemented || Clicking &amp;quot;+&amp;quot; navigates to `edit-questionnaire` with type parameter || More UI updates&lt;br /&gt;
|-&lt;br /&gt;
| EditQuestionnaire.tsx || Form handling &amp;amp; API integration || Static layout || Full integration with axios POST/PUT calls to backend || updated interface so it can now update backend&lt;br /&gt;
|-&lt;br /&gt;
| EditQuestionnaire.tsx || Questionnaire name editing || Not available || Name can now be edited from the UI || More functionality updates&lt;br /&gt;
|-&lt;br /&gt;
| EditQuestionnaire.tsx || Display and manage rubric items || Static list || Dynamically displays and adds rubric items || Properly displays items and properly adds items&lt;br /&gt;
|-&lt;br /&gt;
| questionnaire.tsx || Icons and UI elements || No icons || Edit, delete, and copy icons added for each row || More UI updates, including icons&lt;br /&gt;
|-&lt;br /&gt;
| axios_client.ts || axios client usage || Not standardized || Shared axiosClient used for API calls across all pages || Integrated across changes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Files Modified==&lt;br /&gt;
The following files were created or modified to implement the questionnaire dashboard and rubric management UI in React with TypeScript:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;src/pages/Questionnaire/questionnaire.tsx&amp;lt;/code&amp;gt; – Implements the Questionnaire Management Dashboard UI and groups questionnaires by type with &amp;quot;+&amp;quot; action buttons.&lt;br /&gt;
*&amp;lt;code&amp;gt;src/pages/EditQuestionnaire/Questionnaire.tsx&amp;lt;/code&amp;gt; – Create/Edit Rubric page that handles full form logic and submission.&lt;br /&gt;
*&amp;lt;code&amp;gt;src/App.tsx&amp;lt;/code&amp;gt; – Updated routing to include new paths: &amp;lt;code&amp;gt;/questionnaire&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/edit-questionnaire&amp;lt;/code&amp;gt;, protected via &amp;lt;code&amp;gt;ProtectedRoute&amp;lt;/code&amp;gt;.&lt;br /&gt;
*&amp;lt;code&amp;gt;src/assets/icons/&amp;lt;/code&amp;gt; – Added new UI icons for edit, delete, and copy actions in the questionnaire list.&lt;br /&gt;
*&amp;lt;code&amp;gt;src/utils/axios_client.ts&amp;lt;/code&amp;gt; – Preconfigured &amp;lt;code&amp;gt;axios&amp;lt;/code&amp;gt; instance used throughout the frontend for API interactions.&lt;br /&gt;
*&amp;lt;code&amp;gt;package.json&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;package-lock.json&amp;lt;/code&amp;gt; – Updated dependencies for React Bootstrap, Formik, and icon support.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Note:&amp;lt;/strong&amp;gt; The previously separate files like &amp;lt;code&amp;gt;QuestionnaireForm.tsx&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;QuestionnaireItemsFieldArray.tsx&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;QuestionnaireUtils.tsx&amp;lt;/code&amp;gt; were refactored and consolidated into &amp;lt;code&amp;gt;EditQuestionnaire/Questionnaire.tsx&amp;lt;/code&amp;gt; for improved maintainability.&lt;br /&gt;
&lt;br /&gt;
==Test Plan - Manual Testing Strategy==&lt;br /&gt;
====Login Credentials====&lt;br /&gt;
To login to the application, use the following credentials:&lt;br /&gt;
* &amp;lt;strong&amp;gt;username:&amp;lt;/strong&amp;gt; instructor6  &lt;br /&gt;
* &amp;lt;strong&amp;gt;password:&amp;lt;/strong&amp;gt; password&lt;br /&gt;
&lt;br /&gt;
====Questionnaire Dashboard Loading====&lt;br /&gt;
* Visit &amp;lt;code&amp;gt;/questionnaire&amp;lt;/code&amp;gt; and confirm that all types of questionnaires are displayed.&lt;br /&gt;
* &amp;quot;+&amp;quot; button next to each type should open the rubric creation form with the correct type preselected.&lt;br /&gt;
&lt;br /&gt;
====Form Functionality====&lt;br /&gt;
* Enter name, min/max scores, and toggle the private/public checkbox.&lt;br /&gt;
* Dynamically add or remove criteria.&lt;br /&gt;
* Submit the form to create a new rubric and confirm it reflects on the dashboard.&lt;br /&gt;
&lt;br /&gt;
====Edit Rubric====&lt;br /&gt;
* Click on an existing rubric's &amp;quot;Edit&amp;quot; icon to load it in the edit form.&lt;br /&gt;
* Modify any field (name, score range, criteria) and resubmit.&lt;br /&gt;
* Confirm updated rubric details persist and are displayed correctly.&lt;br /&gt;
&lt;br /&gt;
====Form Validation====&lt;br /&gt;
* Leave required fields empty and confirm that validation messages are displayed.&lt;br /&gt;
* Enter invalid values (e.g., &amp;lt;code&amp;gt;max_score &amp;amp;lt; min_score&amp;lt;/code&amp;gt;) and confirm appropriate warnings are shown.&lt;br /&gt;
&lt;br /&gt;
====API Communication====&lt;br /&gt;
* Verify that form submissions trigger &amp;lt;code&amp;gt;POST /questionnaires&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;PUT /questionnaires/:id&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Confirm that response handling updates the UI appropriately (e.g., rerenders list on successful save).&lt;br /&gt;
&lt;br /&gt;
====UI Testing====&lt;br /&gt;
* Confirm that the layout is responsive across desktop, tablet, and mobile devices.&lt;br /&gt;
* Ensure accessibility: keyboard navigation works, form fields are properly labeled, and ARIA roles are used where needed.&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
*Prathyusha Kodali - pkodali&lt;br /&gt;
&lt;br /&gt;
=====Members===== &lt;br /&gt;
*Ashwin Muniswamy - akumarm&lt;br /&gt;
*Michael Anderson - mwander5&lt;br /&gt;
*Martina Viola - mmviola&lt;br /&gt;
&lt;br /&gt;
==Reference Links==&lt;br /&gt;
*[https://expertiza.ncsu.edu/tree_display/list?currCtlr=Questionnaires, Questionnaire Management Dashboard]&lt;br /&gt;
*[https://expertiza.ncsu.edu/questionnaires/new?model=ReviewQuestionnaire&amp;amp;private=1, Create/Edit Rubric Page]&lt;br /&gt;
*[https://github.com/Michael-Anderson-NCSU/reimplementation-front-end, Project Repo]&lt;br /&gt;
*[http://152.7.176.255:8080 VCL Deployment]&lt;br /&gt;
*[https://github.com/expertiza/reimplementation-front-end/pull/98, Pull Request]&lt;br /&gt;
&lt;br /&gt;
=====Demo Video=====&lt;br /&gt;
*[https://youtu.be/eVViM9_Gg80, Demo Video]&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2538_Reimplementing_Questionnaire_Page_in_Expertiza&amp;diff=164741</id>
		<title>CSC/ECE 517 Spring 2025 - E2538 Reimplementing Questionnaire Page in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2538_Reimplementing_Questionnaire_Page_in_Expertiza&amp;diff=164741"/>
		<updated>2025-04-22T21:13:56Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E2538 Reimplementing Questionnaire Page==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
Expertiza is an open-source web application currently built using [http://rubyonrails.org/ Ruby on Rails] and led by [https://www.csc.ncsu.edu/people/efg Dr. Edward Gehringer]. Designed for educational use, it enables instructors to manage assignments, rubrics, and participants, as well as assign grades and monitor student progress. Students can submit various types of learning objects, form teams, conduct peer evaluations, and review feedback from both peers and instructors. Originally developed at NC State, Expertiza is now used in select courses there and by faculty at other institutions, offering a flexible platform to enhance active learning and feedback in academic settings.&lt;br /&gt;
&lt;br /&gt;
The reimplementation of Expertiza aims to mimic and enhance the application’s existing functionality with clean, well-structured code, while transitioning to a front-end application written in React and Typescipt integrated with a Ruby on Rails back-end.&lt;br /&gt;
&lt;br /&gt;
==Project Overview==&lt;br /&gt;
The goal of this project is to implement the Questionnaire Management Dashboard and Create/Edit Rubric pages in Expertiza by reimplementing its frontend using React with TypeScript, while integrating it with the existing Ruby on Rails backend APIs in the reimplementation backend repo. The new implementation will improve user experience, maintainability, and scalability while preserving core functionalities.&lt;br /&gt;
&lt;br /&gt;
This project covers:&lt;br /&gt;
&lt;br /&gt;
* Developing a React-based UI for managing questionnaire rubrics.&lt;br /&gt;
&lt;br /&gt;
* Enabling navigation to a new page when clicking the &amp;quot;+&amp;quot; button to create a specific rubric for a questionnaire type.&lt;br /&gt;
&lt;br /&gt;
* Ensuring seamless API integration with the reimplementation backend repo.&lt;br /&gt;
&lt;br /&gt;
* Managing user sessions and authentication securely.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
While adhering to the following best practices: &lt;br /&gt;
&lt;br /&gt;
*&amp;lt;strong&amp;gt;Component Reusability (DRY Principle)&amp;lt;/strong&amp;gt;: Design reusable and modular components to avoid duplication and simplify maintenance, adhering to the &amp;quot;Don't Repeat Yourself&amp;quot; principle.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;strong&amp;gt;Separation of Concerns&amp;lt;/strong&amp;gt;: Keep the UI, state management, and business logic separated. Use container components for state and logic and presentational components for rendering.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;strong&amp;gt;Responsive and Accessible Design&amp;lt;/strong&amp;gt;: Ensure the UI adapts to different devices and meets accessibility standards (e.g., ARIA roles, keyboard navigation, and proper contrast).&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;strong&amp;gt;Type Safety with TypeScript&amp;lt;/strong&amp;gt;: Use TypeScript interfaces and types to ensure data consistency, reduce runtime errors.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;strong&amp;gt;Single Responsibility Principle&amp;lt;/strong&amp;gt;: Each component or function should have a single, well-defined purpose to improve clarity, testability, and scalability.&lt;br /&gt;
&lt;br /&gt;
==What Needs to be Done?==&lt;br /&gt;
===Questionnaire Management Dashboard===&lt;br /&gt;
&lt;br /&gt;
Displays a list of questionnaire types (Review, Metareview, Author Feedback, etc.)&lt;br /&gt;
* Each questionnaire type has a &amp;quot;+&amp;quot; button, which, when clicked, navigates to a new page for creating a specific rubric for that questionnaire type.&lt;br /&gt;
* Data is fetched dynamically from the backend.&lt;br /&gt;
&lt;br /&gt;
[[File:Picx1x.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
===Create/Edit Rubric Page===&lt;br /&gt;
&lt;br /&gt;
This page is displayed when a user clicks the &amp;quot;+&amp;quot; button from the dashboard.&lt;br /&gt;
&lt;br /&gt;
Allows users to:&lt;br /&gt;
* Enter a name for the rubric.&lt;br /&gt;
* Define min/max item scores.&lt;br /&gt;
* Set the review visibility (private/public).&lt;br /&gt;
* Add criteria for evaluation.&lt;br /&gt;
* Submit the form to create a new rubric for the selected questionnaire type.&lt;br /&gt;
&lt;br /&gt;
[[File:Picx2x.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
==Backend Integration==&lt;br /&gt;
&lt;br /&gt;
The frontend interacts with several key resources exposed by the backend through a RESTful API. The structure of each model's associated database table lets us define Typescript interfaces, transform request/response payloads and promote type safety.&lt;br /&gt;
&lt;br /&gt;
===Models===&lt;br /&gt;
&lt;br /&gt;
====Questionnaire====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;Questionnaire&amp;lt;/code&amp;gt; model forms the foundation of the Create/Edit form functionality, storing necessary attributes for each questionnaire. These fields are used to construct a form for editing or creating a rubric and to prepopulate the form when editing an existing rubric. &lt;br /&gt;
&lt;br /&gt;
The backend database also includes a table of &amp;lt;code&amp;gt;questionnaire_types&amp;lt;/code&amp;gt;, access to which would allow the Questionnaire Management Dashboard to dynamically render all available categories of questionnaires and enable users to initiate the creation process based on a selected type. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Attribute !! Description&lt;br /&gt;
|-&lt;br /&gt;
| id || Unique identifier for the questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| name || The name/title of the questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| instructor_id || Foreign key referencing the instructor who created it&lt;br /&gt;
|-&lt;br /&gt;
| private || Boolean indicating if the questionnaire is private&lt;br /&gt;
|-&lt;br /&gt;
| min_question_score || Minimum score that can be given to any question&lt;br /&gt;
|-&lt;br /&gt;
| max_question_score || Maximum score that can be given to any question&lt;br /&gt;
|-&lt;br /&gt;
| questionnaire_type || The type/category of questionnaire (e.g., Survey, Teammate Review)&lt;br /&gt;
|-&lt;br /&gt;
| display_type || Field for specifying how to display the questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| instruction_loc || Field for custom instructions location or reference&lt;br /&gt;
|-&lt;br /&gt;
| created_at || Timestamp of questionnaire creation&lt;br /&gt;
|-&lt;br /&gt;
| updated_at || Timestamp of last update&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Item====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;Item&amp;lt;/code&amp;gt; model represents individual items (or questions) within a questionnaire and includes attributes that should be included when adding an item to a particular questionnaire.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Attribute !! Description&lt;br /&gt;
|-&lt;br /&gt;
| id || Unique identifier for the item&lt;br /&gt;
|-&lt;br /&gt;
| txt || The text of the item/question&lt;br /&gt;
|-&lt;br /&gt;
| weight || The relative importance or weight of the item&lt;br /&gt;
|-&lt;br /&gt;
| seq || The sequence/order of the item in the questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| question_type || Foreign key referencing the type of question&lt;br /&gt;
|-&lt;br /&gt;
| size || Size attribute for text-based answers (e.g., text area size)&lt;br /&gt;
|-&lt;br /&gt;
| alternatives || Possible answer choices (comma-separated for multiple-choice)&lt;br /&gt;
|-&lt;br /&gt;
| break_before || Boolean indicating whether to insert a page break before the item&lt;br /&gt;
|-&lt;br /&gt;
| max_label || Optional label for the maximum scale value&lt;br /&gt;
|-&lt;br /&gt;
| min_label || Optional label for the minimum scale value&lt;br /&gt;
|-&lt;br /&gt;
| created_at || Timestamp of item creation&lt;br /&gt;
|-&lt;br /&gt;
| updated_at || Timestamp of last update&lt;br /&gt;
|-&lt;br /&gt;
| questionnaire_id || Foreign key referencing the associated questionnaire&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===API Endpoints===&lt;br /&gt;
&lt;br /&gt;
To facilitate interaction with the backend, the frontend uses a pre-configured &amp;lt;code&amp;gt;axiosClient&amp;lt;/code&amp;gt;, which abstracts the base API URL and port number. This client is defined in the &amp;lt;code&amp;gt;utils/axios_client.ts&amp;lt;/code&amp;gt; file and reused throughout the project for API communication. For questionnaire management, several key API routes are accessed using this client. For example, &amp;lt;code&amp;gt;GET /questionnaires/:id&amp;lt;/code&amp;gt; fetches detailed data for editing a selected questionnaire. When creating or updating a questionnaire, the application uses &amp;lt;code&amp;gt;POST /questionnaires&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PUT /questionnaires/:id&amp;lt;/code&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
! HTTP Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| GET || /questionnaires || Fetches a list of all questionnaires&lt;br /&gt;
|-&lt;br /&gt;
| GET || /questionnaires/:id || Fetches a specific questionnaire by ID&lt;br /&gt;
|-&lt;br /&gt;
| POST || /questionnaires || Creates a new questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| PUT || /questionnaires/:id || Updates an existing questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| DELETE || /questionnaires/:id || Deletes a specific questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| GET || /questions || Retrieves a list of all questions (items)&lt;br /&gt;
|-&lt;br /&gt;
| GET || /questions/:id || Retrieves a specific item, along with its rendered display&lt;br /&gt;
|-&lt;br /&gt;
| POST || /questions || Creates a new item for a questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| PUT || /questions/:id || Updates an existing item&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
===User Interface===&lt;br /&gt;
&lt;br /&gt;
====Manage Questionnaires====&lt;br /&gt;
&lt;br /&gt;
To navigate to the Questionnaire Management Dashboard, &amp;lt;strong&amp;gt;Questionnaire&amp;lt;/strong&amp;gt; from the &amp;lt;strong&amp;gt;Manage&amp;lt;/strong&amp;gt; dropdown from any page on Expertiza.&lt;br /&gt;
&lt;br /&gt;
To be consistent with other management pages (for Users, Courses, Assignements) in the reimplementation front end, a table of questionnaires belonging to the logged-in instructor is visible on the page. From this page, you may create, edit, or delete a questionnaire. &lt;br /&gt;
&lt;br /&gt;
To create a new questionnaire, click on the &amp;lt;strong&amp;gt;Create&amp;lt;/strong&amp;gt; button in the top left corner of the page. &lt;br /&gt;
&lt;br /&gt;
[[File:ManagementDashboard.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
====Type Selection====&lt;br /&gt;
&lt;br /&gt;
When the &amp;lt;strong&amp;gt;Create&amp;lt;/strong&amp;gt; button is selected from the top of the Questionnaire Management Dashboard, a pop-up appears with the available questionnaire types. To create a questionnaire of a given type, select the &amp;lt;strong&amp;gt;&amp;quot;+&amp;quot;&amp;lt;/strong&amp;gt; botton in the row of the desired type. &lt;br /&gt;
&lt;br /&gt;
[[File:TypeSelection.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
====Questionnaire Form====&lt;br /&gt;
&lt;br /&gt;
Once a type has been selected, the user is directed to the appropriate form to create a questionnaire of the selected type. The user can include a variable number of items to the questionnaire at the time of creation. The required fields for an item is determined by the item type. For example, a scale type item required minimum and maximum values for its scale. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire Form.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once a form field has been touched, the application alerts the user of missing required fields. Failure to provide appropriate values will prevent form submission. &lt;br /&gt;
&lt;br /&gt;
[[File:Screenshot 2025-04-22 at 10.12.22 AM.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Upon successful submission, the newly-created questionnaire will appear in the list of questionnaires in the Questionnaire Management Dashboard. &lt;br /&gt;
&lt;br /&gt;
[[File:Editquestionnaireselect.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To edit a questionnaire, select the edit icon next to the questionnaire you want to edit. You will be directed to a form with the existing questionnaire and items filled in. &lt;br /&gt;
&lt;br /&gt;
[[File:Editquestionnaire.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
===QuestionnaireUtils.ts===&lt;br /&gt;
The &amp;lt;code&amp;gt;QuestionnaireUtils.ts&amp;lt;/code&amp;gt; file serves as a utility module for handling questionnaire-related functionality in the application, including interfaces, data transformation methods, and back-end data retrieval. This file helps maintain clear separation of concerns, type safety, and adherence to design principles such as the Single Responsibility Principle (SRP).&lt;br /&gt;
&lt;br /&gt;
===QuestionnaireForm.tsx===&lt;br /&gt;
The &amp;lt;code&amp;gt;QuestionnaireForm.tsx&amp;lt;/code&amp;gt; file is a React component that provides a form interface for creating or editing questionnaires. It integrates with Formik for form state management and validation, utilizing React Bootstrap for UI elements.&lt;br /&gt;
&lt;br /&gt;
The form fields are strongly typed using Formik's &amp;lt;code&amp;gt;Field&amp;lt;/code&amp;gt; components and the &amp;lt;code&amp;gt;QuestionnaireFormValues&amp;lt;/code&amp;gt; interface, ensuring that the data entered by the user adheres to the correct structure.&lt;br /&gt;
*&amp;lt;strong&amp;gt;Name&amp;lt;/strong&amp;gt;: A text field for entering the questionnaire name.&lt;br /&gt;
*&amp;lt;strong&amp;gt;Type&amp;lt;/strong&amp;gt;: A hidden input used to specify the type of the questionnaire selected from the Questionnaire Management Dashboard and to be passed to the back-end.&lt;br /&gt;
*&amp;lt;strong&amp;gt;Private&amp;lt;/strong&amp;gt;: A checkbox to indicate whether the questionnaire is private.&lt;br /&gt;
*&amp;lt;strong&amp;gt;Minimum/Maximum Question Scores&amp;lt;/strong&amp;gt;: Numeric fields for setting the minimum and maximum scores for questions.&lt;br /&gt;
&lt;br /&gt;
The form delegates the responsibility of handling questionnaire items to the &amp;lt;code&amp;gt;QuestionnaireItemsFieldArray&amp;lt;/code&amp;gt; component, which allows users to add or remove items dynamically and keeps each component focused on a single responsibility.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===QuestionnaireTypes.tsx===&lt;br /&gt;
This component renders a table that displays different types of questionnaires. Each row provides an action to navigate to the corresponding creation page for the selected questionnaire type. The &amp;lt;code&amp;gt;Table&amp;lt;/code&amp;gt; component from &amp;lt;code&amp;gt;components/Table/Table&amp;lt;/code&amp;gt; is used in adherence with the DRY Principle and the provided design guidelines.&lt;br /&gt;
&lt;br /&gt;
==Code Changes Summary==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File !! Method / Function !! Before !! After / Changes Introduced !! Commit Summary&lt;br /&gt;
|-&lt;br /&gt;
| App.tsx || Routing to /questionnaire and /edit-questionnaire || Not defined or incomplete || Added `ProtectedRoute` wrappers and proper routing to `Questionnaire` and `EditQuestionnaire` || Updated App.tsx&lt;br /&gt;
|-&lt;br /&gt;
| Questionnaire.tsx || render(), type grouping || Basic list display || Grouped by type, added &amp;quot;+&amp;quot; button for creating new rubrics || Update Questionnaire.tsx&lt;br /&gt;
|-&lt;br /&gt;
| Questionnaire.tsx || Add rubric handler || Not implemented || Clicking &amp;quot;+&amp;quot; navigates to `edit-questionnaire` with type parameter || More UI updates&lt;br /&gt;
|-&lt;br /&gt;
| EditQuestionnaire.tsx || Form handling &amp;amp; API integration || Static layout || Full integration with axios POST/PUT calls to backend || updated interface so it can now update backend&lt;br /&gt;
|-&lt;br /&gt;
| EditQuestionnaire.tsx || Questionnaire name editing || Not available || Name can now be edited from the UI || More functionality updates&lt;br /&gt;
|-&lt;br /&gt;
| EditQuestionnaire.tsx || Display and manage rubric items || Static list || Dynamically displays and adds rubric items || Properly displays items and properly adds items&lt;br /&gt;
|-&lt;br /&gt;
| questionnaire.tsx || Icons and UI elements || No icons || Edit, delete, and copy icons added for each row || More UI updates, including icons&lt;br /&gt;
|-&lt;br /&gt;
| axios_client.ts || axios client usage || Not standardized || Shared axiosClient used for API calls across all pages || Integrated across changes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Files Modified==&lt;br /&gt;
The following files were created or modified to implement the questionnaire dashboard and rubric management UI in React with TypeScript:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;src/pages/Questionnaire/questionnaire.tsx&amp;lt;/code&amp;gt; – Implements the Questionnaire Management Dashboard UI and groups questionnaires by type with &amp;quot;+&amp;quot; action buttons.&lt;br /&gt;
*&amp;lt;code&amp;gt;src/pages/EditQuestionnaire/Questionnaire.tsx&amp;lt;/code&amp;gt; – Create/Edit Rubric page that handles full form logic and submission.&lt;br /&gt;
*&amp;lt;code&amp;gt;src/App.tsx&amp;lt;/code&amp;gt; – Updated routing to include new paths: &amp;lt;code&amp;gt;/questionnaire&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/edit-questionnaire&amp;lt;/code&amp;gt;, protected via &amp;lt;code&amp;gt;ProtectedRoute&amp;lt;/code&amp;gt;.&lt;br /&gt;
*&amp;lt;code&amp;gt;src/assets/icons/&amp;lt;/code&amp;gt; – Added new UI icons for edit, delete, and copy actions in the questionnaire list.&lt;br /&gt;
*&amp;lt;code&amp;gt;src/utils/axios_client.ts&amp;lt;/code&amp;gt; – Preconfigured &amp;lt;code&amp;gt;axios&amp;lt;/code&amp;gt; instance used throughout the frontend for API interactions.&lt;br /&gt;
*&amp;lt;code&amp;gt;package.json&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;package-lock.json&amp;lt;/code&amp;gt; – Updated dependencies for React Bootstrap, Formik, and icon support.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Note:&amp;lt;/strong&amp;gt; The previously separate files like &amp;lt;code&amp;gt;QuestionnaireForm.tsx&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;QuestionnaireItemsFieldArray.tsx&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;QuestionnaireUtils.tsx&amp;lt;/code&amp;gt; were refactored and consolidated into &amp;lt;code&amp;gt;EditQuestionnaire/Questionnaire.tsx&amp;lt;/code&amp;gt; for improved maintainability.&lt;br /&gt;
&lt;br /&gt;
==Test Plan - Manual Testing Strategy==&lt;br /&gt;
====Login Credentials====&lt;br /&gt;
To login to the application, use the following credentials:&lt;br /&gt;
* &amp;lt;strong&amp;gt;username:&amp;lt;/strong&amp;gt; instructor6  &lt;br /&gt;
* &amp;lt;strong&amp;gt;password:&amp;lt;/strong&amp;gt; password&lt;br /&gt;
&lt;br /&gt;
====Questionnaire Dashboard Loading====&lt;br /&gt;
* Visit &amp;lt;code&amp;gt;/questionnaire&amp;lt;/code&amp;gt; and confirm that all types of questionnaires are displayed.&lt;br /&gt;
* &amp;quot;+&amp;quot; button next to each type should open the rubric creation form with the correct type preselected.&lt;br /&gt;
&lt;br /&gt;
====Form Functionality====&lt;br /&gt;
* Enter name, min/max scores, and toggle the private/public checkbox.&lt;br /&gt;
* Dynamically add or remove criteria.&lt;br /&gt;
* Submit the form to create a new rubric and confirm it reflects on the dashboard.&lt;br /&gt;
&lt;br /&gt;
====Edit Rubric====&lt;br /&gt;
* Click on an existing rubric's ✏️ icon to load it in the edit form.&lt;br /&gt;
* Modify any field (name, score range, criteria) and resubmit.&lt;br /&gt;
* Confirm updated rubric details persist and are displayed correctly.&lt;br /&gt;
&lt;br /&gt;
====Form Validation====&lt;br /&gt;
* Leave required fields empty and confirm that validation messages are displayed.&lt;br /&gt;
* Enter invalid values (e.g., &amp;lt;code&amp;gt;max_score &amp;amp;lt; min_score&amp;lt;/code&amp;gt;) and confirm appropriate warnings are shown.&lt;br /&gt;
&lt;br /&gt;
====API Communication====&lt;br /&gt;
* Verify that form submissions trigger &amp;lt;code&amp;gt;POST /questionnaires&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;PUT /questionnaires/:id&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Confirm that response handling updates the UI appropriately (e.g., rerenders list on successful save).&lt;br /&gt;
&lt;br /&gt;
====UI Testing====&lt;br /&gt;
* Confirm that the layout is responsive across desktop, tablet, and mobile devices.&lt;br /&gt;
* Ensure accessibility: keyboard navigation works, form fields are properly labeled, and ARIA roles are used where needed.&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
*Prathyusha Kodali - pkodali&lt;br /&gt;
&lt;br /&gt;
=====Members===== &lt;br /&gt;
*Ashwin Muniswamy - akumarm&lt;br /&gt;
*Michael Anderson - mwander5&lt;br /&gt;
*Martina Viola - mmviola&lt;br /&gt;
&lt;br /&gt;
==Reference Links==&lt;br /&gt;
*[https://expertiza.ncsu.edu/tree_display/list?currCtlr=Questionnaires, Questionnaire Management Dashboard]&lt;br /&gt;
*[https://expertiza.ncsu.edu/questionnaires/new?model=ReviewQuestionnaire&amp;amp;private=1, Create/Edit Rubric Page]&lt;br /&gt;
*[https://github.com/Michael-Anderson-NCSU/reimplementation-front-end, Project Repo]&lt;br /&gt;
*[http://152.7.176.255:8080 VCL Deployment]&lt;br /&gt;
*[https://github.com/expertiza/reimplementation-front-end/pull/98, Pull Request]&lt;br /&gt;
&lt;br /&gt;
=====Demo Video=====&lt;br /&gt;
*[https://youtu.be/eVViM9_Gg80, Demo Video]&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2538_Reimplementing_Questionnaire_Page_in_Expertiza&amp;diff=164739</id>
		<title>CSC/ECE 517 Spring 2025 - E2538 Reimplementing Questionnaire Page in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2538_Reimplementing_Questionnaire_Page_in_Expertiza&amp;diff=164739"/>
		<updated>2025-04-22T21:09:57Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E2538 Reimplementing Questionnaire Page==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
Expertiza is an open-source web application currently built using [http://rubyonrails.org/ Ruby on Rails] and led by [https://www.csc.ncsu.edu/people/efg Dr. Edward Gehringer]. Designed for educational use, it enables instructors to manage assignments, rubrics, and participants, as well as assign grades and monitor student progress. Students can submit various types of learning objects, form teams, conduct peer evaluations, and review feedback from both peers and instructors. Originally developed at NC State, Expertiza is now used in select courses there and by faculty at other institutions, offering a flexible platform to enhance active learning and feedback in academic settings.&lt;br /&gt;
&lt;br /&gt;
The reimplementation of Expertiza aims to mimic and enhance the application’s existing functionality with clean, well-structured code, while transitioning to a front-end application written in React and Typescipt integrated with a Ruby on Rails back-end.&lt;br /&gt;
&lt;br /&gt;
==Project Overview==&lt;br /&gt;
The goal of this project is to implement the Questionnaire Management Dashboard and Create/Edit Rubric pages in Expertiza by reimplementing its frontend using React with TypeScript, while integrating it with the existing Ruby on Rails backend APIs in the reimplementation backend repo. The new implementation will improve user experience, maintainability, and scalability while preserving core functionalities.&lt;br /&gt;
&lt;br /&gt;
This project covers:&lt;br /&gt;
&lt;br /&gt;
* Developing a React-based UI for managing questionnaire rubrics.&lt;br /&gt;
&lt;br /&gt;
* Enabling navigation to a new page when clicking the &amp;quot;+&amp;quot; button to create a specific rubric for a questionnaire type.&lt;br /&gt;
&lt;br /&gt;
* Ensuring seamless API integration with the reimplementation backend repo.&lt;br /&gt;
&lt;br /&gt;
* Managing user sessions and authentication securely.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
While adhering to the following best practices: &lt;br /&gt;
&lt;br /&gt;
*&amp;lt;strong&amp;gt;Component Reusability (DRY Principle)&amp;lt;/strong&amp;gt;: Design reusable and modular components to avoid duplication and simplify maintenance, adhering to the &amp;quot;Don't Repeat Yourself&amp;quot; principle.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;strong&amp;gt;Separation of Concerns&amp;lt;/strong&amp;gt;: Keep the UI, state management, and business logic separated. Use container components for state and logic and presentational components for rendering.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;strong&amp;gt;Responsive and Accessible Design&amp;lt;/strong&amp;gt;: Ensure the UI adapts to different devices and meets accessibility standards (e.g., ARIA roles, keyboard navigation, and proper contrast).&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;strong&amp;gt;Type Safety with TypeScript&amp;lt;/strong&amp;gt;: Use TypeScript interfaces and types to ensure data consistency, reduce runtime errors.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;strong&amp;gt;Single Responsibility Principle&amp;lt;/strong&amp;gt;: Each component or function should have a single, well-defined purpose to improve clarity, testability, and scalability.&lt;br /&gt;
&lt;br /&gt;
==What Needs to be Done?==&lt;br /&gt;
===Questionnaire Management Dashboard===&lt;br /&gt;
&lt;br /&gt;
Displays a list of questionnaire types (Review, Metareview, Author Feedback, etc.)&lt;br /&gt;
* Each questionnaire type has a &amp;quot;+&amp;quot; button, which, when clicked, navigates to a new page for creating a specific rubric for that questionnaire type.&lt;br /&gt;
* Data is fetched dynamically from the backend.&lt;br /&gt;
&lt;br /&gt;
[[File:Picx1x.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
===Create/Edit Rubric Page===&lt;br /&gt;
&lt;br /&gt;
This page is displayed when a user clicks the &amp;quot;+&amp;quot; button from the dashboard.&lt;br /&gt;
&lt;br /&gt;
Allows users to:&lt;br /&gt;
* Enter a name for the rubric.&lt;br /&gt;
* Define min/max item scores.&lt;br /&gt;
* Set the review visibility (private/public).&lt;br /&gt;
* Add criteria for evaluation.&lt;br /&gt;
* Submit the form to create a new rubric for the selected questionnaire type.&lt;br /&gt;
&lt;br /&gt;
[[File:Picx2x.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
==Backend Integration==&lt;br /&gt;
&lt;br /&gt;
The frontend interacts with several key resources exposed by the backend through a RESTful API. The structure of each model's associated database table lets us define Typescript interfaces, transform request/response payloads and promote type safety.&lt;br /&gt;
&lt;br /&gt;
===Models===&lt;br /&gt;
&lt;br /&gt;
====Questionnaire====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;Questionnaire&amp;lt;/code&amp;gt; model forms the foundation of the Create/Edit form functionality, storing necessary attributes for each questionnaire. These fields are used to construct a form for editing or creating a rubric and to prepopulate the form when editing an existing rubric. &lt;br /&gt;
&lt;br /&gt;
The backend database also includes a table of &amp;lt;code&amp;gt;questionnaire_types&amp;lt;/code&amp;gt;, access to which would allow the Questionnaire Management Dashboard to dynamically render all available categories of questionnaires and enable users to initiate the creation process based on a selected type. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Attribute !! Description&lt;br /&gt;
|-&lt;br /&gt;
| id || Unique identifier for the questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| name || The name/title of the questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| instructor_id || Foreign key referencing the instructor who created it&lt;br /&gt;
|-&lt;br /&gt;
| private || Boolean indicating if the questionnaire is private&lt;br /&gt;
|-&lt;br /&gt;
| min_question_score || Minimum score that can be given to any question&lt;br /&gt;
|-&lt;br /&gt;
| max_question_score || Maximum score that can be given to any question&lt;br /&gt;
|-&lt;br /&gt;
| questionnaire_type || The type/category of questionnaire (e.g., Survey, Teammate Review)&lt;br /&gt;
|-&lt;br /&gt;
| display_type || Field for specifying how to display the questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| instruction_loc || Field for custom instructions location or reference&lt;br /&gt;
|-&lt;br /&gt;
| created_at || Timestamp of questionnaire creation&lt;br /&gt;
|-&lt;br /&gt;
| updated_at || Timestamp of last update&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Item====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;Item&amp;lt;/code&amp;gt; model represents individual items (or questions) within a questionnaire and includes attributes that should be included when adding an item to a particular questionnaire.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Attribute !! Description&lt;br /&gt;
|-&lt;br /&gt;
| id || Unique identifier for the item&lt;br /&gt;
|-&lt;br /&gt;
| txt || The text of the item/question&lt;br /&gt;
|-&lt;br /&gt;
| weight || The relative importance or weight of the item&lt;br /&gt;
|-&lt;br /&gt;
| seq || The sequence/order of the item in the questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| question_type || Foreign key referencing the type of question&lt;br /&gt;
|-&lt;br /&gt;
| size || Size attribute for text-based answers (e.g., text area size)&lt;br /&gt;
|-&lt;br /&gt;
| alternatives || Possible answer choices (comma-separated for multiple-choice)&lt;br /&gt;
|-&lt;br /&gt;
| break_before || Boolean indicating whether to insert a page break before the item&lt;br /&gt;
|-&lt;br /&gt;
| max_label || Optional label for the maximum scale value&lt;br /&gt;
|-&lt;br /&gt;
| min_label || Optional label for the minimum scale value&lt;br /&gt;
|-&lt;br /&gt;
| created_at || Timestamp of item creation&lt;br /&gt;
|-&lt;br /&gt;
| updated_at || Timestamp of last update&lt;br /&gt;
|-&lt;br /&gt;
| questionnaire_id || Foreign key referencing the associated questionnaire&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===API Endpoints===&lt;br /&gt;
&lt;br /&gt;
To facilitate interaction with the backend, the frontend uses a pre-configured &amp;lt;code&amp;gt;axiosClient&amp;lt;/code&amp;gt;, which abstracts the base API URL and port number. This client is defined in the &amp;lt;code&amp;gt;utils/axios_client.ts&amp;lt;/code&amp;gt; file and reused throughout the project for API communication. For questionnaire management, several key API routes are accessed using this client. For example, &amp;lt;code&amp;gt;GET /questionnaires/:id&amp;lt;/code&amp;gt; fetches detailed data for editing a selected questionnaire. When creating or updating a questionnaire, the application uses &amp;lt;code&amp;gt;POST /questionnaires&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PUT /questionnaires/:id&amp;lt;/code&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
! HTTP Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| GET || /questionnaires || Fetches a list of all questionnaires&lt;br /&gt;
|-&lt;br /&gt;
| GET || /questionnaires/:id || Fetches a specific questionnaire by ID&lt;br /&gt;
|-&lt;br /&gt;
| POST || /questionnaires || Creates a new questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| PUT || /questionnaires/:id || Updates an existing questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| DELETE || /questionnaires/:id || Deletes a specific questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| GET || /questions || Retrieves a list of all questions (items)&lt;br /&gt;
|-&lt;br /&gt;
| GET || /questions/:id || Retrieves a specific item, along with its rendered display&lt;br /&gt;
|-&lt;br /&gt;
| POST || /questions || Creates a new item for a questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| PUT || /questions/:id || Updates an existing item&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
===User Interface===&lt;br /&gt;
&lt;br /&gt;
====Manage Questionnaires====&lt;br /&gt;
&lt;br /&gt;
To navigate to the Questionnaire Management Dashboard, &amp;lt;strong&amp;gt;Questionnaire&amp;lt;/strong&amp;gt; from the &amp;lt;strong&amp;gt;Manage&amp;lt;/strong&amp;gt; dropdown from any page on Expertiza.&lt;br /&gt;
&lt;br /&gt;
To be consistent with other management pages (for Users, Courses, Assignements) in the reimplementation front end, a table of questionnaires belonging to the logged-in instructor is visible on the page. From this page, you may create, edit, or delete a questionnaire. &lt;br /&gt;
&lt;br /&gt;
To create a new questionnaire, click on the &amp;lt;strong&amp;gt;Create&amp;lt;/strong&amp;gt; button in the top left corner of the page. &lt;br /&gt;
&lt;br /&gt;
[[File:ManagementDashboard.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
====Type Selection====&lt;br /&gt;
&lt;br /&gt;
When the &amp;lt;strong&amp;gt;Create&amp;lt;/strong&amp;gt; button is selected from the top of the Questionnaire Management Dashboard, a pop-up appears with the available questionnaire types. To create a questionnaire of a given type, select the &amp;lt;strong&amp;gt;&amp;quot;+&amp;quot;&amp;lt;/strong&amp;gt; botton in the row of the desired type. &lt;br /&gt;
&lt;br /&gt;
[[File:TypeSelection.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
====Questionnaire Form====&lt;br /&gt;
&lt;br /&gt;
Once a type has been selected, the user is directed to the appropriate form to create a questionnaire of the selected type. The user can include a variable number of items to the questionnaire at the time of creation. The required fields for an item is determined by the item type. For example, a scale type item required minimum and maximum values for its scale. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire Form.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once a form field has been touched, the application alerts the user of missing required fields. Failure to provide appropriate values will prevent form submission. &lt;br /&gt;
&lt;br /&gt;
[[File:Screenshot 2025-04-22 at 10.12.22 AM.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Upon successful submission, the newly-created questionnaire will appear in the list of questionnaires in the Questionnaire Management Dashboard. &lt;br /&gt;
&lt;br /&gt;
[[File:Editquestionnaireselect.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To edit a questionnaire, select the edit icon next to the questionnaire you want to edit. You will be directed to a form with the existing questionnaire and items filled in. &lt;br /&gt;
&lt;br /&gt;
[[File:Editquestionnaire.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
===QuestionnaireUtils.ts===&lt;br /&gt;
The &amp;lt;code&amp;gt;QuestionnaireUtils.ts&amp;lt;/code&amp;gt; file serves as a utility module for handling questionnaire-related functionality in the application, including interfaces, data transformation methods, and back-end data retrieval. This file helps maintain clear separation of concerns, type safety, and adherence to design principles such as the Single Responsibility Principle (SRP).&lt;br /&gt;
&lt;br /&gt;
===QuestionnaireForm.tsx===&lt;br /&gt;
The &amp;lt;code&amp;gt;QuestionnaireForm.tsx&amp;lt;/code&amp;gt; file is a React component that provides a form interface for creating or editing questionnaires. It integrates with Formik for form state management and validation, utilizing React Bootstrap for UI elements.&lt;br /&gt;
&lt;br /&gt;
The form fields are strongly typed using Formik's &amp;lt;code&amp;gt;Field&amp;lt;/code&amp;gt; components and the &amp;lt;code&amp;gt;QuestionnaireFormValues&amp;lt;/code&amp;gt; interface, ensuring that the data entered by the user adheres to the correct structure.&lt;br /&gt;
*&amp;lt;strong&amp;gt;Name&amp;lt;/strong&amp;gt;: A text field for entering the questionnaire name.&lt;br /&gt;
*&amp;lt;strong&amp;gt;Type&amp;lt;/strong&amp;gt;: A hidden input used to specify the type of the questionnaire selected from the Questionnaire Management Dashboard and to be passed to the back-end.&lt;br /&gt;
*&amp;lt;strong&amp;gt;Private&amp;lt;/strong&amp;gt;: A checkbox to indicate whether the questionnaire is private.&lt;br /&gt;
*&amp;lt;strong&amp;gt;Minimum/Maximum Question Scores&amp;lt;/strong&amp;gt;: Numeric fields for setting the minimum and maximum scores for questions.&lt;br /&gt;
&lt;br /&gt;
The form delegates the responsibility of handling questionnaire items to the &amp;lt;code&amp;gt;QuestionnaireItemsFieldArray&amp;lt;/code&amp;gt; component, which allows users to add or remove items dynamically and keeps each component focused on a single responsibility.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===QuestionnaireTypes.tsx===&lt;br /&gt;
This component renders a table that displays different types of questionnaires. Each row provides an action to navigate to the corresponding creation page for the selected questionnaire type. The &amp;lt;code&amp;gt;Table&amp;lt;/code&amp;gt; component from &amp;lt;code&amp;gt;components/Table/Table&amp;lt;/code&amp;gt; is used in adherence with the DRY Principle and the provided design guidelines.&lt;br /&gt;
&lt;br /&gt;
==Code Changes Summary==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File !! Method / Function !! Before !! After / Changes Introduced !! Commit Summary&lt;br /&gt;
|-&lt;br /&gt;
| App.tsx || Routing to /questionnaire and /edit-questionnaire || Not defined or incomplete || Added `ProtectedRoute` wrappers and proper routing to `Questionnaire` and `EditQuestionnaire` || Updated App.tsx&lt;br /&gt;
|-&lt;br /&gt;
| Questionnaire.tsx || render(), type grouping || Basic list display || Grouped by type, added &amp;quot;+&amp;quot; button for creating new rubrics || Update Questionnaire.tsx&lt;br /&gt;
|-&lt;br /&gt;
| Questionnaire.tsx || Add rubric handler || Not implemented || Clicking &amp;quot;+&amp;quot; navigates to `edit-questionnaire` with type parameter || More UI updates&lt;br /&gt;
|-&lt;br /&gt;
| EditQuestionnaire.tsx || Form handling &amp;amp; API integration || Static layout || Full integration with axios POST/PUT calls to backend || updated interface so it can now update backend&lt;br /&gt;
|-&lt;br /&gt;
| EditQuestionnaire.tsx || Questionnaire name editing || Not available || Name can now be edited from the UI || More functionality updates&lt;br /&gt;
|-&lt;br /&gt;
| EditQuestionnaire.tsx || Display and manage rubric items || Static list || Dynamically displays and adds rubric items || Properly displays items and properly adds items&lt;br /&gt;
|-&lt;br /&gt;
| questionnaire.tsx || Icons and UI elements || No icons || Edit, delete, and copy icons added for each row || More UI updates, including icons&lt;br /&gt;
|-&lt;br /&gt;
| axios_client.ts || axios client usage || Not standardized || Shared axiosClient used for API calls across all pages || Integrated across changes&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Files Modified==&lt;br /&gt;
The following files were created or modified to implement the questionnaire dashboard and rubric management UI in React with TypeScript:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;src/pages/Questionnaires/Questionnaires.tsx&amp;lt;/code&amp;gt; – Implements the Questionnaire Management Dashboard UI.&lt;br /&gt;
*&amp;lt;code&amp;gt;src/pages/Questionnaires/QuestionnaireTypes.tsx&amp;lt;/code&amp;gt; – List of questionnaire types that may be created by the user. &lt;br /&gt;
*&amp;lt;code&amp;gt;src/pages/Questionnaires/QuestionnaireEditor.tsx&amp;lt;/code&amp;gt; – Create/Edit Rubric page that encapsultes form.&lt;br /&gt;
*&amp;lt;code&amp;gt;src/pages/Questionnaires/QuestionnaireForm.tsx&amp;lt;/code&amp;gt; – Form component for creating or editing questionnaires. &lt;br /&gt;
*&amp;lt;code&amp;gt;src/pages/Questionnaires/QuestionnaireItemsFieldArray.tsx&amp;lt;/code&amp;gt; – Supporting form component to dynamically create or update questionnaire items. &lt;br /&gt;
*&amp;lt;code&amp;gt;src/pages/Questionnaires/QuestionnaireUtils.tsx&amp;lt;/code&amp;gt; – Utility functions and interfaces for questionnaires.&lt;br /&gt;
*&amp;lt;code&amp;gt;src/App.tsx&amp;lt;/code&amp;gt; – Updated routing to include new questionnaire pages.&lt;br /&gt;
*&amp;lt;code&amp;gt;src/assets/icons/&amp;lt;/code&amp;gt; – Added new UI icons for editing, deleting, and copying questionnaires.&lt;br /&gt;
*&amp;lt;code&amp;gt;src/utils/axios_client.ts&amp;lt;/code&amp;gt; – Preconfigured axios instance used throughout the frontend for API calls.&lt;br /&gt;
*&amp;lt;code&amp;gt;package.json&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;package-lock.json&amp;lt;/code&amp;gt; – Updated dependencies for icons, React Bootstrap, and Formik support.&lt;br /&gt;
&lt;br /&gt;
==Test Plan - Manual Testing Strategy==&lt;br /&gt;
====Login Credentials====&lt;br /&gt;
To login to the application, use the following credentials:&lt;br /&gt;
* &amp;lt;strong&amp;gt;username:&amp;lt;/strong&amp;gt; instructor6&lt;br /&gt;
* &amp;lt;strong&amp;gt;password:&amp;lt;/strong&amp;gt; password&lt;br /&gt;
&lt;br /&gt;
====Questionnaire Dashboard Loading====&lt;br /&gt;
*Visit /questionnaire and confirm that all types of questionnaires are displayed.&lt;br /&gt;
*&amp;quot;+&amp;quot; button next to each type should open the rubric creation form for that type.&lt;br /&gt;
&lt;br /&gt;
====Form Functionality====&lt;br /&gt;
*Enter name, min/max scores, toggle private/public checkbox.&lt;br /&gt;
*Dynamically add/remove criteria.&lt;br /&gt;
*Submit form to create a new rubric and confirm it reflects in the backend.&lt;br /&gt;
&lt;br /&gt;
====Edit Rubric====&lt;br /&gt;
*Click on any existing rubric to load it in the edit form.&lt;br /&gt;
*Edit fields and submit changes. Confirm updated data is persisted.&lt;br /&gt;
&lt;br /&gt;
====Form Validation====&lt;br /&gt;
*Leave required fields empty and confirm validation errors appear.&lt;br /&gt;
*Enter invalid values (e.g., max &amp;lt; min) and confirm appropriate messages.&lt;br /&gt;
&lt;br /&gt;
====API Communication====&lt;br /&gt;
*Verified POST/PUT requests are correctly formatted.&lt;br /&gt;
*Backend updates reflected in UI after reload.&lt;br /&gt;
&lt;br /&gt;
====UI Testing====&lt;br /&gt;
*Confirm responsiveness across desktop, tablet, and mobile.&lt;br /&gt;
*Check accessibility: keyboard navigation, proper labeling.&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
*Prathyusha Kodali - pkodali&lt;br /&gt;
&lt;br /&gt;
=====Members===== &lt;br /&gt;
*Ashwin Muniswamy - akumarm&lt;br /&gt;
*Michael Anderson - mwander5&lt;br /&gt;
*Martina Viola - mmviola&lt;br /&gt;
&lt;br /&gt;
==Reference Links==&lt;br /&gt;
*[https://expertiza.ncsu.edu/tree_display/list?currCtlr=Questionnaires, Questionnaire Management Dashboard]&lt;br /&gt;
*[https://expertiza.ncsu.edu/questionnaires/new?model=ReviewQuestionnaire&amp;amp;private=1, Create/Edit Rubric Page]&lt;br /&gt;
*[https://github.com/Michael-Anderson-NCSU/reimplementation-front-end, Project Repo]&lt;br /&gt;
*[http://152.7.176.255:8080 VCL Deployment]&lt;br /&gt;
*[https://github.com/expertiza/reimplementation-front-end/pull/98, Pull Request]&lt;br /&gt;
&lt;br /&gt;
=====Demo Video=====&lt;br /&gt;
*[https://youtu.be/eVViM9_Gg80, Demo Video]&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2538_Reimplementing_Questionnaire_Page_in_Expertiza&amp;diff=164733</id>
		<title>CSC/ECE 517 Spring 2025 - E2538 Reimplementing Questionnaire Page in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2538_Reimplementing_Questionnaire_Page_in_Expertiza&amp;diff=164733"/>
		<updated>2025-04-22T21:01:44Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E2538 Reimplementing Questionnaire Page==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
Expertiza is an open-source web application currently built using [http://rubyonrails.org/ Ruby on Rails] and led by [https://www.csc.ncsu.edu/people/efg Dr. Edward Gehringer]. Designed for educational use, it enables instructors to manage assignments, rubrics, and participants, as well as assign grades and monitor student progress. Students can submit various types of learning objects, form teams, conduct peer evaluations, and review feedback from both peers and instructors. Originally developed at NC State, Expertiza is now used in select courses there and by faculty at other institutions, offering a flexible platform to enhance active learning and feedback in academic settings.&lt;br /&gt;
&lt;br /&gt;
The reimplementation of Expertiza aims to mimic and enhance the application’s existing functionality with clean, well-structured code, while transitioning to a front-end application written in React and Typescipt integrated with a Ruby on Rails back-end.&lt;br /&gt;
&lt;br /&gt;
==Project Overview==&lt;br /&gt;
The goal of this project is to implement the Questionnaire Management Dashboard and Create/Edit Rubric pages in Expertiza by reimplementing its frontend using React with TypeScript, while integrating it with the existing Ruby on Rails backend APIs in the reimplementation backend repo. The new implementation will improve user experience, maintainability, and scalability while preserving core functionalities.&lt;br /&gt;
&lt;br /&gt;
This project covers:&lt;br /&gt;
&lt;br /&gt;
* Developing a React-based UI for managing questionnaire rubrics.&lt;br /&gt;
&lt;br /&gt;
* Enabling navigation to a new page when clicking the &amp;quot;+&amp;quot; button to create a specific rubric for a questionnaire type.&lt;br /&gt;
&lt;br /&gt;
* Ensuring seamless API integration with the reimplementation backend repo.&lt;br /&gt;
&lt;br /&gt;
* Managing user sessions and authentication securely.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
While adhering to the following best practices: &lt;br /&gt;
&lt;br /&gt;
*&amp;lt;strong&amp;gt;Component Reusability (DRY Principle)&amp;lt;/strong&amp;gt;: Design reusable and modular components to avoid duplication and simplify maintenance, adhering to the &amp;quot;Don't Repeat Yourself&amp;quot; principle.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;strong&amp;gt;Separation of Concerns&amp;lt;/strong&amp;gt;: Keep the UI, state management, and business logic separated. Use container components for state and logic and presentational components for rendering.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;strong&amp;gt;Responsive and Accessible Design&amp;lt;/strong&amp;gt;: Ensure the UI adapts to different devices and meets accessibility standards (e.g., ARIA roles, keyboard navigation, and proper contrast).&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;strong&amp;gt;Type Safety with TypeScript&amp;lt;/strong&amp;gt;: Use TypeScript interfaces and types to ensure data consistency, reduce runtime errors.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;strong&amp;gt;Single Responsibility Principle&amp;lt;/strong&amp;gt;: Each component or function should have a single, well-defined purpose to improve clarity, testability, and scalability.&lt;br /&gt;
&lt;br /&gt;
==What Needs to be Done?==&lt;br /&gt;
===Questionnaire Management Dashboard===&lt;br /&gt;
&lt;br /&gt;
Displays a list of questionnaire types (Review, Metareview, Author Feedback, etc.)&lt;br /&gt;
* Each questionnaire type has a &amp;quot;+&amp;quot; button, which, when clicked, navigates to a new page for creating a specific rubric for that questionnaire type.&lt;br /&gt;
* Data is fetched dynamically from the backend.&lt;br /&gt;
&lt;br /&gt;
[[File:Picx1x.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
===Create/Edit Rubric Page===&lt;br /&gt;
&lt;br /&gt;
This page is displayed when a user clicks the &amp;quot;+&amp;quot; button from the dashboard.&lt;br /&gt;
&lt;br /&gt;
Allows users to:&lt;br /&gt;
* Enter a name for the rubric.&lt;br /&gt;
* Define min/max item scores.&lt;br /&gt;
* Set the review visibility (private/public).&lt;br /&gt;
* Add criteria for evaluation.&lt;br /&gt;
* Submit the form to create a new rubric for the selected questionnaire type.&lt;br /&gt;
&lt;br /&gt;
[[File:Picx2x.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
==Backend Integration==&lt;br /&gt;
&lt;br /&gt;
The frontend interacts with several key resources exposed by the backend through a RESTful API. The structure of each model's associated database table lets us define Typescript interfaces, transform request/response payloads and promote type safety.&lt;br /&gt;
&lt;br /&gt;
===Models===&lt;br /&gt;
&lt;br /&gt;
====Questionnaire====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;Questionnaire&amp;lt;/code&amp;gt; model forms the foundation of the Create/Edit form functionality, storing necessary attributes for each questionnaire. These fields are used to construct a form for editing or creating a rubric and to prepopulate the form when editing an existing rubric. &lt;br /&gt;
&lt;br /&gt;
The backend database also includes a table of &amp;lt;code&amp;gt;questionnaire_types&amp;lt;/code&amp;gt;, access to which would allow the Questionnaire Management Dashboard to dynamically render all available categories of questionnaires and enable users to initiate the creation process based on a selected type. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Attribute !! Description&lt;br /&gt;
|-&lt;br /&gt;
| id || Unique identifier for the questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| name || The name/title of the questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| instructor_id || Foreign key referencing the instructor who created it&lt;br /&gt;
|-&lt;br /&gt;
| private || Boolean indicating if the questionnaire is private&lt;br /&gt;
|-&lt;br /&gt;
| min_question_score || Minimum score that can be given to any question&lt;br /&gt;
|-&lt;br /&gt;
| max_question_score || Maximum score that can be given to any question&lt;br /&gt;
|-&lt;br /&gt;
| questionnaire_type || The type/category of questionnaire (e.g., Survey, Teammate Review)&lt;br /&gt;
|-&lt;br /&gt;
| display_type || Field for specifying how to display the questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| instruction_loc || Field for custom instructions location or reference&lt;br /&gt;
|-&lt;br /&gt;
| created_at || Timestamp of questionnaire creation&lt;br /&gt;
|-&lt;br /&gt;
| updated_at || Timestamp of last update&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Item====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;Item&amp;lt;/code&amp;gt; model represents individual items (or questions) within a questionnaire and includes attributes that should be included when adding an item to a particular questionnaire.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Attribute !! Description&lt;br /&gt;
|-&lt;br /&gt;
| id || Unique identifier for the item&lt;br /&gt;
|-&lt;br /&gt;
| txt || The text of the item/question&lt;br /&gt;
|-&lt;br /&gt;
| weight || The relative importance or weight of the item&lt;br /&gt;
|-&lt;br /&gt;
| seq || The sequence/order of the item in the questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| question_type || Foreign key referencing the type of question&lt;br /&gt;
|-&lt;br /&gt;
| size || Size attribute for text-based answers (e.g., text area size)&lt;br /&gt;
|-&lt;br /&gt;
| alternatives || Possible answer choices (comma-separated for multiple-choice)&lt;br /&gt;
|-&lt;br /&gt;
| break_before || Boolean indicating whether to insert a page break before the item&lt;br /&gt;
|-&lt;br /&gt;
| max_label || Optional label for the maximum scale value&lt;br /&gt;
|-&lt;br /&gt;
| min_label || Optional label for the minimum scale value&lt;br /&gt;
|-&lt;br /&gt;
| created_at || Timestamp of item creation&lt;br /&gt;
|-&lt;br /&gt;
| updated_at || Timestamp of last update&lt;br /&gt;
|-&lt;br /&gt;
| questionnaire_id || Foreign key referencing the associated questionnaire&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===API Endpoints===&lt;br /&gt;
&lt;br /&gt;
To facilitate interaction with the backend, the frontend uses a pre-configured &amp;lt;code&amp;gt;axiosClient&amp;lt;/code&amp;gt;, which abstracts the base API URL and port number. This client is defined in the &amp;lt;code&amp;gt;utils/axios_client.ts&amp;lt;/code&amp;gt; file and reused throughout the project for API communication. For questionnaire management, several key API routes are accessed using this client. For example, &amp;lt;code&amp;gt;GET /questionnaires/:id&amp;lt;/code&amp;gt; fetches detailed data for editing a selected questionnaire. When creating or updating a questionnaire, the application uses &amp;lt;code&amp;gt;POST /questionnaires&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PUT /questionnaires/:id&amp;lt;/code&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
! HTTP Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| GET || /questionnaires || Fetches a list of all questionnaires&lt;br /&gt;
|-&lt;br /&gt;
| GET || /questionnaires/:id || Fetches a specific questionnaire by ID&lt;br /&gt;
|-&lt;br /&gt;
| POST || /questionnaires || Creates a new questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| PUT || /questionnaires/:id || Updates an existing questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| DELETE || /questionnaires/:id || Deletes a specific questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| GET || /questions || Retrieves a list of all questions (items)&lt;br /&gt;
|-&lt;br /&gt;
| GET || /questions/:id || Retrieves a specific item, along with its rendered display&lt;br /&gt;
|-&lt;br /&gt;
| POST || /questions || Creates a new item for a questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| PUT || /questions/:id || Updates an existing item&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
===User Interface===&lt;br /&gt;
&lt;br /&gt;
====Manage Questionnaires====&lt;br /&gt;
&lt;br /&gt;
To navigate to the Questionnaire Management Dashboard, &amp;lt;strong&amp;gt;Questionnaire&amp;lt;/strong&amp;gt; from the &amp;lt;strong&amp;gt;Manage&amp;lt;/strong&amp;gt; dropdown from any page on Expertiza.&lt;br /&gt;
&lt;br /&gt;
To be consistent with other management pages (for Users, Courses, Assignements) in the reimplementation front end, a table of questionnaires belonging to the logged-in instructor is visible on the page. From this page, you may create, edit, or delete a questionnaire. &lt;br /&gt;
&lt;br /&gt;
To create a new questionnaire, click on the &amp;lt;strong&amp;gt;Create&amp;lt;/strong&amp;gt; button in the top left corner of the page. &lt;br /&gt;
&lt;br /&gt;
[[File:ManagementDashboard.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
====Type Selection====&lt;br /&gt;
&lt;br /&gt;
When the &amp;lt;strong&amp;gt;Create&amp;lt;/strong&amp;gt; button is selected from the top of the Questionnaire Management Dashboard, a pop-up appears with the available questionnaire types. To create a questionnaire of a given type, select the &amp;lt;strong&amp;gt;&amp;quot;+&amp;quot;&amp;lt;/strong&amp;gt; botton in the row of the desired type. &lt;br /&gt;
&lt;br /&gt;
[[File:TypeSelection.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
====Questionnaire Form====&lt;br /&gt;
&lt;br /&gt;
Once a type has been selected, the user is directed to the appropriate form to create a questionnaire of the selected type. The user can include a variable number of items to the questionnaire at the time of creation. The required fields for an item is determined by the item type. For example, a scale type item required minimum and maximum values for its scale. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire Form.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once a form field has been touched, the application alerts the user of missing required fields. Failure to provide appropriate values will prevent form submission. &lt;br /&gt;
&lt;br /&gt;
[[File:Screenshot 2025-04-22 at 10.12.22 AM.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Upon successful submission, the newly-created questionnaire will appear in the list of questionnaires in the Questionnaire Management Dashboard. &lt;br /&gt;
&lt;br /&gt;
[[File:Editquestionnaireselect.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To edit a questionnaire, select the edit icon next to the questionnaire you want to edit. You will be directed to a form with the existing questionnaire and items filled in. &lt;br /&gt;
&lt;br /&gt;
[[File:Editquestionnaire.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
===QuestionnaireUtils.ts===&lt;br /&gt;
The &amp;lt;code&amp;gt;QuestionnaireUtils.ts&amp;lt;/code&amp;gt; file serves as a utility module for handling questionnaire-related functionality in the application, including interfaces, data transformation methods, and back-end data retrieval. This file helps maintain clear separation of concerns, type safety, and adherence to design principles such as the Single Responsibility Principle (SRP).&lt;br /&gt;
&lt;br /&gt;
===QuestionnaireForm.tsx===&lt;br /&gt;
The &amp;lt;code&amp;gt;QuestionnaireForm.tsx&amp;lt;/code&amp;gt; file is a React component that provides a form interface for creating or editing questionnaires. It integrates with Formik for form state management and validation, utilizing React Bootstrap for UI elements.&lt;br /&gt;
&lt;br /&gt;
The form fields are strongly typed using Formik's &amp;lt;code&amp;gt;Field&amp;lt;/code&amp;gt; components and the &amp;lt;code&amp;gt;QuestionnaireFormValues&amp;lt;/code&amp;gt; interface, ensuring that the data entered by the user adheres to the correct structure.&lt;br /&gt;
*&amp;lt;strong&amp;gt;Name&amp;lt;/strong&amp;gt;: A text field for entering the questionnaire name.&lt;br /&gt;
*&amp;lt;strong&amp;gt;Type&amp;lt;/strong&amp;gt;: A hidden input used to specify the type of the questionnaire selected from the Questionnaire Management Dashboard and to be passed to the back-end.&lt;br /&gt;
*&amp;lt;strong&amp;gt;Private&amp;lt;/strong&amp;gt;: A checkbox to indicate whether the questionnaire is private.&lt;br /&gt;
*&amp;lt;strong&amp;gt;Minimum/Maximum Question Scores&amp;lt;/strong&amp;gt;: Numeric fields for setting the minimum and maximum scores for questions.&lt;br /&gt;
&lt;br /&gt;
The form delegates the responsibility of handling questionnaire items to the &amp;lt;code&amp;gt;QuestionnaireItemsFieldArray&amp;lt;/code&amp;gt; component, which allows users to add or remove items dynamically and keeps each component focused on a single responsibility.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===QuestionnaireTypes.tsx===&lt;br /&gt;
This component renders a table that displays different types of questionnaires. Each row provides an action to navigate to the corresponding creation page for the selected questionnaire type. The &amp;lt;code&amp;gt;Table&amp;lt;/code&amp;gt; component from &amp;lt;code&amp;gt;components/Table/Table&amp;lt;/code&amp;gt; is used in adherence with the DRY Principle and the provided design guidelines.&lt;br /&gt;
&lt;br /&gt;
==Files Modified==&lt;br /&gt;
The following files were created or modified to implement the questionnaire dashboard and rubric management UI in React with TypeScript:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;src/pages/Questionnaires/Questionnaires.tsx&amp;lt;/code&amp;gt; – Implements the Questionnaire Management Dashboard UI.&lt;br /&gt;
*&amp;lt;code&amp;gt;src/pages/Questionnaires/QuestionnaireTypes.tsx&amp;lt;/code&amp;gt; – List of questionnaire types that may be created by the user. &lt;br /&gt;
*&amp;lt;code&amp;gt;src/pages/Questionnaires/QuestionnaireEditor.tsx&amp;lt;/code&amp;gt; – Create/Edit Rubric page that encapsultes form.&lt;br /&gt;
*&amp;lt;code&amp;gt;src/pages/Questionnaires/QuestionnaireForm.tsx&amp;lt;/code&amp;gt; – Form component for creating or editing questionnaires. &lt;br /&gt;
*&amp;lt;code&amp;gt;src/pages/Questionnaires/QuestionnaireItemsFieldArray.tsx&amp;lt;/code&amp;gt; – Supporting form component to dynamically create or update questionnaire items. &lt;br /&gt;
*&amp;lt;code&amp;gt;src/pages/Questionnaires/QuestionnaireUtils.tsx&amp;lt;/code&amp;gt; – Utility functions and interfaces for questionnaires.&lt;br /&gt;
*&amp;lt;code&amp;gt;src/App.tsx&amp;lt;/code&amp;gt; – Updated routing to include new questionnaire pages.&lt;br /&gt;
*&amp;lt;code&amp;gt;src/assets/icons/&amp;lt;/code&amp;gt; – Added new UI icons for editing, deleting, and copying questionnaires.&lt;br /&gt;
*&amp;lt;code&amp;gt;src/utils/axios_client.ts&amp;lt;/code&amp;gt; – Preconfigured axios instance used throughout the frontend for API calls.&lt;br /&gt;
*&amp;lt;code&amp;gt;package.json&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;package-lock.json&amp;lt;/code&amp;gt; – Updated dependencies for icons, React Bootstrap, and Formik support.&lt;br /&gt;
&lt;br /&gt;
==Test Plan - Manual Testing Strategy==&lt;br /&gt;
====Login Credentials====&lt;br /&gt;
To login to the application, use the following credentials:&lt;br /&gt;
* &amp;lt;strong&amp;gt;username:&amp;lt;/strong&amp;gt; instructor6&lt;br /&gt;
* &amp;lt;strong&amp;gt;password:&amp;lt;/strong&amp;gt; password&lt;br /&gt;
&lt;br /&gt;
====Questionnaire Dashboard Loading====&lt;br /&gt;
*Visit /questionnaire and confirm that all types of questionnaires are displayed.&lt;br /&gt;
*&amp;quot;+&amp;quot; button next to each type should open the rubric creation form for that type.&lt;br /&gt;
&lt;br /&gt;
====Form Functionality====&lt;br /&gt;
*Enter name, min/max scores, toggle private/public checkbox.&lt;br /&gt;
*Dynamically add/remove criteria.&lt;br /&gt;
*Submit form to create a new rubric and confirm it reflects in the backend.&lt;br /&gt;
&lt;br /&gt;
====Edit Rubric====&lt;br /&gt;
*Click on any existing rubric to load it in the edit form.&lt;br /&gt;
*Edit fields and submit changes. Confirm updated data is persisted.&lt;br /&gt;
&lt;br /&gt;
====Form Validation====&lt;br /&gt;
*Leave required fields empty and confirm validation errors appear.&lt;br /&gt;
*Enter invalid values (e.g., max &amp;lt; min) and confirm appropriate messages.&lt;br /&gt;
&lt;br /&gt;
====API Communication====&lt;br /&gt;
*Verified POST/PUT requests are correctly formatted.&lt;br /&gt;
*Backend updates reflected in UI after reload.&lt;br /&gt;
&lt;br /&gt;
====UI Testing====&lt;br /&gt;
*Confirm responsiveness across desktop, tablet, and mobile.&lt;br /&gt;
*Check accessibility: keyboard navigation, proper labeling.&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
*Prathyusha Kodali - pkodali&lt;br /&gt;
&lt;br /&gt;
=====Members===== &lt;br /&gt;
*Ashwin Muniswamy - akumarm&lt;br /&gt;
*Michael Anderson - mwander5&lt;br /&gt;
*Martina Viola - mmviola&lt;br /&gt;
&lt;br /&gt;
==Reference Links==&lt;br /&gt;
*[https://expertiza.ncsu.edu/tree_display/list?currCtlr=Questionnaires, Questionnaire Management Dashboard]&lt;br /&gt;
*[https://expertiza.ncsu.edu/questionnaires/new?model=ReviewQuestionnaire&amp;amp;private=1, Create/Edit Rubric Page]&lt;br /&gt;
*[https://github.com/Michael-Anderson-NCSU/reimplementation-front-end, Project Repo]&lt;br /&gt;
*[http://152.7.176.255:8080 VCL Deployment]&lt;br /&gt;
*[https://github.com/expertiza/reimplementation-front-end/pull/98, Pull Request]&lt;br /&gt;
&lt;br /&gt;
=====Demo Video=====&lt;br /&gt;
*[https://youtu.be/eVViM9_Gg80, Demo Video]&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2538_Reimplementing_Questionnaire_Page_in_Expertiza&amp;diff=164442</id>
		<title>CSC/ECE 517 Spring 2025 - E2538 Reimplementing Questionnaire Page in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2538_Reimplementing_Questionnaire_Page_in_Expertiza&amp;diff=164442"/>
		<updated>2025-04-22T00:47:24Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E2538 Reimplementing Questionnaire Page==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
Expertiza is an open-source web application currently built using [http://rubyonrails.org/ Ruby on Rails] and led by [https://www.csc.ncsu.edu/people/efg Dr. Edward Gehringer]. Designed for educational use, it enables instructors to manage assignments, rubrics, and participants, as well as assign grades and monitor student progress. Students can submit various types of learning objects, form teams, conduct peer evaluations, and review feedback from both peers and instructors. Originally developed at NC State, Expertiza is now used in select courses there and by faculty at other institutions, offering a flexible platform to enhance active learning and feedback in academic settings.&lt;br /&gt;
&lt;br /&gt;
The reimplementation of Expertiza aims to mimic and enhance the application’s existing functionality with clean, well-structured code, while transitioning to a front-end application written in React and Typescipt integrated with a Ruby on Rails back-end.&lt;br /&gt;
&lt;br /&gt;
==Project Overview==&lt;br /&gt;
The goal of this project is to implement the Questionnaire Management Dashboard and Create/Edit Rubric pages in Expertiza by reimplementing its frontend using React with TypeScript, while integrating it with the existing Ruby on Rails backend APIs in the reimplementation backend repo. The new implementation will improve user experience, maintainability, and scalability while preserving core functionalities.&lt;br /&gt;
&lt;br /&gt;
This project covers:&lt;br /&gt;
&lt;br /&gt;
* Developing a React-based UI for managing questionnaire rubrics.&lt;br /&gt;
&lt;br /&gt;
* Enabling navigation to a new page when clicking the &amp;quot;+&amp;quot; button to create a specific rubric for a questionnaire type.&lt;br /&gt;
&lt;br /&gt;
* Ensuring seamless API integration with the reimplementation backend repo.&lt;br /&gt;
&lt;br /&gt;
* Managing user sessions and authentication securely.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
While adhering to the following best practices: &lt;br /&gt;
&lt;br /&gt;
*&amp;lt;strong&amp;gt;Component Reusability (DRY Principle)&amp;lt;/strong&amp;gt;: Design reusable and modular components to avoid duplication and simplify maintenance, adhering to the &amp;quot;Don't Repeat Yourself&amp;quot; principle.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;strong&amp;gt;Separation of Concerns&amp;lt;/strong&amp;gt;: Keep the UI, state management, and business logic separated. Use container components for state and logic and presentational components for rendering.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;strong&amp;gt;Responsive and Accessible Design&amp;lt;/strong&amp;gt;: Ensure the UI adapts to different devices and meets accessibility standards (e.g., ARIA roles, keyboard navigation, and proper contrast).&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;strong&amp;gt;Type Safety with TypeScript&amp;lt;/strong&amp;gt;: Use TypeScript interfaces and types to ensure data consistency, reduce runtime errors.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;strong&amp;gt;Single Responsibility Principle&amp;lt;/strong&amp;gt;: Each component or function should have a single, well-defined purpose to improve clarity, testability, and scalability.&lt;br /&gt;
&lt;br /&gt;
==What Needs to be Done?==&lt;br /&gt;
===Questionnaire Management Dashboard===&lt;br /&gt;
&lt;br /&gt;
Displays a list of questionnaire types (Review, Metareview, Author Feedback, etc.)&lt;br /&gt;
* Each questionnaire type has a &amp;quot;+&amp;quot; button, which, when clicked, navigates to a new page for creating a specific rubric for that questionnaire type.&lt;br /&gt;
* Data is fetched dynamically from the backend.&lt;br /&gt;
&lt;br /&gt;
[[File:Picx1x.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
===Create/Edit Rubric Page===&lt;br /&gt;
&lt;br /&gt;
This page is displayed when a user clicks the &amp;quot;+&amp;quot; button from the dashboard.&lt;br /&gt;
&lt;br /&gt;
Allows users to:&lt;br /&gt;
* Enter a name for the rubric.&lt;br /&gt;
* Define min/max item scores.&lt;br /&gt;
* Set the review visibility (private/public).&lt;br /&gt;
* Add criteria for evaluation.&lt;br /&gt;
* Submit the form to create a new rubric for the selected questionnaire type.&lt;br /&gt;
&lt;br /&gt;
[[File:Picx2x.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
==Backend Integration==&lt;br /&gt;
&lt;br /&gt;
The frontend interacts with several key resources exposed by the backend through a RESTful API. The structure of each model's associated database table lets us define Typescript interfaces, transform request/response payloads and promote type safety.&lt;br /&gt;
&lt;br /&gt;
===Models===&lt;br /&gt;
&lt;br /&gt;
====Questionnaire====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;Questionnaire&amp;lt;/code&amp;gt; model forms the foundation of the Create/Edit form functionality, storing necessary attributes for each questionnaire. These fields are used to construct a form for editing or creating a rubric and to prepopulate the form when editing an existing rubric. &lt;br /&gt;
&lt;br /&gt;
The backend database also includes a table of &amp;lt;code&amp;gt;questionnaire_types&amp;lt;/code&amp;gt;, access to which would allow the Questionnaire Management Dashboard to dynamically render all available categories of questionnaires and enable users to initiate the creation process based on a selected type. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Attribute !! Description&lt;br /&gt;
|-&lt;br /&gt;
| id || Unique identifier for the questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| name || The name/title of the questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| instructor_id || Foreign key referencing the instructor who created it&lt;br /&gt;
|-&lt;br /&gt;
| private || Boolean indicating if the questionnaire is private&lt;br /&gt;
|-&lt;br /&gt;
| min_question_score || Minimum score that can be given to any question&lt;br /&gt;
|-&lt;br /&gt;
| max_question_score || Maximum score that can be given to any question&lt;br /&gt;
|-&lt;br /&gt;
| questionnaire_type || The type/category of questionnaire (e.g., Survey, Teammate Review)&lt;br /&gt;
|-&lt;br /&gt;
| display_type || Field for specifying how to display the questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| instruction_loc || Field for custom instructions location or reference&lt;br /&gt;
|-&lt;br /&gt;
| created_at || Timestamp of questionnaire creation&lt;br /&gt;
|-&lt;br /&gt;
| updated_at || Timestamp of last update&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Item====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;Item&amp;lt;/code&amp;gt; model represents individual items (or questions) within a questionnaire and includes attributes that should be included when adding an item to a particular questionnaire.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Attribute !! Description&lt;br /&gt;
|-&lt;br /&gt;
| id || Unique identifier for the item&lt;br /&gt;
|-&lt;br /&gt;
| txt || The text of the item/question&lt;br /&gt;
|-&lt;br /&gt;
| weight || The relative importance or weight of the item&lt;br /&gt;
|-&lt;br /&gt;
| seq || The sequence/order of the item in the questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| question_type || Foreign key referencing the type of question&lt;br /&gt;
|-&lt;br /&gt;
| size || Size attribute for text-based answers (e.g., text area size)&lt;br /&gt;
|-&lt;br /&gt;
| alternatives || Possible answer choices (comma-separated for multiple-choice)&lt;br /&gt;
|-&lt;br /&gt;
| break_before || Boolean indicating whether to insert a page break before the item&lt;br /&gt;
|-&lt;br /&gt;
| max_label || Optional label for the maximum scale value&lt;br /&gt;
|-&lt;br /&gt;
| min_label || Optional label for the minimum scale value&lt;br /&gt;
|-&lt;br /&gt;
| created_at || Timestamp of item creation&lt;br /&gt;
|-&lt;br /&gt;
| updated_at || Timestamp of last update&lt;br /&gt;
|-&lt;br /&gt;
| questionnaire_id || Foreign key referencing the associated questionnaire&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===API Endpoints===&lt;br /&gt;
&lt;br /&gt;
To facilitate interaction with the backend, the frontend uses a pre-configured &amp;lt;code&amp;gt;axiosClient&amp;lt;/code&amp;gt;, which abstracts the base API URL and port number. This client is defined in the &amp;lt;code&amp;gt;utils/axios_client.ts&amp;lt;/code&amp;gt; file and reused throughout the project for API communication. For questionnaire management, several key API routes are accessed using this client. For example, &amp;lt;code&amp;gt;GET /questionnaires/:id&amp;lt;/code&amp;gt; fetches detailed data for editing a selected questionnaire. When creating or updating a questionnaire, the application uses &amp;lt;code&amp;gt;POST /questionnaires&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PUT /questionnaires/:id&amp;lt;/code&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
! HTTP Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| GET || /questionnaires || Fetches a list of all questionnaires&lt;br /&gt;
|-&lt;br /&gt;
| GET || /questionnaires/:id || Fetches a specific questionnaire by ID&lt;br /&gt;
|-&lt;br /&gt;
| POST || /questionnaires || Creates a new questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| PUT || /questionnaires/:id || Updates an existing questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| DELETE || /questionnaires/:id || Deletes a specific questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| GET || /questions || Retrieves a list of all questions (items)&lt;br /&gt;
|-&lt;br /&gt;
| GET || /questions/:id || Retrieves a specific item, along with its rendered display&lt;br /&gt;
|-&lt;br /&gt;
| POST || /questions || Creates a new item for a questionnaire&lt;br /&gt;
|-&lt;br /&gt;
| PUT || /questions/:id || Updates an existing item&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
&lt;br /&gt;
===QuestionnaireUtils.ts===&lt;br /&gt;
The &amp;lt;code&amp;gt;QuestionnaireUtils.ts&amp;lt;/code&amp;gt; file serves as a utility module for handling questionnaire-related functionality in the application, including interfaces, data transformation methods, and back-end data retrieval. This file helps maintain clear separation of concerns, type safety, and adherence to design principles such as the Single Responsibility Principle (SRP).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===QuestionnaireForm.tsx===&lt;br /&gt;
The &amp;lt;code&amp;gt;QuestionnaireForm.tsx&amp;lt;/code&amp;gt; file is a React component that provides a form interface for creating or editing questionnaires. It integrates with Formik for form state management and validation, utilizing React Bootstrap for UI elements.&lt;br /&gt;
&lt;br /&gt;
The form fields are strongly typed using Formik's &amp;lt;code&amp;gt;Field&amp;lt;/code&amp;gt; components and the &amp;lt;code&amp;gt;QuestionnaireFormValues&amp;lt;/code&amp;gt; interface, ensuring that the data entered by the user adheres to the correct structure.&lt;br /&gt;
*&amp;lt;strong&amp;gt;Name&amp;lt;/strong&amp;gt;: A text field for entering the questionnaire name.&lt;br /&gt;
*&amp;lt;strong&amp;gt;Type&amp;lt;/strong&amp;gt;: A hidden input used to specify the type of the questionnaire selected from the Questionnaire Management Dashboard and to be passed to the back-end.&lt;br /&gt;
*&amp;lt;strong&amp;gt;Private&amp;lt;/strong&amp;gt;: A checkbox to indicate whether the questionnaire is private.&lt;br /&gt;
*&amp;lt;strong&amp;gt;Minimum/Maximum Question Scores&amp;lt;/strong&amp;gt;: Numeric fields for setting the minimum and maximum scores for questions.&lt;br /&gt;
&lt;br /&gt;
The form delegates the responsibility of handling questionnaire items to the &amp;lt;code&amp;gt;QuestionnaireItemsFieldArray&amp;lt;/code&amp;gt; component, which allows users to add or remove items dynamically and keeps each component focused on a single responsibility.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===QuestionnaireType.tsx===&lt;br /&gt;
This component renders a table that displays different types of questionnaires. Each row provides an action to navigate to the corresponding creation page for the selected questionnaire type. The &amp;lt;code&amp;gt;Table&amp;lt;/code&amp;gt; component from &amp;lt;code&amp;gt;components/Table/Table&amp;lt;/code&amp;gt; is used in adherence with the DRY Principle and the provided design guidelines.&lt;br /&gt;
&lt;br /&gt;
==Files Modified==&lt;br /&gt;
The following files were created or modified to implement the questionnaire dashboard and rubric management UI in React with TypeScript:&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;src/pages/Questionnaire/questionnaire.tsx&amp;lt;/code&amp;gt; – Implements the Questionnaire Management Dashboard UI.&lt;br /&gt;
*&amp;lt;code&amp;gt;src/pages/EditQuestionnaire/Questionnaire.tsx&amp;lt;/code&amp;gt; – Implements the Create/Edit Rubric page with full form support.&lt;br /&gt;
*&amp;lt;code&amp;gt;src/App.tsx&amp;lt;/code&amp;gt; – Updated routing to include new questionnaire pages.&lt;br /&gt;
*&amp;lt;code&amp;gt;src/assets/icons/&amp;lt;/code&amp;gt; – Added new UI icons for editing, deleting, and copying questionnaires.&lt;br /&gt;
*&amp;lt;code&amp;gt;src/utils/axios_client.ts&amp;lt;/code&amp;gt; – Preconfigured axios instance used throughout the frontend for API calls.&lt;br /&gt;
*&amp;lt;code&amp;gt;package.json&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;package-lock.json&amp;lt;/code&amp;gt; – Updated dependencies for icons, React Bootstrap, and Formik support.&lt;br /&gt;
&lt;br /&gt;
==Test Plan - Manual Testing Strategy==&lt;br /&gt;
&lt;br /&gt;
====Questionnaire Dashboard Loading====&lt;br /&gt;
*Visit /questionnaire and confirm that all types of questionnaires are displayed.&lt;br /&gt;
*&amp;quot;+&amp;quot; button next to each type should open the rubric creation form for that type.&lt;br /&gt;
&lt;br /&gt;
====Form Functionality====&lt;br /&gt;
*Enter name, min/max scores, toggle private/public checkbox.&lt;br /&gt;
*Dynamically add/remove criteria.&lt;br /&gt;
*Submit form to create a new rubric and confirm it reflects in the backend.&lt;br /&gt;
&lt;br /&gt;
====Edit Rubric====&lt;br /&gt;
*Click on any existing rubric to load it in the edit form.&lt;br /&gt;
*Edit fields and submit changes. Confirm updated data is persisted.&lt;br /&gt;
&lt;br /&gt;
====Form Validation====&lt;br /&gt;
*Leave required fields empty and confirm validation errors appear.&lt;br /&gt;
*Enter invalid values (e.g., max &amp;lt; min) and confirm appropriate messages.&lt;br /&gt;
&lt;br /&gt;
====API Communication====&lt;br /&gt;
*Verified POST/PUT requests are correctly formatted.&lt;br /&gt;
*Backend updates reflected in UI after reload.&lt;br /&gt;
&lt;br /&gt;
====UI Testing====&lt;br /&gt;
*Confirm responsiveness across desktop, tablet, and mobile.&lt;br /&gt;
*Check accessibility: keyboard navigation, proper labeling.&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
*Prathyusha Kodali - pkodali&lt;br /&gt;
&lt;br /&gt;
=====Members===== &lt;br /&gt;
*Ashwin Muniswamy - akumarm&lt;br /&gt;
*Michael Anderson - mwander5&lt;br /&gt;
*Martina Viola - mmviola&lt;br /&gt;
&lt;br /&gt;
==Reference Links==&lt;br /&gt;
*[https://expertiza.ncsu.edu/tree_display/list?currCtlr=Questionnaires, Questionnaire Management Dashboard]&lt;br /&gt;
*[https://expertiza.ncsu.edu/questionnaires/new?model=ReviewQuestionnaire&amp;amp;private=1, Create/Edit Rubric Page]&lt;br /&gt;
*[https://github.com/mmviola1/reimplementation-front-end-E2538 Project Repo]&lt;br /&gt;
=====Demo Video=====&lt;br /&gt;
*[, Demo Video]&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2538_Reimplementing_Questionnaire_Page_in_Expertiza&amp;diff=162962</id>
		<title>CSC/ECE 517 Spring 2025 - E2538 Reimplementing Questionnaire Page in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2538_Reimplementing_Questionnaire_Page_in_Expertiza&amp;diff=162962"/>
		<updated>2025-04-02T19:09:30Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Project Requirement==&lt;br /&gt;
The goal of this project is to implement the Questionnaire Page in Expertiza by reimplementing its frontend using React with TypeScript, while integrating it with the existing Ruby on Rails backend APIs in the reimplementation backend repo. The new implementation will improve user experience, maintainability, and scalability while preserving core functionalities.&lt;br /&gt;
&lt;br /&gt;
This project covers:&lt;br /&gt;
&lt;br /&gt;
* Developing a React-based UI for managing questionnaire rubrics.&lt;br /&gt;
&lt;br /&gt;
* Enabling navigation to a new page when clicking the &amp;quot;+&amp;quot; button to create a specific rubric for a questionnaire type.&lt;br /&gt;
&lt;br /&gt;
* Ensuring seamless API integration with the reimplementation backend repo.&lt;br /&gt;
&lt;br /&gt;
* Managing user sessions and authentication securely.&lt;br /&gt;
&lt;br /&gt;
==Best Practices==&lt;br /&gt;
*Component Reusability (DRY Principle): Design reusable and modular components to avoid duplication and simplify maintenance, adhering to the &amp;quot;Don't Repeat Yourself&amp;quot; principle.&lt;br /&gt;
&lt;br /&gt;
*Separation of Concerns: Keep the UI, state management, and business logic separated. Use container components for state and logic and presentational components for rendering.&lt;br /&gt;
&lt;br /&gt;
*Responsive and Accessible Design: Ensure the UI adapts to different devices and meets accessibility standards (e.g., ARIA roles, keyboard navigation, and proper contrast).&lt;br /&gt;
&lt;br /&gt;
*Type Safety with TypeScript: Use TypeScript interfaces and types to ensure data consistency, reduce runtime errors.&lt;br /&gt;
&lt;br /&gt;
*Single Responsibility Principle: Each component or function should have a single, well-defined purpose to improve clarity, testability, and scalability.&lt;br /&gt;
&lt;br /&gt;
==What Needs to be Done?==&lt;br /&gt;
===Questionnaire Management Dashboard===&lt;br /&gt;
&lt;br /&gt;
Displays a list of questionnaire types (Review, Metareview, Author Feedback, etc.)&lt;br /&gt;
* Each questionnaire type has a &amp;quot;+&amp;quot; button, which, when clicked, navigates to a new page for creating a specific rubric for that questionnaire type.&lt;br /&gt;
* Data is fetched dynamically from the backend.&lt;br /&gt;
&lt;br /&gt;
[[File:Picx1x.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
===Create/Edit Rubric Page===&lt;br /&gt;
&lt;br /&gt;
This page is displayed when a user clicks the &amp;quot;+&amp;quot; button from the dashboard.&lt;br /&gt;
&lt;br /&gt;
Allows users to:&lt;br /&gt;
* Enter a name for the rubric.&lt;br /&gt;
* Define min/max item scores.&lt;br /&gt;
* Set the review visibility (private/public).&lt;br /&gt;
* Add criteria for evaluation.&lt;br /&gt;
* Submit the form to create a new rubric for the selected questionnaire type.&lt;br /&gt;
&lt;br /&gt;
[[File:Picx2x.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
==Class UML Diagram==&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
===Views===&lt;br /&gt;
===Model===&lt;br /&gt;
===Controller===&lt;br /&gt;
&lt;br /&gt;
==Files Modified==&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
===Testing Views===&lt;br /&gt;
===Testing Model===&lt;br /&gt;
===Testing Controller===&lt;br /&gt;
&lt;br /&gt;
==Test Coverage==&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
*Prathyusha Kodali - pkodali&lt;br /&gt;
&lt;br /&gt;
=====Members===== &lt;br /&gt;
*Ashwin Muniswamy - akumarm&lt;br /&gt;
*Michael Anderson - mwander5&lt;br /&gt;
*Martina Viola - mmviola&lt;br /&gt;
&lt;br /&gt;
==Reference Links==&lt;br /&gt;
*[https://expertiza.ncsu.edu/tree_display/list?currCtlr=Questionnaires, 1]&lt;br /&gt;
*[https://expertiza.ncsu.edu/questionnaires/new?model=ReviewQuestionnaire&amp;amp;private=1, 2]&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2538_Reimplementing_Questionnaire_Page_in_Expertiza&amp;diff=162961</id>
		<title>CSC/ECE 517 Spring 2025 - E2538 Reimplementing Questionnaire Page in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2538_Reimplementing_Questionnaire_Page_in_Expertiza&amp;diff=162961"/>
		<updated>2025-04-02T19:06:04Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Project Requirement==&lt;br /&gt;
The goal of this project is to implement the Questionnaire Page in Expertiza by reimplementing its frontend using React with TypeScript, while integrating it with the existing Ruby on Rails backend APIs in the reimplementation backend repo. The new implementation will improve user experience, maintainability, and scalability while preserving core functionalities.&lt;br /&gt;
&lt;br /&gt;
This project covers:&lt;br /&gt;
&lt;br /&gt;
* Developing a React-based UI for managing questionnaire rubrics.&lt;br /&gt;
&lt;br /&gt;
* Enabling navigation to a new page when clicking the &amp;quot;+&amp;quot; button to create a specific rubric for a questionnaire type.&lt;br /&gt;
&lt;br /&gt;
* Ensuring seamless API integration with the reimplementation backend repo.&lt;br /&gt;
&lt;br /&gt;
* Managing user sessions and authentication securely.&lt;br /&gt;
&lt;br /&gt;
==Best Practices==&lt;br /&gt;
*Component Reusability (DRY Principle): Design reusable and modular components to avoid duplication and simplify maintenance, adhering to the &amp;quot;Don't Repeat Yourself&amp;quot; principle.&lt;br /&gt;
&lt;br /&gt;
*Separation of Concerns: Keep the UI, state management, and business logic separated. Use container components for state and logic and presentational components for rendering.&lt;br /&gt;
&lt;br /&gt;
*Responsive and Accessible Design: Ensure the UI adapts to different devices and meets accessibility standards (e.g., ARIA roles, keyboard navigation, and proper contrast).&lt;br /&gt;
&lt;br /&gt;
*Type Safety with TypeScript: Use TypeScript interfaces and types to ensure data consistency, reduce runtime errors.&lt;br /&gt;
&lt;br /&gt;
*Single Responsibility Principle: Each component or function should have a single, well-defined purpose to improve clarity, testability, and scalability.&lt;br /&gt;
&lt;br /&gt;
==What Needs to be Done?==&lt;br /&gt;
1) Questionnaire Management Dashboard&lt;br /&gt;
&lt;br /&gt;
Displays a list of questionnaire types (Review, Metareview, Author Feedback, etc.)&lt;br /&gt;
* Each questionnaire type has a &amp;quot;+&amp;quot; button, which, when clicked, navigates to a new page for creating a specific rubric for that questionnaire type.&lt;br /&gt;
* Data is fetched dynamically from the backend.&lt;br /&gt;
&lt;br /&gt;
[[File:Picx1x.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
2) Create/Edit Rubric Page&lt;br /&gt;
&lt;br /&gt;
This page is displayed when a user clicks the &amp;quot;+&amp;quot; button from the dashboard.&lt;br /&gt;
&lt;br /&gt;
Allows users to:&lt;br /&gt;
* Enter a name for the rubric.&lt;br /&gt;
* Define min/max item scores.&lt;br /&gt;
* Set the review visibility (private/public).&lt;br /&gt;
* Add criteria for evaluation.&lt;br /&gt;
* Submit the form to create a new rubric for the selected questionnaire type.&lt;br /&gt;
&lt;br /&gt;
[[File:Picx2x.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
==Class UML Diagram==&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
===Views===&lt;br /&gt;
===Model===&lt;br /&gt;
===Controller===&lt;br /&gt;
&lt;br /&gt;
==Files Modified==&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
===Testing Views===&lt;br /&gt;
===Testing Model===&lt;br /&gt;
===Testing Controller===&lt;br /&gt;
&lt;br /&gt;
==Test Coverage==&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
*Prathyusha Kodali - pkodali&lt;br /&gt;
&lt;br /&gt;
=====Members===== &lt;br /&gt;
*Ashwin Muniswamy - akumarm&lt;br /&gt;
*Michael Anderson - mwander5&lt;br /&gt;
*Martina Viola - mmviola&lt;br /&gt;
&lt;br /&gt;
==Reference Links==&lt;br /&gt;
*[https://expertiza.ncsu.edu/tree_display/list?currCtlr=Questionnaires, 1]&lt;br /&gt;
*[https://expertiza.ncsu.edu/questionnaires/new?model=ReviewQuestionnaire&amp;amp;private=1, 2]&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2538_Reimplementing_Questionnaire_Page_in_Expertiza&amp;diff=162960</id>
		<title>CSC/ECE 517 Spring 2025 - E2538 Reimplementing Questionnaire Page in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2538_Reimplementing_Questionnaire_Page_in_Expertiza&amp;diff=162960"/>
		<updated>2025-04-02T18:58:04Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: /* What Needs to be Done? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
==Project Requirement==&lt;br /&gt;
The goal of this project is to implement the Questionnaire Page in Expertiza by reimplementing its frontend using React with TypeScript, while integrating it with the existing Ruby on Rails backend APIs in the reimplementation backend repo. The new implementation will improve user experience, maintainability, and scalability while preserving core functionalities.&lt;br /&gt;
&lt;br /&gt;
This project covers:&lt;br /&gt;
&lt;br /&gt;
* Developing a React-based UI for managing questionnaire rubrics.&lt;br /&gt;
&lt;br /&gt;
* Enabling navigation to a new page when clicking the &amp;quot;+&amp;quot; button to create a specific rubric for a questionnaire type.&lt;br /&gt;
&lt;br /&gt;
* Ensuring seamless API integration with the reimplementation backend repo.&lt;br /&gt;
&lt;br /&gt;
* Managing user sessions and authentication securely.&lt;br /&gt;
&lt;br /&gt;
==Best Practices==&lt;br /&gt;
*Component Reusability (DRY Principle): Design reusable and modular components to avoid duplication and simplify maintenance, adhering to the &amp;quot;Don't Repeat Yourself&amp;quot; principle.&lt;br /&gt;
&lt;br /&gt;
*Separation of Concerns: Keep the UI, state management, and business logic separated. Use container components for state and logic and presentational components for rendering.&lt;br /&gt;
&lt;br /&gt;
*Responsive and Accessible Design: Ensure the UI adapts to different devices and meets accessibility standards (e.g., ARIA roles, keyboard navigation, and proper contrast).&lt;br /&gt;
&lt;br /&gt;
*Type Safety with TypeScript: Use TypeScript interfaces and types to ensure data consistency, reduce runtime errors.&lt;br /&gt;
&lt;br /&gt;
*Single Responsibility Principle: Each component or function should have a single, well-defined purpose to improve clarity, testability, and scalability.&lt;br /&gt;
&lt;br /&gt;
==What Needs to be Done?==&lt;br /&gt;
1) Questionnaire Management Dashboard&lt;br /&gt;
&lt;br /&gt;
Displays a list of questionnaire types (Review, Metareview, Author Feedback, etc.)&lt;br /&gt;
* Each questionnaire type has a &amp;quot;+&amp;quot; button, which, when clicked, navigates to a new page for creating a specific rubric for that questionnaire type.&lt;br /&gt;
* Data is fetched dynamically from the backend.&lt;br /&gt;
&lt;br /&gt;
[[File:Picx1x.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
2) Create/Edit Rubric Page&lt;br /&gt;
&lt;br /&gt;
This page is displayed when a user clicks the &amp;quot;+&amp;quot; button from the dashboard.&lt;br /&gt;
&lt;br /&gt;
Allows users to:&lt;br /&gt;
* Enter a name for the rubric.&lt;br /&gt;
* Define min/max item scores.&lt;br /&gt;
* Set the review visibility (private/public).&lt;br /&gt;
* Add criteria for evaluation.&lt;br /&gt;
* Submit the form to create a new rubric for the selected questionnaire type.&lt;br /&gt;
&lt;br /&gt;
[[File:Picx2x.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
==Class UML Diagram==&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
&lt;br /&gt;
==Files Modified==&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
*Prathyusha Kodali - pkodali&lt;br /&gt;
&lt;br /&gt;
=====Members===== &lt;br /&gt;
*Ashwin Muniswamy - akumarm&lt;br /&gt;
*Michael Anderson - mwander5&lt;br /&gt;
*Martina Viola - mmviola&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Reference Links==&lt;br /&gt;
*[https://expertiza.ncsu.edu/tree_display/list?currCtlr=Questionnaires, 1]&lt;br /&gt;
*[https://expertiza.ncsu.edu/questionnaires/new?model=ReviewQuestionnaire&amp;amp;private=1, 2]&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Picx2x.png&amp;diff=162959</id>
		<title>File:Picx2x.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Picx2x.png&amp;diff=162959"/>
		<updated>2025-04-02T18:57:28Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2538_Reimplementing_Questionnaire_Page_in_Expertiza&amp;diff=162958</id>
		<title>CSC/ECE 517 Spring 2025 - E2538 Reimplementing Questionnaire Page in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2538_Reimplementing_Questionnaire_Page_in_Expertiza&amp;diff=162958"/>
		<updated>2025-04-02T18:57:06Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: /* What Needs to be Done? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
==Project Requirement==&lt;br /&gt;
The goal of this project is to implement the Questionnaire Page in Expertiza by reimplementing its frontend using React with TypeScript, while integrating it with the existing Ruby on Rails backend APIs in the reimplementation backend repo. The new implementation will improve user experience, maintainability, and scalability while preserving core functionalities.&lt;br /&gt;
&lt;br /&gt;
This project covers:&lt;br /&gt;
&lt;br /&gt;
* Developing a React-based UI for managing questionnaire rubrics.&lt;br /&gt;
&lt;br /&gt;
* Enabling navigation to a new page when clicking the &amp;quot;+&amp;quot; button to create a specific rubric for a questionnaire type.&lt;br /&gt;
&lt;br /&gt;
* Ensuring seamless API integration with the reimplementation backend repo.&lt;br /&gt;
&lt;br /&gt;
* Managing user sessions and authentication securely.&lt;br /&gt;
&lt;br /&gt;
==Best Practices==&lt;br /&gt;
*Component Reusability (DRY Principle): Design reusable and modular components to avoid duplication and simplify maintenance, adhering to the &amp;quot;Don't Repeat Yourself&amp;quot; principle.&lt;br /&gt;
&lt;br /&gt;
*Separation of Concerns: Keep the UI, state management, and business logic separated. Use container components for state and logic and presentational components for rendering.&lt;br /&gt;
&lt;br /&gt;
*Responsive and Accessible Design: Ensure the UI adapts to different devices and meets accessibility standards (e.g., ARIA roles, keyboard navigation, and proper contrast).&lt;br /&gt;
&lt;br /&gt;
*Type Safety with TypeScript: Use TypeScript interfaces and types to ensure data consistency, reduce runtime errors.&lt;br /&gt;
&lt;br /&gt;
*Single Responsibility Principle: Each component or function should have a single, well-defined purpose to improve clarity, testability, and scalability.&lt;br /&gt;
&lt;br /&gt;
==What Needs to be Done?==&lt;br /&gt;
1) Questionnaire Management Dashboard (First Screenshot)&lt;br /&gt;
&lt;br /&gt;
Displays a list of questionnaire types (Review, Metareview, Author Feedback, etc.)&lt;br /&gt;
* Each questionnaire type has a &amp;quot;+&amp;quot; button, which, when clicked, navigates to a new page for creating a specific rubric for that questionnaire type.&lt;br /&gt;
* Data is fetched dynamically from the backend.&lt;br /&gt;
&lt;br /&gt;
[[File:Picx1x.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
2) Create/Edit Rubric Page (Second Screenshot)&lt;br /&gt;
&lt;br /&gt;
This page is displayed when a user clicks the &amp;quot;+&amp;quot; button from the dashboard.&lt;br /&gt;
&lt;br /&gt;
Allows users to:&lt;br /&gt;
* Enter a name for the rubric.&lt;br /&gt;
* Define min/max item scores.&lt;br /&gt;
* Set the review visibility (private/public).&lt;br /&gt;
* Add criteria for evaluation.&lt;br /&gt;
* Submit the form to create a new rubric for the selected questionnaire type.&lt;br /&gt;
&lt;br /&gt;
==Class UML Diagram==&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
&lt;br /&gt;
==Files Modified==&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
*Prathyusha Kodali - pkodali&lt;br /&gt;
&lt;br /&gt;
=====Members===== &lt;br /&gt;
*Ashwin Muniswamy - akumarm&lt;br /&gt;
*Michael Anderson - mwander5&lt;br /&gt;
*Martina Viola - mmviola&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Reference Links==&lt;br /&gt;
*[https://expertiza.ncsu.edu/tree_display/list?currCtlr=Questionnaires, 1]&lt;br /&gt;
*[https://expertiza.ncsu.edu/questionnaires/new?model=ReviewQuestionnaire&amp;amp;private=1, 2]&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Picx1x.png&amp;diff=162957</id>
		<title>File:Picx1x.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Picx1x.png&amp;diff=162957"/>
		<updated>2025-04-02T18:55:50Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2538_Reimplementing_Questionnaire_Page_in_Expertiza&amp;diff=162956</id>
		<title>CSC/ECE 517 Spring 2025 - E2538 Reimplementing Questionnaire Page in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2538_Reimplementing_Questionnaire_Page_in_Expertiza&amp;diff=162956"/>
		<updated>2025-04-02T18:54:58Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
==Project Requirement==&lt;br /&gt;
The goal of this project is to implement the Questionnaire Page in Expertiza by reimplementing its frontend using React with TypeScript, while integrating it with the existing Ruby on Rails backend APIs in the reimplementation backend repo. The new implementation will improve user experience, maintainability, and scalability while preserving core functionalities.&lt;br /&gt;
&lt;br /&gt;
This project covers:&lt;br /&gt;
&lt;br /&gt;
* Developing a React-based UI for managing questionnaire rubrics.&lt;br /&gt;
&lt;br /&gt;
* Enabling navigation to a new page when clicking the &amp;quot;+&amp;quot; button to create a specific rubric for a questionnaire type.&lt;br /&gt;
&lt;br /&gt;
* Ensuring seamless API integration with the reimplementation backend repo.&lt;br /&gt;
&lt;br /&gt;
* Managing user sessions and authentication securely.&lt;br /&gt;
&lt;br /&gt;
==Best Practices==&lt;br /&gt;
*Component Reusability (DRY Principle): Design reusable and modular components to avoid duplication and simplify maintenance, adhering to the &amp;quot;Don't Repeat Yourself&amp;quot; principle.&lt;br /&gt;
&lt;br /&gt;
*Separation of Concerns: Keep the UI, state management, and business logic separated. Use container components for state and logic and presentational components for rendering.&lt;br /&gt;
&lt;br /&gt;
*Responsive and Accessible Design: Ensure the UI adapts to different devices and meets accessibility standards (e.g., ARIA roles, keyboard navigation, and proper contrast).&lt;br /&gt;
&lt;br /&gt;
*Type Safety with TypeScript: Use TypeScript interfaces and types to ensure data consistency, reduce runtime errors.&lt;br /&gt;
&lt;br /&gt;
*Single Responsibility Principle: Each component or function should have a single, well-defined purpose to improve clarity, testability, and scalability.&lt;br /&gt;
&lt;br /&gt;
==What Needs to be Done?==&lt;br /&gt;
1) Questionnaire Management Dashboard (First Screenshot)&lt;br /&gt;
&lt;br /&gt;
Displays a list of questionnaire types (Review, Metareview, Author Feedback, etc.)&lt;br /&gt;
* Each questionnaire type has a &amp;quot;+&amp;quot; button, which, when clicked, navigates to a new page for creating a specific rubric for that questionnaire type.&lt;br /&gt;
* Data is fetched dynamically from the backend.&lt;br /&gt;
&lt;br /&gt;
2) Create/Edit Rubric Page (Second Screenshot)&lt;br /&gt;
&lt;br /&gt;
This page is displayed when a user clicks the &amp;quot;+&amp;quot; button from the dashboard.&lt;br /&gt;
&lt;br /&gt;
Allows users to:&lt;br /&gt;
* Enter a name for the rubric.&lt;br /&gt;
* Define min/max item scores.&lt;br /&gt;
* Set the review visibility (private/public).&lt;br /&gt;
* Add criteria for evaluation.&lt;br /&gt;
* Submit the form to create a new rubric for the selected questionnaire type.&lt;br /&gt;
&lt;br /&gt;
==Class UML Diagram==&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
&lt;br /&gt;
==Files Modified==&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
*Prathyusha Kodali - pkodali&lt;br /&gt;
&lt;br /&gt;
=====Members===== &lt;br /&gt;
*Ashwin Muniswamy - akumarm&lt;br /&gt;
*Michael Anderson - mwander5&lt;br /&gt;
*Martina Viola - mmviola&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Reference Links==&lt;br /&gt;
*[https://expertiza.ncsu.edu/tree_display/list?currCtlr=Questionnaires, 1]&lt;br /&gt;
*[https://expertiza.ncsu.edu/questionnaires/new?model=ReviewQuestionnaire&amp;amp;private=1, 2]&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2538_Reimplementing_Questionnaire_Page_in_Expertiza&amp;diff=162955</id>
		<title>CSC/ECE 517 Spring 2025 - E2538 Reimplementing Questionnaire Page in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2538_Reimplementing_Questionnaire_Page_in_Expertiza&amp;diff=162955"/>
		<updated>2025-04-02T18:48:25Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
==Project Requirement==&lt;br /&gt;
The goal of this project is to implement the Questionnaire Page in Expertiza by reimplementing its frontend using React with TypeScript, while integrating it with the existing Ruby on Rails backend APIs in the reimplementation backend repo. The new implementation will improve user experience, maintainability, and scalability while preserving core functionalities.&lt;br /&gt;
&lt;br /&gt;
This project covers:&lt;br /&gt;
&lt;br /&gt;
* Developing a React-based UI for managing questionnaire rubrics.&lt;br /&gt;
&lt;br /&gt;
* Enabling navigation to a new page when clicking the &amp;quot;+&amp;quot; button to create a specific rubric for a questionnaire type.&lt;br /&gt;
&lt;br /&gt;
* Ensuring seamless API integration with the reimplementation backend repo.&lt;br /&gt;
&lt;br /&gt;
* Managing user sessions and authentication securely.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Best Practices==&lt;br /&gt;
&lt;br /&gt;
==Class UML Diagram==&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
&lt;br /&gt;
==Files Modified==&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
*Prathyusha Kodali - pkodali&lt;br /&gt;
&lt;br /&gt;
=====Members===== &lt;br /&gt;
*Ashwin Muniswamy - akumarm&lt;br /&gt;
*Michael Anderson - mwander5&lt;br /&gt;
*Martina Viola - mmviola&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Reference Links==&lt;br /&gt;
*[https://expertiza.ncsu.edu/tree_display/list?currCtlr=Questionnaires, 1]&lt;br /&gt;
*[https://expertiza.ncsu.edu/questionnaires/new?model=ReviewQuestionnaire&amp;amp;private=1, 2]&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2538_Reimplementing_Questionnaire_Page_in_Expertiza&amp;diff=162954</id>
		<title>CSC/ECE 517 Spring 2025 - E2538 Reimplementing Questionnaire Page in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2538_Reimplementing_Questionnaire_Page_in_Expertiza&amp;diff=162954"/>
		<updated>2025-04-02T18:45:00Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
==Project Requirement==&lt;br /&gt;
&lt;br /&gt;
==Best Practices==&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
&lt;br /&gt;
==Files Modified==&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
*Prathyusha Kodali - pkodali&lt;br /&gt;
&lt;br /&gt;
=====Members===== &lt;br /&gt;
*Ashwin Muniswamy - akumarm&lt;br /&gt;
*Michael Anderson - mwander5&lt;br /&gt;
*Martina Viola - mmviola&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Reference Links==&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025&amp;diff=162953</id>
		<title>CSC/ECE 517 Spring 2025</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025&amp;diff=162953"/>
		<updated>2025-04-02T18:14:40Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[CSC/ECE 517 Spring 2025 - E2503. Refactor the Team hierarchy]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2504. Mentor-meeting management]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2505. Testing Answer Tagging]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2508. Reimplement bidding-algorithm web service]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2509. Reimplement feedback_response_map.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2519. Implement view for results of bidding]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2522. Enhancing UI Consistency in Expertiza 1]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2520. Reimplement heatgrid UI for reviews]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2517. Reimplement internationalization (frontend + backend)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2523: Enhancing UI Consistency in Expertiza 2]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2515:  Reimplement student_teams_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2501:  Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2502:  Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2512. Reimplement responses controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2510. Reimplement grades_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2507. Reimplement back end for submission records]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2514. Reimplement student_quizzes_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2518. Reimplement password resets (frontend + backend)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2516. Reimplement teams_users_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2511. Reimplement participants_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2521. UI for View submissions/assign grades (except heatgrid)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2513. Reimplement sign_up_topic.rb as project_topic.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2506. Implement testing for new Bookmarks Controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2527. Mentor-meeting management: assignments with topics]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2532. Reimplement Missing ResponseMap Subclasses]]&lt;br /&gt;
&lt;br /&gt;
== Final Projects ==&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2539 Reimplement Student Task View (Frontend + Backend)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2521 UI for View submissions/assign grades (except heatgrid)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2538 Reimplementing Questionnaire Page in Expertiza]]&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2538_Reimplementing_Questionnaire_Page_in_Expertiza&amp;diff=162952</id>
		<title>CSC/ECE 517 Spring 2025 - E2538 Reimplementing Questionnaire Page in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2538_Reimplementing_Questionnaire_Page_in_Expertiza&amp;diff=162952"/>
		<updated>2025-04-02T18:13:45Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: Created page with &amp;quot;==Project Overview== ===   ''Background''   ===   ===   ''Objectives''   ===&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Project Overview==&lt;br /&gt;
===   ''Background''   ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===   ''Objectives''   ===&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162743</id>
		<title>CSC/ECE 517 Spring 2025 - E2508. Reimplement bidding-algorithm web service</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162743"/>
		<updated>2025-03-25T03:11:21Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Project Overview==&lt;br /&gt;
===   ''Background''   ===&lt;br /&gt;
The previous implementation of the bidding service was hosted on peerlogic by a former student. The University no longer has access to this hosting service, and  is requiring a new solution. It is also asked that the webservice accept a better and cleaner json format which is easier to interpret and read.&lt;br /&gt;
&lt;br /&gt;
===   ''Objectives''   ===&lt;br /&gt;
# Reimplement trading cycles on a webservice&lt;br /&gt;
# Figure out a new hosting solution for the BiddingService web service. (VCL)&lt;br /&gt;
# Host the webservice on VCL&lt;br /&gt;
# Using tmux, figure out a way to keep the process running with a production wsgi service compatible with Flask.&lt;br /&gt;
# Create new tests for the repository&lt;br /&gt;
# Create a list of required packages that future maintainers can install easily&lt;br /&gt;
# Create a tests directory that users can test the functionality of the code with&lt;br /&gt;
# Modularize the code further, eliminate code smells.&lt;br /&gt;
# Refactor existing backend logic to account for the new json format&lt;br /&gt;
# Refactor existing backend code to send HTTP requests to the correct IP address&lt;br /&gt;
# Refactor existing frontend code to provide a list for users to select multiple topics on the frontend&lt;br /&gt;
# Allow users to prioritize their topic selection on the frontend&lt;br /&gt;
# Users should not be allowed to bid on their review topics on the frontend&lt;br /&gt;
# Display the results of the matched topics on the frontend&lt;br /&gt;
&lt;br /&gt;
===   ''Previous Work''   ===&lt;br /&gt;
There have been three previous implementations: &amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2019 [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Spring 2020 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2020 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2024 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2508._Reimplement_bidding-algorithm_web_service here]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/2931 &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Files Modified''   ===&lt;br /&gt;
This is a list of all the files added or changed in completing this project. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Changed'': &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/app.py - accomodated for changes in JsonParser&lt;br /&gt;
*app/json_parser.py - moved functions out due to SRP&lt;br /&gt;
*app/topics_matcher.py&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Added'': &amp;lt;br&amp;gt;&lt;br /&gt;
*app/tests/sample.json &amp;lt;br&amp;gt; - Sample input for the tests.&lt;br /&gt;
&lt;br /&gt;
*app/tests/test_assignment.py &amp;lt;br&amp;gt; Test File to test forms of input - tests both a successful and unsuccessful input&lt;br /&gt;
&lt;br /&gt;
*app/utils/popular_topics.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/student_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/topic_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
&lt;br /&gt;
*setup.py - required for wsgi&lt;br /&gt;
*wsgi.py - for hosting the server via gunicorn on VCL.&lt;br /&gt;
*.gitignore - to ignore anything that we may not want pushed (mostly for venv)&lt;br /&gt;
*requirements.txt - a list of requirements made easy for future maintainers&lt;br /&gt;
&lt;br /&gt;
=== ''Webservice'' ===&lt;br /&gt;
===== ''app'' =====&lt;br /&gt;
&lt;br /&gt;
The entry point to the Web service is the app.py file where we have the POST Method match_topics.&lt;br /&gt;
This receives the input in a json format from Expertiza. The input will contain a list of task ids, and then an Object of users, which each contain their student id and correlated bids that they made. Each bid contains a task id, a priority, and a timestamp. The input format was reworked to align to this style since it made more sense to have each student have a list of bids instead of the previous implementation which did not have this case. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:App2508.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''json parser'' =====&lt;br /&gt;
The json parser converts the json into a Dictionary. The previous implementation also had the parser create a preferences dictionary for the Student to store their topic preferences and one for Topics to store list of topics which have been selected by students and also the priority for the selection using the Timestamps. However, this was removed due to the Single Responsibility Principle. We felt the json parser was doing too much and should only be parsing the json!&lt;br /&gt;
&lt;br /&gt;
[[File:init_parser.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The student priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:student_prio.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The topic priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:topic_priorities.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== ''Test Input'' =====&lt;br /&gt;
&lt;br /&gt;
Sample Test case:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Case:&amp;lt;/b&amp;gt; There are a few very popular topics and the students who bid for them and bid early should receive it.&lt;br /&gt;
Popular Topics: 3969, 3971, 3972&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;tid&amp;quot;: [4427, 4428, 4429, 4430],&lt;br /&gt;
    &amp;quot;users&amp;quot;: {&lt;br /&gt;
      &amp;quot;40763&amp;quot;: {&lt;br /&gt;
          &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4429&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40764&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4427&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40765&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:15 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:16 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:17 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4428&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;max_accepted_proposals&amp;quot;: 3&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''Output'' =====&lt;br /&gt;
&lt;br /&gt;
 Since there is competition for these topics, the algorithm recognizes this and makes sure to assign them only to the students who bid for it.&lt;br /&gt;
		Other students who picked other topics or did not pick anything are assigned different topics.&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
    &amp;quot;40763&amp;quot;: [&lt;br /&gt;
        4427,&lt;br /&gt;
        4428,&lt;br /&gt;
        4430&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40764&amp;quot;: [&lt;br /&gt;
        4428,&lt;br /&gt;
        4430,&lt;br /&gt;
        4429&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40765&amp;quot;: [&lt;br /&gt;
        4429,&lt;br /&gt;
        4427,&lt;br /&gt;
        4430&lt;br /&gt;
    ]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== ''Controller'' ===&lt;br /&gt;
&lt;br /&gt;
The controller includes 8 methods that handle the review bidding process. The public methods cover authorization, rendering views, saving user bids, and coordinating review assignment. The private methods support these functions by abstracting data gathering and algorithm coordination logic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Method: action_allowed? ======&lt;br /&gt;
&lt;br /&gt;
This method controls user access to controller actions. It allows 'Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator', and 'Student' roles to access show, set_priority, and index. Other actions are restricted to non-student roles. It ensures proper permissions for accessing review bidding features.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: index ======&lt;br /&gt;
&lt;br /&gt;
This method gathers information for the &amp;quot;Your Work&amp;quot; page, where users can view their assigned reviews. It checks user identity, retrieves associated reviews, and counts completed reviews. The view rendered is sign_up_sheet/review_bids_others_work.View: others_work.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_index.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: show ======&lt;br /&gt;
&lt;br /&gt;
This method renders the bidding page where users select topics they'd prefer to review. It fetches the assignment, available topics, and any existing bids. Already assigned or signed-up topics are excluded. The page also lists any assigned reviews.View: show.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_show.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: set_priority ======&lt;br /&gt;
&lt;br /&gt;
This method stores or updates a participant's topic preferences. It removes old bids not in the current selection and creates or updates the remaining bids with new priorities. This method is triggered when users submit their topic rankings on the bidding page.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_set_priority.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_bidding ======&lt;br /&gt;
&lt;br /&gt;
This method coordinates the assignment of review topics. It gathers reviewer IDs and invokes the bidding algorithm using a service. It validates the output and uses ReviewBid.assign_review_topics to perform the actual assignment. Bidding is then disabled.&lt;br /&gt;
&lt;br /&gt;
[[File:X9x.png|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: fetch_reviewer_ids (Private) ======&lt;br /&gt;
&lt;br /&gt;
This helper method retrieves all AssignmentParticipant IDs for a given assignment. These IDs represent the reviewers participating in the bidding process.&lt;br /&gt;
&lt;br /&gt;
====== Method: process_bidding (Private) ======&lt;br /&gt;
This helper method delegates the logic for running the bidding algorithm to the service class ReviewBiddingAlgorithmService. It takes the assignment ID and list of reviewers as input and returns matched topic assignments.&lt;br /&gt;
&lt;br /&gt;
====== Method: ensure_valid_topics (Private) ======&lt;br /&gt;
This method ensures that all reviewers have valid topic assignment entries, even if the algorithm returns nothing (e.g., due to web service failure). It initializes empty topic arrays for any missing reviewers.&lt;br /&gt;
&lt;br /&gt;
[[File:Controller_private_methods.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== ''Model'' ===&lt;br /&gt;
&lt;br /&gt;
The model includes 13 methods that manage the review bidding process. The public methods handle bidding data retrieval, review topic assignment, and fallback allocation. The private methods support these functions by fetching user and team data, sorting topics, and formatting bid details.&lt;br /&gt;
&lt;br /&gt;
====== Method: bidding_data ======&lt;br /&gt;
&lt;br /&gt;
Collects bidding data for an assignment, including topics, max allowed proposals, and individual reviewer bids.&lt;br /&gt;
&lt;br /&gt;
[[File:X1x1.png|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_review_topics ======&lt;br /&gt;
&lt;br /&gt;
Assigns reviewers to topics based on matched preferences and clears previous assignments.&lt;br /&gt;
&lt;br /&gt;
[[File:X2x.png|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_topic_to_reviewer ======&lt;br /&gt;
&lt;br /&gt;
Assigns a single topic to a reviewer by linking them to a team under that topic.&lt;br /&gt;
&lt;br /&gt;
[[File:X3x.png|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: reviewer_bidding_data ======&lt;br /&gt;
&lt;br /&gt;
Retrieves bid details for a specific reviewer, including self-selected topics and bid priorities.&lt;br /&gt;
&lt;br /&gt;
[[File:File4.png|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: fallback_algorithm ======&lt;br /&gt;
&lt;br /&gt;
Assigns topics to reviewers using a fallback approach when the initial bidding fails.&lt;br /&gt;
&lt;br /&gt;
[[File:X5x.png|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Private Methods ======&lt;br /&gt;
&lt;br /&gt;
* sorted_topic_queue – Sorts topics based on the number of team members and returns them in descending order&lt;br /&gt;
* assign_topics – Iterates through reviewers and assigns topics from the sorted queue, ensuring balanced distribution&lt;br /&gt;
* find_available_topic – Selects an available topic for a reviewer while avoiding self-selected topics&lt;br /&gt;
* reviewer_team_id – Retrieves the team ID associated with a given reviewer&lt;br /&gt;
* find_reviewer_user_id – Fetches the user ID for a given reviewer&lt;br /&gt;
* fetch_self_topic – Gets the topic that the user has self-selected for an assignment&lt;br /&gt;
* fetch_team_id – Finds the team ID for a given user in an assignment&lt;br /&gt;
* fetch_team_bids – Retrieves all bid records associated with a specific team&lt;br /&gt;
* format_bid – Converts a bid record into a structured format with topic ID, priority, and a formatted timestamp&lt;br /&gt;
&lt;br /&gt;
[[File:X6x.png|700px]]&lt;br /&gt;
&lt;br /&gt;
[[File:X7x.png|700px]]&lt;br /&gt;
&lt;br /&gt;
=== ''Service'' ===&lt;br /&gt;
&lt;br /&gt;
The ReviewBiddingAlgorithmService is a service object responsible for handling communication between the application and the external web service that executes the review bidding algorithm. It prepares bidding data, sends it to the web service, processes the response, and provides a fallback mechanism in case of failure.&lt;br /&gt;
&lt;br /&gt;
This service allows to encapsulate all logic required to interact with the external topic-matching web service. It separates the algorithm execution concerns from the controller, improving modularity, testability, and maintainability of the code.&lt;br /&gt;
&lt;br /&gt;
====== Method: self.process_bidding ======&lt;br /&gt;
&lt;br /&gt;
This is the primary entry point for the controller. It accepts the assignment_id and a list of reviewer_ids, then prepares the bidding data by calling ReviewBid.bidding_data(...). It passes the data to the web service by calling run_bidding_algorithm. If the web service is unavailable or fails, the method logs an error and falls back to an internal method: ReviewBid.fallback_algorithm. The result is returned as a hash mapping reviewer IDs to arrays of assigned topic IDs.&lt;br /&gt;
&lt;br /&gt;
====== Method: self.run_bidding_algorithm ======&lt;br /&gt;
&lt;br /&gt;
This method retrieves the review bidding web service URL from the app configuration (config/webservices.yml) and calls the internal send_bidding_request method to make the actual request.It logs the outgoing URL for debugging and delegates the response parsing.&lt;br /&gt;
&lt;br /&gt;
====== Private Method: send_bidding_request ======&lt;br /&gt;
&lt;br /&gt;
This private class method handles the HTTP POST request using RestClient. It sends the bidding data as JSON and expects a JSON response. If the request fails due to a connection error, server error, or timeout, the method logs the exception and returns false, allowing the caller to trigger a fallback.&lt;br /&gt;
&lt;br /&gt;
[[File:Review_bidding_algorithm_service.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Fallback Algorithm ===&lt;br /&gt;
=====   ''Introduction''   =====&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm in Expertiza is designed to ensure automatic topic assignment when the primary Bidding Algorithm fails due to Web Service unavailability.  &lt;br /&gt;
&lt;br /&gt;
Normally, Expertiza allows reviewers to bid on topics, and the ''ReviewBiddingAlgorithmService'' processes these bids to assign topics. However, when this web service ''fails'' (due to API downtime, server issues, or unexpected errors), the system must switch to fallback and automatically assign topics to reviewers.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Solution''   =====&lt;br /&gt;
It is triggered when the web service is unavailable. It ensures fair topic assignment by:  &lt;br /&gt;
* Prioritizing topics with the largest teams.  &lt;br /&gt;
* Using a round-robin approach to distribute topics among reviewers.  &lt;br /&gt;
* Ensuring reviewers do not get their own team’s topic.  &lt;br /&gt;
&lt;br /&gt;
=====   ''When is this Used?''  ===== &lt;br /&gt;
* The ReviewBiddingAlgorithmService fails due to an API issue.  &lt;br /&gt;
* The web service times out or returns an error.  &lt;br /&gt;
* Unexpected exceptions occur in the bidding process.  &lt;br /&gt;
&lt;br /&gt;
Instead of stopping the review process, the system automatically falls-back to an internal algorithm to distribute topics.  &lt;br /&gt;
&lt;br /&gt;
=====   ''How Does the Fallback Algorithm Work?''   ===== &lt;br /&gt;
The algorithm follows these **four main steps:  &lt;br /&gt;
* Fetch available topics – Retrieves all topics for the given assignment.  &lt;br /&gt;
* Sort topics by team size – Topics with more members are given priority.  &lt;br /&gt;
* Create a topic queue – Topics are arranged in descending order of team size.  &lt;br /&gt;
* Assign topics in a round-robin manner – Reviewers are assigned topics while avoiding their own team's topic.  &lt;br /&gt;
&lt;br /&gt;
This ensures ''fair and balanced'' distribution of topics. If ''ReviewBiddingAlgorithmService'' fails, the system automatically calls fallback_algorithm.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Implementation - Model Code (Fallback Algorithm)''   =====&lt;br /&gt;
This method ensures fair topic assignment when the bidding system fails.&lt;br /&gt;
&lt;br /&gt;
[[File:X5x.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: This function ensures every reviewer receives a topic without requiring manual intervention.&lt;br /&gt;
&lt;br /&gt;
=====   ''RSpec Testing of Fallback Algorithm''   =====&lt;br /&gt;
To verify correctness, we use unit tests in ''review_bid_spec.rb''&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm ensures that ''topics are assigned fairly'' even when the primary bidding service fails. By prioritizing ''larger teams'', ''avoiding self-review'', and using a ''round-robin strategy'', the fallback mechanism keeps the review process smooth and automatic.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
This section outlines the test plan for this project including testing scenarios/edge cases, the manual testing plan, and the automatic/RSpec testing plan.&lt;br /&gt;
&lt;br /&gt;
=== ''Testing Scenarios'' ===&lt;br /&gt;
This section outlines the various bidding scenarios that could occur. These scenarios should be tested in either '''Manual Testing''' or '''Automatic Testing'''.&lt;br /&gt;
&lt;br /&gt;
==== Basic Bidding Scenario ====&lt;br /&gt;
*Reviewers bid on multiple projects at different times&lt;br /&gt;
** Bidding algorithm should give priority to reviewers that bid first and should assign based on reviewers ranking&lt;br /&gt;
&lt;br /&gt;
====   Edge Cases   ====&lt;br /&gt;
* All reviewers bid on the same project&lt;br /&gt;
** If different time stamps: bidding algorithm should give priority to reviewers that bid first&lt;br /&gt;
** If same time stamps: bidding algorithm should assign reviews randomly&lt;br /&gt;
* None of the reviews bid on any projects&lt;br /&gt;
** Bidding algorithm should assign reviews randomly&lt;br /&gt;
* Reviewer bids on their own project&lt;br /&gt;
** Bidding algorithm should not allow a reviewer to bid on their own project and should have validation to prevent assigning a reviewer their own project&lt;br /&gt;
* None of the reviewers bid on a specific project&lt;br /&gt;
** Bidding algorithm should still assign reviewers to this project&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Manual Testing''   ===&lt;br /&gt;
Manual testing should be preformed on an Expertiza server and webserver platform &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Plan for Expertiza Server ====&lt;br /&gt;
* test that an instructor can allow review bidding for an assignment&lt;br /&gt;
* test that server routes correctly when review bidding is allowed&lt;br /&gt;
** test that task box links to bidding page before algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to bidding page before algorithm is run&lt;br /&gt;
** test that task box links to review page with bidding information after algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to review page with bidding information after algorithm is run&lt;br /&gt;
* test that the bidding UI is implemented as expected&lt;br /&gt;
* test that a participant can bid on projects to review&lt;br /&gt;
** test that a participant can move projects into the bidding column&lt;br /&gt;
** test that a participant can reorder projects in the bidding column&lt;br /&gt;
** test that a participant's bidding preferences save&lt;br /&gt;
** test that a participant can't bid for their own topic&lt;br /&gt;
* test that run algorithm button calls webserver with correct information and returns review assignments for each user&lt;br /&gt;
&lt;br /&gt;
==== Directions for Manual Testing of Expertiza Server ====&lt;br /&gt;
1. Go to [http://152.7.99.70:8081/ testing server] &amp;lt;br&amp;gt;&lt;br /&gt;
2. Log in as username: '''instructor6''' password: '''password''' &amp;lt;br&amp;gt;&lt;br /&gt;
3. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''General''' tab make sure '''Has teams?''' and '''Has topics?''' are checked&lt;br /&gt;
:# In the '''Topics''' tab check '''Allow review to choose which topic to review?''' then click '''save'''&lt;br /&gt;
:# In the '''Topics''' tab select '''Bidding''' then click '''save'''&lt;br /&gt;
4. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# This UI is based on '''instructor6''' being a '''participant''' assigned to topic '''Topic4'''&lt;br /&gt;
::# The UI blocks user from bidding on their own project &lt;br /&gt;
::# Check that user can bid on topics and reorder bids&lt;br /&gt;
::# Check that users topic preferences save on page refresh&lt;br /&gt;
::# Impersonate other participants and repeat bidding UI tests ('''student7601''', '''student7602''', '''student7603''', '''student7604''', '''student7605''', '''student7606''', '''student7607''', '''student7608''', '''student7609'')&lt;br /&gt;
5. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''Topics''' tab click '''Run Review Algorithm''' button&lt;br /&gt;
6. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# '''E2085 Manual Testing review''' should now link to the reviewing page&lt;br /&gt;
::# The number of required reviews should already be displayed&lt;br /&gt;
::# A '''Request Another Review''' button should be present unless reviews listed is equal to the number of reviews allowed&lt;br /&gt;
::# '''Begin''' a review and test '''save''' and '''submit'''&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Demo Video for Expertiza Server ====&lt;br /&gt;
Video demonstration of manual testing: [https://www.screencast.com/t/0rSg1zDW here]&lt;br /&gt;
&lt;br /&gt;
=== ''Automatic/PyTest Testing '' ===&lt;br /&gt;
Pytest tests are written for the webservice to test a well formed and a malformed request.&lt;br /&gt;
&lt;br /&gt;
===   ''Automatic/RSpec Testing ''   ===&lt;br /&gt;
RSpec tests will need to be refactored according to the changes that we make in the expertiza repository. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== RSpec Testing Plan ====&lt;br /&gt;
These RSpec tests will need to:&lt;br /&gt;
* test basic functionality of review bids controller&lt;br /&gt;
* test basic functionality of review bid model&lt;br /&gt;
&lt;br /&gt;
==== Directions for RSpec Testing ====&lt;br /&gt;
:# on personal device using [https://github.com/ncsu-ngw/expertiza forked repo]&lt;br /&gt;
:# Run the following commands:&lt;br /&gt;
&lt;br /&gt;
 # review bids controller: &lt;br /&gt;
 bundle exec rspec spec/controllers/review_bids_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
 # review bid model: &lt;br /&gt;
 bundle exec rspec spec/models/review_bid_spec.rb&lt;br /&gt;
 &lt;br /&gt;
 # review bidding algorithm service:&lt;br /&gt;
 bundle exec rspec spec/services/review_bidding_algorithm_service_spec.rb&lt;br /&gt;
&lt;br /&gt;
==Test Coverage==&lt;br /&gt;
* Code Climate: [https://codeclimate.com/github/expertiza/expertiza/pull/2931 here]&lt;br /&gt;
&lt;br /&gt;
[[File:code-climate.png|700px]]&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
&lt;br /&gt;
'''Mentor:''' Janice Uwujaren (juwujar) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ashwin Muniswamy (akumarm) &amp;lt;br&amp;gt;&lt;br /&gt;
Arturo Serdan (aaserdan) &amp;lt;br&amp;gt;&lt;br /&gt;
Nicholas Winsen (nwinsen) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====''Previous Implementations''=====&lt;br /&gt;
Fall 2019 [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Spring 2020 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2020 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2024 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2508._Reimplement_bidding-algorithm_web_service here]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====''Relevant Links''=====&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/2931 &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
''Video Demo'': https://app.screencast.com/vaiJnWpHf0r07&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:X9x.png&amp;diff=162740</id>
		<title>File:X9x.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:X9x.png&amp;diff=162740"/>
		<updated>2025-03-25T03:10:19Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162726</id>
		<title>CSC/ECE 517 Spring 2025 - E2508. Reimplement bidding-algorithm web service</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162726"/>
		<updated>2025-03-25T02:57:32Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Project Overview==&lt;br /&gt;
===   ''Background''   ===&lt;br /&gt;
The previous implementation of the bidding service was hosted on peerlogic by a former student. The University no longer has access to this hosting service, and  is requiring a new solution. It is also asked that the webservice accept a better and cleaner json format which is easier to interpret and read.&lt;br /&gt;
&lt;br /&gt;
===   ''Objectives''   ===&lt;br /&gt;
# Reimplement trading cycles on a webservice&lt;br /&gt;
# Figure out a new hosting solution for the BiddingService web service. (VCL)&lt;br /&gt;
# Host the webservice on VCL&lt;br /&gt;
# Using tmux, figure out a way to keep the process running with a production wsgi service compatible with Flask.&lt;br /&gt;
# Create new tests for the repository&lt;br /&gt;
# Create a list of required packages that future maintainers can install easily&lt;br /&gt;
# Create a tests directory that users can test the functionality of the code with&lt;br /&gt;
# Modularize the code further, eliminate code smells.&lt;br /&gt;
# Refactor existing backend logic to account for the new json format&lt;br /&gt;
# Refactor existing backend code to send HTTP requests to the correct IP address&lt;br /&gt;
# Refactor existing frontend code to provide a list for users to select multiple topics on the frontend&lt;br /&gt;
# Allow users to prioritize their topic selection on the frontend&lt;br /&gt;
# Users should not be allowed to bid on their review topics on the frontend&lt;br /&gt;
# Display the results of the matched topics on the frontend&lt;br /&gt;
&lt;br /&gt;
===   ''Previous Work''   ===&lt;br /&gt;
There have been three previous implementations: &amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2019 [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Spring 2020 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2020 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2024 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2508._Reimplement_bidding-algorithm_web_service here]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/2931 &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Files Modified''   ===&lt;br /&gt;
This is a list of all the files added or changed in completing this project. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Changed'': &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/app.py - accomodated for changes in JsonParser&lt;br /&gt;
*app/json_parser.py - moved functions out due to SRP&lt;br /&gt;
*app/topics_matcher.py&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Added'': &amp;lt;br&amp;gt;&lt;br /&gt;
*app/tests/sample.json &amp;lt;br&amp;gt; - Sample input for the tests.&lt;br /&gt;
&lt;br /&gt;
*app/tests/test_assignment.py &amp;lt;br&amp;gt; Test File to test forms of input - tests both a successful and unsuccessful input&lt;br /&gt;
&lt;br /&gt;
*app/utils/popular_topics.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/student_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/topic_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
&lt;br /&gt;
*setup.py - required for wsgi&lt;br /&gt;
*wsgi.py - for hosting the server via gunicorn on VCL.&lt;br /&gt;
*.gitignore - to ignore anything that we may not want pushed (mostly for venv)&lt;br /&gt;
*requirements.txt - a list of requirements made easy for future maintainers&lt;br /&gt;
&lt;br /&gt;
=== ''Webservice'' ===&lt;br /&gt;
===== ''app'' =====&lt;br /&gt;
&lt;br /&gt;
The entry point to the Web service is the app.py file where we have the POST Method match_topics.&lt;br /&gt;
This receives the input in a json format from Expertiza. The input will contain a list of task ids, and then an Object of users, which each contain their student id and correlated bids that they made. Each bid contains a task id, a priority, and a timestamp. The input format was reworked to align to this style since it made more sense to have each student have a list of bids instead of the previous implementation which did not have this case. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:App2508.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''json parser'' =====&lt;br /&gt;
The json parser converts the json into a Dictionary. The previous implementation also had the parser create a preferences dictionary for the Student to store their topic preferences and one for Topics to store list of topics which have been selected by students and also the priority for the selection using the Timestamps. However, this was removed due to the Single Responsibility Principle. We felt the json parser was doing too much and should only be parsing the json!&lt;br /&gt;
&lt;br /&gt;
[[File:init_parser.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The student priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:student_prio.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The topic priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:topic_priorities.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== ''Test Input'' =====&lt;br /&gt;
&lt;br /&gt;
Sample Test case:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Case:&amp;lt;/b&amp;gt; There are a few very popular topics and the students who bid for them and bid early should receive it.&lt;br /&gt;
Popular Topics: 3969, 3971, 3972&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;tid&amp;quot;: [4427, 4428, 4429, 4430],&lt;br /&gt;
    &amp;quot;users&amp;quot;: {&lt;br /&gt;
      &amp;quot;40763&amp;quot;: {&lt;br /&gt;
          &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4429&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40764&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4427&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40765&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:15 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:16 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:17 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4428&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;max_accepted_proposals&amp;quot;: 3&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''Output'' =====&lt;br /&gt;
&lt;br /&gt;
 Since there is competition for these topics, the algorithm recognizes this and makes sure to assign them only to the students who bid for it.&lt;br /&gt;
		Other students who picked other topics or did not pick anything are assigned different topics.&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
    &amp;quot;40763&amp;quot;: [&lt;br /&gt;
        4427,&lt;br /&gt;
        4428,&lt;br /&gt;
        4430&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40764&amp;quot;: [&lt;br /&gt;
        4428,&lt;br /&gt;
        4430,&lt;br /&gt;
        4429&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40765&amp;quot;: [&lt;br /&gt;
        4429,&lt;br /&gt;
        4427,&lt;br /&gt;
        4430&lt;br /&gt;
    ]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== ''Controller'' ===&lt;br /&gt;
&lt;br /&gt;
The controller includes 8 methods that handle the review bidding process. The public methods cover authorization, rendering views, saving user bids, and coordinating review assignment. The private methods support these functions by abstracting data gathering and algorithm coordination logic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Method: action_allowed? ======&lt;br /&gt;
&lt;br /&gt;
This method controls user access to controller actions. It allows 'Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator', and 'Student' roles to access show, set_priority, and index. Other actions are restricted to non-student roles. It ensures proper permissions for accessing review bidding features.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: index ======&lt;br /&gt;
&lt;br /&gt;
This method gathers information for the &amp;quot;Your Work&amp;quot; page, where users can view their assigned reviews. It checks user identity, retrieves associated reviews, and counts completed reviews. The view rendered is sign_up_sheet/review_bids_others_work.View: others_work.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_index.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: show ======&lt;br /&gt;
&lt;br /&gt;
This method renders the bidding page where users select topics they'd prefer to review. It fetches the assignment, available topics, and any existing bids. Already assigned or signed-up topics are excluded. The page also lists any assigned reviews.View: show.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_show.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: set_priority ======&lt;br /&gt;
&lt;br /&gt;
This method stores or updates a participant's topic preferences. It removes old bids not in the current selection and creates or updates the remaining bids with new priorities. This method is triggered when users submit their topic rankings on the bidding page.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_set_priority.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_bidding ======&lt;br /&gt;
&lt;br /&gt;
This method coordinates the assignment of review topics. It gathers reviewer IDs and invokes the bidding algorithm using a service. It validates the output and uses ReviewBid.assign_review_topics to perform the actual assignment. Bidding is then disabled.&lt;br /&gt;
&lt;br /&gt;
[[File:X8x.png|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: fetch_reviewer_ids (Private) ======&lt;br /&gt;
&lt;br /&gt;
This helper method retrieves all AssignmentParticipant IDs for a given assignment. These IDs represent the reviewers participating in the bidding process.&lt;br /&gt;
&lt;br /&gt;
====== Method: process_bidding (Private) ======&lt;br /&gt;
This helper method delegates the logic for running the bidding algorithm to the service class ReviewBiddingAlgorithmService. It takes the assignment ID and list of reviewers as input and returns matched topic assignments.&lt;br /&gt;
&lt;br /&gt;
====== Method: ensure_valid_topics (Private) ======&lt;br /&gt;
This method ensures that all reviewers have valid topic assignment entries, even if the algorithm returns nothing (e.g., due to web service failure). It initializes empty topic arrays for any missing reviewers.&lt;br /&gt;
&lt;br /&gt;
[[File:Controller_private_methods.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== ''Model'' ===&lt;br /&gt;
&lt;br /&gt;
The model includes 13 methods that manage the review bidding process. The public methods handle bidding data retrieval, review topic assignment, and fallback allocation. The private methods support these functions by fetching user and team data, sorting topics, and formatting bid details.&lt;br /&gt;
&lt;br /&gt;
====== Method: bidding_data ======&lt;br /&gt;
&lt;br /&gt;
Collects bidding data for an assignment, including topics, max allowed proposals, and individual reviewer bids.&lt;br /&gt;
&lt;br /&gt;
[[File:X1x1.png|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_review_topics ======&lt;br /&gt;
&lt;br /&gt;
Assigns reviewers to topics based on matched preferences and clears previous assignments.&lt;br /&gt;
&lt;br /&gt;
[[File:X2x.png|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_topic_to_reviewer ======&lt;br /&gt;
&lt;br /&gt;
Assigns a single topic to a reviewer by linking them to a team under that topic.&lt;br /&gt;
&lt;br /&gt;
[[File:X3x.png|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: reviewer_bidding_data ======&lt;br /&gt;
&lt;br /&gt;
Retrieves bid details for a specific reviewer, including self-selected topics and bid priorities.&lt;br /&gt;
&lt;br /&gt;
[[File:File4.png|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: fallback_algorithm ======&lt;br /&gt;
&lt;br /&gt;
Assigns topics to reviewers using a fallback approach when the initial bidding fails.&lt;br /&gt;
&lt;br /&gt;
[[File:X5x.png|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Private Methods ======&lt;br /&gt;
&lt;br /&gt;
* sorted_topic_queue – Sorts topics based on the number of team members and returns them in descending order&lt;br /&gt;
* assign_topics – Iterates through reviewers and assigns topics from the sorted queue, ensuring balanced distribution&lt;br /&gt;
* find_available_topic – Selects an available topic for a reviewer while avoiding self-selected topics&lt;br /&gt;
* reviewer_team_id – Retrieves the team ID associated with a given reviewer&lt;br /&gt;
* find_reviewer_user_id – Fetches the user ID for a given reviewer&lt;br /&gt;
* fetch_self_topic – Gets the topic that the user has self-selected for an assignment&lt;br /&gt;
* fetch_team_id – Finds the team ID for a given user in an assignment&lt;br /&gt;
* fetch_team_bids – Retrieves all bid records associated with a specific team&lt;br /&gt;
* format_bid – Converts a bid record into a structured format with topic ID, priority, and a formatted timestamp&lt;br /&gt;
&lt;br /&gt;
[[File:X6x.png|700px]]&lt;br /&gt;
&lt;br /&gt;
[[File:X7x.png|700px]]&lt;br /&gt;
&lt;br /&gt;
=== ''Service'' ===&lt;br /&gt;
&lt;br /&gt;
The ReviewBiddingAlgorithmService is a service object responsible for handling communication between the application and the external web service that executes the review bidding algorithm. It prepares bidding data, sends it to the web service, processes the response, and provides a fallback mechanism in case of failure.&lt;br /&gt;
&lt;br /&gt;
This service allows to encapsulate all logic required to interact with the external topic-matching web service. It separates the algorithm execution concerns from the controller, improving modularity, testability, and maintainability of the code.&lt;br /&gt;
&lt;br /&gt;
====== Method: self.process_bidding ======&lt;br /&gt;
&lt;br /&gt;
This is the primary entry point for the controller. It accepts the assignment_id and a list of reviewer_ids, then prepares the bidding data by calling ReviewBid.bidding_data(...). It passes the data to the web service by calling run_bidding_algorithm. If the web service is unavailable or fails, the method logs an error and falls back to an internal method: ReviewBid.fallback_algorithm. The result is returned as a hash mapping reviewer IDs to arrays of assigned topic IDs.&lt;br /&gt;
&lt;br /&gt;
====== Method: self.run_bidding_algorithm ======&lt;br /&gt;
&lt;br /&gt;
This method retrieves the review bidding web service URL from the app configuration (config/webservices.yml) and calls the internal send_bidding_request method to make the actual request.It logs the outgoing URL for debugging and delegates the response parsing.&lt;br /&gt;
&lt;br /&gt;
====== Private Method: send_bidding_request ======&lt;br /&gt;
&lt;br /&gt;
This private class method handles the HTTP POST request using RestClient. It sends the bidding data as JSON and expects a JSON response. If the request fails due to a connection error, server error, or timeout, the method logs the exception and returns false, allowing the caller to trigger a fallback.&lt;br /&gt;
&lt;br /&gt;
[[File:Review_bidding_algorithm_service.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Fallback Algorithm ===&lt;br /&gt;
=====   ''Introduction''   =====&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm in Expertiza is designed to ensure automatic topic assignment when the primary Bidding Algorithm fails due to Web Service unavailability.  &lt;br /&gt;
&lt;br /&gt;
Normally, Expertiza allows reviewers to bid on topics, and the ''ReviewBiddingAlgorithmService'' processes these bids to assign topics. However, when this web service ''fails'' (due to API downtime, server issues, or unexpected errors), the system must switch to fallback and automatically assign topics to reviewers.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Solution''   =====&lt;br /&gt;
It is triggered when the web service is unavailable. It ensures fair topic assignment by:  &lt;br /&gt;
* Prioritizing topics with the largest teams.  &lt;br /&gt;
* Using a round-robin approach to distribute topics among reviewers.  &lt;br /&gt;
* Ensuring reviewers do not get their own team’s topic.  &lt;br /&gt;
&lt;br /&gt;
=====   ''When is this Used?''  ===== &lt;br /&gt;
* The ReviewBiddingAlgorithmService fails due to an API issue.  &lt;br /&gt;
* The web service times out or returns an error.  &lt;br /&gt;
* Unexpected exceptions occur in the bidding process.  &lt;br /&gt;
&lt;br /&gt;
Instead of stopping the review process, the system automatically falls-back to an internal algorithm to distribute topics.  &lt;br /&gt;
&lt;br /&gt;
=====   ''How Does the Fallback Algorithm Work?''   ===== &lt;br /&gt;
The algorithm follows these **four main steps:  &lt;br /&gt;
* Fetch available topics – Retrieves all topics for the given assignment.  &lt;br /&gt;
* Sort topics by team size – Topics with more members are given priority.  &lt;br /&gt;
* Create a topic queue – Topics are arranged in descending order of team size.  &lt;br /&gt;
* Assign topics in a round-robin manner – Reviewers are assigned topics while avoiding their own team's topic.  &lt;br /&gt;
&lt;br /&gt;
This ensures ''fair and balanced'' distribution of topics.&lt;br /&gt;
  &lt;br /&gt;
=====   ''Implementation - Controller Code (Triggering the Fallback)''   =====&lt;br /&gt;
If the primary bidding service fails, the system catches the error and calls the Fallback Algorithm.&lt;br /&gt;
&lt;br /&gt;
[[File:X8x.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: If ''ReviewBiddingAlgorithmService'' fails, the system automatically calls fallback_algorithm.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Implementation - Model Code (Fallback Algorithm)''   =====&lt;br /&gt;
This method ensures fair topic assignment when the bidding system fails.&lt;br /&gt;
&lt;br /&gt;
[[File:X5x.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: This function ensures every reviewer receives a topic without requiring manual intervention.&lt;br /&gt;
&lt;br /&gt;
=====   ''RSpec Testing of Fallback Algorithm''   =====&lt;br /&gt;
To verify correctness, we use unit tests in ''review_bid_spec.rb''&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm ensures that ''topics are assigned fairly'' even when the primary bidding service fails. By prioritizing ''larger teams'', ''avoiding self-review'', and using a ''round-robin strategy'', the fallback mechanism keeps the review process smooth and automatic.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
This section outlines the test plan for this project including testing scenarios/edge cases, the manual testing plan, and the automatic/RSpec testing plan.&lt;br /&gt;
&lt;br /&gt;
=== ''Testing Scenarios'' ===&lt;br /&gt;
This section outlines the various bidding scenarios that could occur. These scenarios should be tested in either '''Manual Testing''' or '''Automatic Testing'''.&lt;br /&gt;
&lt;br /&gt;
==== Basic Bidding Scenario ====&lt;br /&gt;
*Reviewers bid on multiple projects at different times&lt;br /&gt;
** Bidding algorithm should give priority to reviewers that bid first and should assign based on reviewers ranking&lt;br /&gt;
&lt;br /&gt;
====   Edge Cases   ====&lt;br /&gt;
* All reviewers bid on the same project&lt;br /&gt;
** If different time stamps: bidding algorithm should give priority to reviewers that bid first&lt;br /&gt;
** If same time stamps: bidding algorithm should assign reviews randomly&lt;br /&gt;
* None of the reviews bid on any projects&lt;br /&gt;
** Bidding algorithm should assign reviews randomly&lt;br /&gt;
* Reviewer bids on their own project&lt;br /&gt;
** Bidding algorithm should not allow a reviewer to bid on their own project and should have validation to prevent assigning a reviewer their own project&lt;br /&gt;
* None of the reviewers bid on a specific project&lt;br /&gt;
** Bidding algorithm should still assign reviewers to this project&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Manual Testing''   ===&lt;br /&gt;
Manual testing should be preformed on an Expertiza server and webserver platform &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Plan for Expertiza Server ====&lt;br /&gt;
* test that an instructor can allow review bidding for an assignment&lt;br /&gt;
* test that server routes correctly when review bidding is allowed&lt;br /&gt;
** test that task box links to bidding page before algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to bidding page before algorithm is run&lt;br /&gt;
** test that task box links to review page with bidding information after algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to review page with bidding information after algorithm is run&lt;br /&gt;
* test that the bidding UI is implemented as expected&lt;br /&gt;
* test that a participant can bid on projects to review&lt;br /&gt;
** test that a participant can move projects into the bidding column&lt;br /&gt;
** test that a participant can reorder projects in the bidding column&lt;br /&gt;
** test that a participant's bidding preferences save&lt;br /&gt;
** test that a participant can't bid for their own topic&lt;br /&gt;
* test that run algorithm button calls webserver with correct information and returns review assignments for each user&lt;br /&gt;
&lt;br /&gt;
==== Directions for Manual Testing of Expertiza Server ====&lt;br /&gt;
1. Go to [http://152.7.99.70:8081/ testing server] &amp;lt;br&amp;gt;&lt;br /&gt;
2. Log in as username: '''instructor6''' password: '''password''' &amp;lt;br&amp;gt;&lt;br /&gt;
3. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''General''' tab make sure '''Has teams?''' and '''Has topics?''' are checked&lt;br /&gt;
:# In the '''Topics''' tab check '''Allow review to choose which topic to review?''' then click '''save'''&lt;br /&gt;
:# In the '''Topics''' tab select '''Bidding''' then click '''save'''&lt;br /&gt;
4. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# This UI is based on '''instructor6''' being a '''participant''' assigned to topic '''Topic4'''&lt;br /&gt;
::# The UI blocks user from bidding on their own project &lt;br /&gt;
::# Check that user can bid on topics and reorder bids&lt;br /&gt;
::# Check that users topic preferences save on page refresh&lt;br /&gt;
::# Impersonate other participants and repeat bidding UI tests ('''student7601''', '''student7602''', '''student7603''', '''student7604''', '''student7605''', '''student7606''', '''student7607''', '''student7608''', '''student7609'')&lt;br /&gt;
5. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''Topics''' tab click '''Run Review Algorithm''' button&lt;br /&gt;
6. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# '''E2085 Manual Testing review''' should now link to the reviewing page&lt;br /&gt;
::# The number of required reviews should already be displayed&lt;br /&gt;
::# A '''Request Another Review''' button should be present unless reviews listed is equal to the number of reviews allowed&lt;br /&gt;
::# '''Begin''' a review and test '''save''' and '''submit'''&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Demo Video for Expertiza Server ====&lt;br /&gt;
Video demonstration of manual testing: [https://www.screencast.com/t/0rSg1zDW here]&lt;br /&gt;
&lt;br /&gt;
=== ''Automatic/PyTest Testing '' ===&lt;br /&gt;
Pytest tests are written for the webservice to test a well formed and a malformed request.&lt;br /&gt;
&lt;br /&gt;
===   ''Automatic/RSpec Testing ''   ===&lt;br /&gt;
RSpec tests will need to be refactored according to the changes that we make in the expertiza repository. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== RSpec Testing Plan ====&lt;br /&gt;
These RSpec tests will need to:&lt;br /&gt;
* test basic functionality of review bids controller&lt;br /&gt;
* test basic functionality of review bid model&lt;br /&gt;
&lt;br /&gt;
==== Directions for RSpec Testing ====&lt;br /&gt;
:# on personal device using [https://github.com/ncsu-ngw/expertiza forked repo]&lt;br /&gt;
:# Run the following commands:&lt;br /&gt;
&lt;br /&gt;
 # review bids controller: &lt;br /&gt;
 bundle exec rspec spec/controllers/review_bids_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
 # review bid model: &lt;br /&gt;
 bundle exec rspec spec/models/review_bid_spec.rb&lt;br /&gt;
 &lt;br /&gt;
 # review bidding algorithm service:&lt;br /&gt;
 bundle exec rspec spec/services/review_bidding_algorithm_service_spec.rb&lt;br /&gt;
&lt;br /&gt;
==Test Coverage==&lt;br /&gt;
* Code Climate: [https://codeclimate.com/github/expertiza/expertiza/pull/2931 here]&lt;br /&gt;
&lt;br /&gt;
[[File:code-climate.png|700px]]&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
&lt;br /&gt;
'''Mentor:''' Janice Uwujaren (juwujar) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ashwin Muniswamy (akumarm) &amp;lt;br&amp;gt;&lt;br /&gt;
Arturo Serdan (aaserdan) &amp;lt;br&amp;gt;&lt;br /&gt;
Nicholas Winsen (nwinsen) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====''Previous Implementations''=====&lt;br /&gt;
Fall 2019 [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Spring 2020 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2020 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2024 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2508._Reimplement_bidding-algorithm_web_service here]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====''Relevant Links''=====&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/2931 &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
''Video Demo'': https://app.screencast.com/vaiJnWpHf0r07&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162721</id>
		<title>CSC/ECE 517 Spring 2025 - E2508. Reimplement bidding-algorithm web service</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162721"/>
		<updated>2025-03-25T02:55:19Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Project Overview==&lt;br /&gt;
===   ''Background''   ===&lt;br /&gt;
The previous implementation of the bidding service was hosted on peerlogic by a former student. The University no longer has access to this hosting service, and  is requiring a new solution. It is also asked that the webservice accept a better and cleaner json format which is easier to interpret and read.&lt;br /&gt;
&lt;br /&gt;
===   ''Objectives''   ===&lt;br /&gt;
# Reimplement trading cycles on a webservice&lt;br /&gt;
# Figure out a new hosting solution for the BiddingService web service. (VCL)&lt;br /&gt;
# Host the webservice on VCL&lt;br /&gt;
# Using tmux, figure out a way to keep the process running with a production wsgi service compatible with Flask.&lt;br /&gt;
# Create new tests for the repository&lt;br /&gt;
# Create a list of required packages that future maintainers can install easily&lt;br /&gt;
# Create a tests directory that users can test the functionality of the code with&lt;br /&gt;
# Modularize the code further, eliminate code smells.&lt;br /&gt;
# Refactor existing backend logic to account for the new json format&lt;br /&gt;
# Refactor existing backend code to send HTTP requests to the correct IP address&lt;br /&gt;
# Refactor existing frontend code to provide a list for users to select multiple topics on the frontend&lt;br /&gt;
# Allow users to prioritize their topic selection on the frontend&lt;br /&gt;
# Users should not be allowed to bid on their review topics on the frontend&lt;br /&gt;
# Display the results of the matched topics on the frontend&lt;br /&gt;
&lt;br /&gt;
===   ''Previous Work''   ===&lt;br /&gt;
There have been three previous implementations: &amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2019 [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Spring 2020 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2020 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2024 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2508._Reimplement_bidding-algorithm_web_service here]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/2931 &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Files Modified''   ===&lt;br /&gt;
This is a list of all the files added or changed in completing this project. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Changed'': &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/app.py - accomodated for changes in JsonParser&lt;br /&gt;
*app/json_parser.py - moved functions out due to SRP&lt;br /&gt;
*app/topics_matcher.py&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Added'': &amp;lt;br&amp;gt;&lt;br /&gt;
*app/tests/sample.json &amp;lt;br&amp;gt; - Sample input for the tests.&lt;br /&gt;
&lt;br /&gt;
*app/tests/test_assignment.py &amp;lt;br&amp;gt; Test File to test forms of input - tests both a successful and unsuccessful input&lt;br /&gt;
&lt;br /&gt;
*app/utils/popular_topics.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/student_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/topic_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
&lt;br /&gt;
*setup.py - required for wsgi&lt;br /&gt;
*wsgi.py - for hosting the server via gunicorn on VCL.&lt;br /&gt;
*.gitignore - to ignore anything that we may not want pushed (mostly for venv)&lt;br /&gt;
*requirements.txt - a list of requirements made easy for future maintainers&lt;br /&gt;
&lt;br /&gt;
=== ''Webservice'' ===&lt;br /&gt;
===== ''app'' =====&lt;br /&gt;
&lt;br /&gt;
The entry point to the Web service is the app.py file where we have the POST Method match_topics.&lt;br /&gt;
This receives the input in a json format from Expertiza. The input will contain a list of task ids, and then an Object of users, which each contain their student id and correlated bids that they made. Each bid contains a task id, a priority, and a timestamp. The input format was reworked to align to this style since it made more sense to have each student have a list of bids instead of the previous implementation which did not have this case. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:App2508.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''json parser'' =====&lt;br /&gt;
The json parser converts the json into a Dictionary. The previous implementation also had the parser create a preferences dictionary for the Student to store their topic preferences and one for Topics to store list of topics which have been selected by students and also the priority for the selection using the Timestamps. However, this was removed due to the Single Responsibility Principle. We felt the json parser was doing too much and should only be parsing the json!&lt;br /&gt;
&lt;br /&gt;
[[File:init_parser.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The student priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:student_prio.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The topic priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:topic_priorities.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== ''Test Input'' =====&lt;br /&gt;
&lt;br /&gt;
Sample Test case:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Case:&amp;lt;/b&amp;gt; There are a few very popular topics and the students who bid for them and bid early should receive it.&lt;br /&gt;
Popular Topics: 3969, 3971, 3972&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;tid&amp;quot;: [4427, 4428, 4429, 4430],&lt;br /&gt;
    &amp;quot;users&amp;quot;: {&lt;br /&gt;
      &amp;quot;40763&amp;quot;: {&lt;br /&gt;
          &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4429&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40764&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4427&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40765&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:15 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:16 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:17 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4428&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;max_accepted_proposals&amp;quot;: 3&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''Output'' =====&lt;br /&gt;
&lt;br /&gt;
 Since there is competition for these topics, the algorithm recognizes this and makes sure to assign them only to the students who bid for it.&lt;br /&gt;
		Other students who picked other topics or did not pick anything are assigned different topics.&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
    &amp;quot;40763&amp;quot;: [&lt;br /&gt;
        4427,&lt;br /&gt;
        4428,&lt;br /&gt;
        4430&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40764&amp;quot;: [&lt;br /&gt;
        4428,&lt;br /&gt;
        4430,&lt;br /&gt;
        4429&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40765&amp;quot;: [&lt;br /&gt;
        4429,&lt;br /&gt;
        4427,&lt;br /&gt;
        4430&lt;br /&gt;
    ]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== ''Controller'' ===&lt;br /&gt;
&lt;br /&gt;
The controller includes 8 methods that handle the review bidding process. The public methods cover authorization, rendering views, saving user bids, and coordinating review assignment. The private methods support these functions by abstracting data gathering and algorithm coordination logic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Method: action_allowed? ======&lt;br /&gt;
&lt;br /&gt;
This method controls user access to controller actions. It allows 'Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator', and 'Student' roles to access show, set_priority, and index. Other actions are restricted to non-student roles. It ensures proper permissions for accessing review bidding features.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: index ======&lt;br /&gt;
&lt;br /&gt;
This method gathers information for the &amp;quot;Your Work&amp;quot; page, where users can view their assigned reviews. It checks user identity, retrieves associated reviews, and counts completed reviews. The view rendered is sign_up_sheet/review_bids_others_work.View: others_work.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_index.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: show ======&lt;br /&gt;
&lt;br /&gt;
This method renders the bidding page where users select topics they'd prefer to review. It fetches the assignment, available topics, and any existing bids. Already assigned or signed-up topics are excluded. The page also lists any assigned reviews.View: show.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_show.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: set_priority ======&lt;br /&gt;
&lt;br /&gt;
This method stores or updates a participant's topic preferences. It removes old bids not in the current selection and creates or updates the remaining bids with new priorities. This method is triggered when users submit their topic rankings on the bidding page.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_set_priority.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_bidding ======&lt;br /&gt;
&lt;br /&gt;
This method coordinates the assignment of review topics. It gathers reviewer IDs and invokes the bidding algorithm using a service. It validates the output and uses ReviewBid.assign_review_topics to perform the actual assignment. Bidding is then disabled.&lt;br /&gt;
&lt;br /&gt;
[[File:X8x.png|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: fetch_reviewer_ids (Private) ======&lt;br /&gt;
&lt;br /&gt;
This helper method retrieves all AssignmentParticipant IDs for a given assignment. These IDs represent the reviewers participating in the bidding process.&lt;br /&gt;
&lt;br /&gt;
====== Method: process_bidding (Private) ======&lt;br /&gt;
This helper method delegates the logic for running the bidding algorithm to the service class ReviewBiddingAlgorithmService. It takes the assignment ID and list of reviewers as input and returns matched topic assignments.&lt;br /&gt;
&lt;br /&gt;
====== Method: ensure_valid_topics (Private) ======&lt;br /&gt;
This method ensures that all reviewers have valid topic assignment entries, even if the algorithm returns nothing (e.g., due to web service failure). It initializes empty topic arrays for any missing reviewers.&lt;br /&gt;
&lt;br /&gt;
[[File:Controller_private_methods.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== ''Model'' ===&lt;br /&gt;
&lt;br /&gt;
The model includes 13 methods that manage the review bidding process. The public methods handle bidding data retrieval, review topic assignment, and fallback allocation. The private methods support these functions by fetching user and team data, sorting topics, and formatting bid details.&lt;br /&gt;
&lt;br /&gt;
====== Method: bidding_data ======&lt;br /&gt;
&lt;br /&gt;
Collects bidding data for an assignment, including topics, max allowed proposals, and individual reviewer bids.&lt;br /&gt;
&lt;br /&gt;
[[File:X1x1.png|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_review_topics ======&lt;br /&gt;
&lt;br /&gt;
Assigns reviewers to topics based on matched preferences and clears previous assignments.&lt;br /&gt;
&lt;br /&gt;
[[File:X2x.png|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_topic_to_reviewer ======&lt;br /&gt;
&lt;br /&gt;
Assigns a single topic to a reviewer by linking them to a team under that topic.&lt;br /&gt;
&lt;br /&gt;
[[File:X3x.png|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: reviewer_bidding_data ======&lt;br /&gt;
&lt;br /&gt;
Retrieves bid details for a specific reviewer, including self-selected topics and bid priorities.&lt;br /&gt;
&lt;br /&gt;
[[File:File4.png|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: fallback_algorithm ======&lt;br /&gt;
&lt;br /&gt;
Assigns topics to reviewers using a fallback approach when the initial bidding fails.&lt;br /&gt;
&lt;br /&gt;
[[File:X5x.png|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Private Methods ======&lt;br /&gt;
&lt;br /&gt;
* sorted_topic_queue – Sorts topics based on the number of team members and returns them in descending order&lt;br /&gt;
* assign_topics – Iterates through reviewers and assigns topics from the sorted queue, ensuring balanced distribution&lt;br /&gt;
* find_available_topic – Selects an available topic for a reviewer while avoiding self-selected topics&lt;br /&gt;
* reviewer_team_id – Retrieves the team ID associated with a given reviewer&lt;br /&gt;
* find_reviewer_user_id – Fetches the user ID for a given reviewer&lt;br /&gt;
* fetch_self_topic – Gets the topic that the user has self-selected for an assignment&lt;br /&gt;
* fetch_team_id – Finds the team ID for a given user in an assignment&lt;br /&gt;
* fetch_team_bids – Retrieves all bid records associated with a specific team&lt;br /&gt;
* format_bid – Converts a bid record into a structured format with topic ID, priority, and a formatted timestamp&lt;br /&gt;
&lt;br /&gt;
[[File:X6x.png|700px]]&lt;br /&gt;
&lt;br /&gt;
[[File:X7x.png|700px]]&lt;br /&gt;
&lt;br /&gt;
=== ''Service'' ===&lt;br /&gt;
&lt;br /&gt;
The ReviewBiddingAlgorithmService is a service object responsible for handling communication between the application and the external web service that executes the review bidding algorithm. It prepares bidding data, sends it to the web service, processes the response, and provides a fallback mechanism in case of failure.&lt;br /&gt;
&lt;br /&gt;
This service allows to encapsulate all logic required to interact with the external topic-matching web service. It separates the algorithm execution concerns from the controller, improving modularity, testability, and maintainability of the code.&lt;br /&gt;
&lt;br /&gt;
====== Method: self.process_bidding ======&lt;br /&gt;
&lt;br /&gt;
This is the primary entry point for the controller. It accepts the assignment_id and a list of reviewer_ids, then prepares the bidding data by calling ReviewBid.bidding_data(...). It passes the data to the web service by calling run_bidding_algorithm. If the web service is unavailable or fails, the method logs an error and falls back to an internal method: ReviewBid.fallback_algorithm. The result is returned as a hash mapping reviewer IDs to arrays of assigned topic IDs.&lt;br /&gt;
&lt;br /&gt;
====== Method: self.run_bidding_algorithm ======&lt;br /&gt;
&lt;br /&gt;
This method retrieves the review bidding web service URL from the app configuration (config/webservices.yml) and calls the internal send_bidding_request method to make the actual request.It logs the outgoing URL for debugging and delegates the response parsing.&lt;br /&gt;
&lt;br /&gt;
====== Private Method: send_bidding_request ======&lt;br /&gt;
&lt;br /&gt;
This private class method handles the HTTP POST request using RestClient. It sends the bidding data as JSON and expects a JSON response. If the request fails due to a connection error, server error, or timeout, the method logs the exception and returns false, allowing the caller to trigger a fallback.&lt;br /&gt;
&lt;br /&gt;
[[File:Review_bidding_algorithm_service.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Fallback Algorithm ===&lt;br /&gt;
=====   ''Introduction''   =====&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm in Expertiza is designed to ensure automatic topic assignment when the primary Bidding Algorithm fails due to Web Service unavailability.  &lt;br /&gt;
&lt;br /&gt;
Normally, Expertiza allows reviewers to bid on topics, and the ''ReviewBiddingAlgorithmService'' processes these bids to assign topics. However, when this web service ''fails'' (due to API downtime, server issues, or unexpected errors), the system must switch to fallback and automatically assign topics to reviewers.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Solution''   =====&lt;br /&gt;
It is triggered when the web service is unavailable. It ensures fair topic assignment by:  &lt;br /&gt;
* Prioritizing topics with the largest teams.  &lt;br /&gt;
* Using a round-robin approach to distribute topics among reviewers.  &lt;br /&gt;
* Ensuring reviewers do not get their own team’s topic.  &lt;br /&gt;
&lt;br /&gt;
=====   ''When is this Used?''  ===== &lt;br /&gt;
* The ReviewBiddingAlgorithmService fails due to an API issue.  &lt;br /&gt;
* The web service times out or returns an error.  &lt;br /&gt;
* Unexpected exceptions occur in the bidding process.  &lt;br /&gt;
&lt;br /&gt;
Instead of stopping the review process, the system automatically falls-back to an internal algorithm to distribute topics.  &lt;br /&gt;
&lt;br /&gt;
=====   ''How Does the Fallback Algorithm Work?''   ===== &lt;br /&gt;
The algorithm follows these **four main steps:  &lt;br /&gt;
* Fetch available topics – Retrieves all topics for the given assignment.  &lt;br /&gt;
* Sort topics by team size – Topics with more members are given priority.  &lt;br /&gt;
* Create a topic queue – Topics are arranged in descending order of team size.  &lt;br /&gt;
* Assign topics in a round-robin manner – Reviewers are assigned topics while avoiding their own team's topic.  &lt;br /&gt;
&lt;br /&gt;
This ensures ''fair and balanced'' distribution of topics.&lt;br /&gt;
  &lt;br /&gt;
=====   ''Implementation - Controller Code (Triggering the Fallback)''   =====&lt;br /&gt;
If the primary bidding service fails, the system catches the error and calls the Fallback Algorithm.&lt;br /&gt;
&lt;br /&gt;
[[File:X8x.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: If ''ReviewBiddingAlgorithmService'' fails, the system automatically calls fallback_algorithm.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Implementation - Model Code (Fallback Algorithm)''   =====&lt;br /&gt;
This method ensures fair topic assignment when the bidding system fails.&lt;br /&gt;
&lt;br /&gt;
[[File:X5x.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: This function ensures every reviewer receives a topic without requiring manual intervention.&lt;br /&gt;
&lt;br /&gt;
=====   ''RSpec Testing of Fallback Algorithm''   =====&lt;br /&gt;
To verify correctness, we use unit tests in ''review_bid_spec.rb''&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm ensures that ''topics are assigned fairly'' even when the primary bidding service fails. By prioritizing ''larger teams'', ''avoiding self-review'', and using a ''round-robin strategy'', the fallback mechanism keeps the review process smooth and automatic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
This section outlines the test plan for this project including testing scenarios/edge cases, the manual testing plan, and the automatic/RSpec testing plan.&lt;br /&gt;
&lt;br /&gt;
=== ''Testing Scenarios'' ===&lt;br /&gt;
This section outlines the various bidding scenarios that could occur. These scenarios should be tested in either '''Manual Testing''' or '''Automatic Testing'''.&lt;br /&gt;
&lt;br /&gt;
==== Basic Bidding Scenario ====&lt;br /&gt;
*Reviewers bid on multiple projects at different times&lt;br /&gt;
** Bidding algorithm should give priority to reviewers that bid first and should assign based on reviewers ranking&lt;br /&gt;
&lt;br /&gt;
====   Edge Cases   ====&lt;br /&gt;
* All reviewers bid on the same project&lt;br /&gt;
** If different time stamps: bidding algorithm should give priority to reviewers that bid first&lt;br /&gt;
** If same time stamps: bidding algorithm should assign reviews randomly&lt;br /&gt;
* None of the reviews bid on any projects&lt;br /&gt;
** Bidding algorithm should assign reviews randomly&lt;br /&gt;
* Reviewer bids on their own project&lt;br /&gt;
** Bidding algorithm should not allow a reviewer to bid on their own project and should have validation to prevent assigning a reviewer their own project&lt;br /&gt;
* None of the reviewers bid on a specific project&lt;br /&gt;
** Bidding algorithm should still assign reviewers to this project&lt;br /&gt;
&lt;br /&gt;
===   ''Manual Testing''   ===&lt;br /&gt;
Manual testing should be preformed on an Expertiza server and webserver platform &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Plan for Expertiza Server ====&lt;br /&gt;
* test that an instructor can allow review bidding for an assignment&lt;br /&gt;
* test that server routes correctly when review bidding is allowed&lt;br /&gt;
** test that task box links to bidding page before algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to bidding page before algorithm is run&lt;br /&gt;
** test that task box links to review page with bidding information after algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to review page with bidding information after algorithm is run&lt;br /&gt;
* test that the bidding UI is implemented as expected&lt;br /&gt;
* test that a participant can bid on projects to review&lt;br /&gt;
** test that a participant can move projects into the bidding column&lt;br /&gt;
** test that a participant can reorder projects in the bidding column&lt;br /&gt;
** test that a participant's bidding preferences save&lt;br /&gt;
** test that a participant can't bid for their own topic&lt;br /&gt;
* test that run algorithm button calls webserver with correct information and returns review assignments for each user&lt;br /&gt;
&lt;br /&gt;
==== Directions for Manual Testing of Expertiza Server ====&lt;br /&gt;
1. Go to [http://152.7.99.70:8081/ testing server] &amp;lt;br&amp;gt;&lt;br /&gt;
2. Log in as username: '''instructor6''' password: '''password''' &amp;lt;br&amp;gt;&lt;br /&gt;
3. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''General''' tab make sure '''Has teams?''' and '''Has topics?''' are checked&lt;br /&gt;
:# In the '''Topics''' tab check '''Allow review to choose which topic to review?''' then click '''save'''&lt;br /&gt;
:# In the '''Topics''' tab select '''Bidding''' then click '''save'''&lt;br /&gt;
4. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# This UI is based on '''instructor6''' being a '''participant''' assigned to topic '''Topic4'''&lt;br /&gt;
::# The UI blocks user from bidding on their own project &lt;br /&gt;
::# Check that user can bid on topics and reorder bids&lt;br /&gt;
::# Check that users topic preferences save on page refresh&lt;br /&gt;
::# Impersonate other participants and repeat bidding UI tests ('''student7601''', '''student7602''', '''student7603''', '''student7604''', '''student7605''', '''student7606''', '''student7607''', '''student7608''', '''student7609'')&lt;br /&gt;
5. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''Topics''' tab click '''Run Review Algorithm''' button&lt;br /&gt;
6. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# '''E2085 Manual Testing review''' should now link to the reviewing page&lt;br /&gt;
::# The number of required reviews should already be displayed&lt;br /&gt;
::# A '''Request Another Review''' button should be present unless reviews listed is equal to the number of reviews allowed&lt;br /&gt;
::# '''Begin''' a review and test '''save''' and '''submit'''&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Demo Video for Expertiza Server ====&lt;br /&gt;
Video demonstration of manual testing: [https://www.screencast.com/t/0rSg1zDW here]&lt;br /&gt;
&lt;br /&gt;
=== ''Automatic/PyTest Testing '' ===&lt;br /&gt;
Pytest tests are written for the webservice to test a well formed and a malformed request.&lt;br /&gt;
&lt;br /&gt;
===   ''Automatic/RSpec Testing ''   ===&lt;br /&gt;
RSpec tests will need to be refactored according to the changes that we make in the expertiza repository. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== RSpec Testing Plan ====&lt;br /&gt;
These RSpec tests will need to:&lt;br /&gt;
* test basic functionality of review bids controller&lt;br /&gt;
* test basic functionality of review bid model&lt;br /&gt;
&lt;br /&gt;
==== Directions for RSpec Testing ====&lt;br /&gt;
:# on personal device using [https://github.com/ncsu-ngw/expertiza forked repo]&lt;br /&gt;
:# Run the following commands:&lt;br /&gt;
&lt;br /&gt;
 # review bids controller: &lt;br /&gt;
 bundle exec rspec spec/controllers/review_bids_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
 # review bid model: &lt;br /&gt;
 bundle exec rspec spec/models/review_bid_spec.rb&lt;br /&gt;
 &lt;br /&gt;
 # review bidding algorithm service:&lt;br /&gt;
 bundle exec rspec spec/services/review_bidding_algorithm_service_spec.rb&lt;br /&gt;
&lt;br /&gt;
==Test Coverage==&lt;br /&gt;
Code Climate: [https://codeclimate.com/github/expertiza/expertiza/pull/2931 here]&lt;br /&gt;
&lt;br /&gt;
[[File:code-climate.png|700px]]&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
&lt;br /&gt;
'''Mentor:''' Janice Uwujaren (juwujar) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ashwin Muniswamy (akumarm) &amp;lt;br&amp;gt;&lt;br /&gt;
Arturo Serdan (aaserdan) &amp;lt;br&amp;gt;&lt;br /&gt;
Nicholas Winsen (nwinsen) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====''Previous Implementations''=====&lt;br /&gt;
Fall 2019 [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Spring 2020 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2020 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2024 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2508._Reimplement_bidding-algorithm_web_service here]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====''Relevant Links''=====&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/2931 &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
''Video Demo'': https://app.screencast.com/vaiJnWpHf0r07&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:X8x.png&amp;diff=162720</id>
		<title>File:X8x.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:X8x.png&amp;diff=162720"/>
		<updated>2025-03-25T02:53:29Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162688</id>
		<title>CSC/ECE 517 Spring 2025 - E2508. Reimplement bidding-algorithm web service</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162688"/>
		<updated>2025-03-25T02:32:45Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Project Overview==&lt;br /&gt;
===   ''Background''   ===&lt;br /&gt;
The previous implementation of the bidding service was hosted on peerlogic by a former student. The University no longer has access to this hosting service, and  is requiring a new solution. It is also asked that the webservice accept a better and cleaner json format which is easier to interpret and read.&lt;br /&gt;
&lt;br /&gt;
===   ''Objectives''   ===&lt;br /&gt;
# Reimplement trading cycles on a webservice&lt;br /&gt;
# Figure out a new hosting solution for the BiddingService web service. (VCL)&lt;br /&gt;
# Host the webservice on VCL&lt;br /&gt;
# Using tmux, figure out a way to keep the process running with a production wsgi service compatible with Flask.&lt;br /&gt;
# Create new tests for the repository&lt;br /&gt;
# Create a list of required packages that future maintainers can install easily&lt;br /&gt;
# Create a tests directory that users can test the functionality of the code with&lt;br /&gt;
# Modularize the code further, eliminate code smells.&lt;br /&gt;
# Refactor existing backend logic to account for the new json format&lt;br /&gt;
# Refactor existing backend code to send HTTP requests to the correct IP address&lt;br /&gt;
# Refactor existing frontend code to provide a list for users to select multiple topics on the frontend&lt;br /&gt;
# Allow users to prioritize their topic selection on the frontend&lt;br /&gt;
# Users should not be allowed to bid on their review topics on the frontend&lt;br /&gt;
# Display the results of the matched topics on the frontend&lt;br /&gt;
&lt;br /&gt;
===   ''Previous Work''   ===&lt;br /&gt;
There have been three previous implementations: &amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2019 [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Spring 2020 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2020 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2024 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2508._Reimplement_bidding-algorithm_web_service here]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/2931 &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Files Modified''   ===&lt;br /&gt;
This is a list of all the files added or changed in completing this project. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Changed'': &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/app.py - accomodated for changes in JsonParser&lt;br /&gt;
*app/json_parser.py - moved functions out due to SRP&lt;br /&gt;
*app/topics_matcher.py&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Added'': &amp;lt;br&amp;gt;&lt;br /&gt;
*app/tests/sample.json &amp;lt;br&amp;gt; - Sample input for the tests.&lt;br /&gt;
&lt;br /&gt;
*app/tests/test_assignment.py &amp;lt;br&amp;gt; Test File to test forms of input - tests both a successful and unsuccessful input&lt;br /&gt;
&lt;br /&gt;
*app/utils/popular_topics.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/student_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/topic_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
&lt;br /&gt;
*setup.py - required for wsgi&lt;br /&gt;
*wsgi.py - for hosting the server via gunicorn on VCL.&lt;br /&gt;
*.gitignore - to ignore anything that we may not want pushed (mostly for venv)&lt;br /&gt;
*requirements.txt - a list of requirements made easy for future maintainers&lt;br /&gt;
&lt;br /&gt;
=== ''Webservice'' ===&lt;br /&gt;
===== ''app'' =====&lt;br /&gt;
&lt;br /&gt;
The entry point to the Web service is the app.py file where we have the POST Method match_topics.&lt;br /&gt;
This receives the input in a json format from Expertiza. The input will contain a list of task ids, and then an Object of users, which each contain their student id and correlated bids that they made. Each bid contains a task id, a priority, and a timestamp. The input format was reworked to align to this style since it made more sense to have each student have a list of bids instead of the previous implementation which did not have this case. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:App2508.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''json parser'' =====&lt;br /&gt;
The json parser converts the json into a Dictionary. The previous implementation also had the parser create a preferences dictionary for the Student to store their topic preferences and one for Topics to store list of topics which have been selected by students and also the priority for the selection using the Timestamps. However, this was removed due to the Single Responsibility Principle. We felt the json parser was doing too much and should only be parsing the json!&lt;br /&gt;
&lt;br /&gt;
[[File:init_parser.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The student priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:student_prio.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The topic priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:topic_priorities.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== ''Test Input'' =====&lt;br /&gt;
&lt;br /&gt;
Sample Test case:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Case:&amp;lt;/b&amp;gt; There are a few very popular topics and the students who bid for them and bid early should receive it.&lt;br /&gt;
Popular Topics: 3969, 3971, 3972&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;tid&amp;quot;: [4427, 4428, 4429, 4430],&lt;br /&gt;
    &amp;quot;users&amp;quot;: {&lt;br /&gt;
      &amp;quot;40763&amp;quot;: {&lt;br /&gt;
          &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4429&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40764&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4427&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40765&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:15 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:16 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:17 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4428&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;max_accepted_proposals&amp;quot;: 3&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''Output'' =====&lt;br /&gt;
&lt;br /&gt;
 Since there is competition for these topics, the algorithm recognizes this and makes sure to assign them only to the students who bid for it.&lt;br /&gt;
		Other students who picked other topics or did not pick anything are assigned different topics.&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
    &amp;quot;40763&amp;quot;: [&lt;br /&gt;
        4427,&lt;br /&gt;
        4428,&lt;br /&gt;
        4430&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40764&amp;quot;: [&lt;br /&gt;
        4428,&lt;br /&gt;
        4430,&lt;br /&gt;
        4429&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40765&amp;quot;: [&lt;br /&gt;
        4429,&lt;br /&gt;
        4427,&lt;br /&gt;
        4430&lt;br /&gt;
    ]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== ''Controller'' ===&lt;br /&gt;
&lt;br /&gt;
The controller includes 8 methods that handle the review bidding process. The public methods cover authorization, rendering views, saving user bids, and coordinating review assignment. The private methods support these functions by abstracting data gathering and algorithm coordination logic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Method: action_allowed? ======&lt;br /&gt;
&lt;br /&gt;
This method controls user access to controller actions. It allows 'Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator', and 'Student' roles to access show, set_priority, and index. Other actions are restricted to non-student roles. It ensures proper permissions for accessing review bidding features.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: index ======&lt;br /&gt;
&lt;br /&gt;
This method gathers information for the &amp;quot;Your Work&amp;quot; page, where users can view their assigned reviews. It checks user identity, retrieves associated reviews, and counts completed reviews. The view rendered is sign_up_sheet/review_bids_others_work.View: others_work.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_index.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: show ======&lt;br /&gt;
&lt;br /&gt;
This method renders the bidding page where users select topics they'd prefer to review. It fetches the assignment, available topics, and any existing bids. Already assigned or signed-up topics are excluded. The page also lists any assigned reviews.View: show.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_show.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: set_priority ======&lt;br /&gt;
&lt;br /&gt;
This method stores or updates a participant's topic preferences. It removes old bids not in the current selection and creates or updates the remaining bids with new priorities. This method is triggered when users submit their topic rankings on the bidding page.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_set_priority.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_bidding ======&lt;br /&gt;
&lt;br /&gt;
This method coordinates the assignment of review topics. It gathers reviewer IDs and invokes the bidding algorithm using a service. It validates the output and uses ReviewBid.assign_review_topics to perform the actual assignment. Bidding is then disabled.&lt;br /&gt;
&lt;br /&gt;
[[File:Assign_bidding.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: fetch_reviewer_ids (Private) ======&lt;br /&gt;
&lt;br /&gt;
This helper method retrieves all AssignmentParticipant IDs for a given assignment. These IDs represent the reviewers participating in the bidding process.&lt;br /&gt;
&lt;br /&gt;
====== Method: process_bidding (Private) ======&lt;br /&gt;
This helper method delegates the logic for running the bidding algorithm to the service class ReviewBiddingAlgorithmService. It takes the assignment ID and list of reviewers as input and returns matched topic assignments.&lt;br /&gt;
&lt;br /&gt;
====== Method: ensure_valid_topics (Private) ======&lt;br /&gt;
This method ensures that all reviewers have valid topic assignment entries, even if the algorithm returns nothing (e.g., due to web service failure). It initializes empty topic arrays for any missing reviewers.&lt;br /&gt;
&lt;br /&gt;
[[File:Controller_private_methods.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== ''Model'' ===&lt;br /&gt;
&lt;br /&gt;
The model includes 13 methods that manage the review bidding process. The public methods handle bidding data retrieval, review topic assignment, and fallback allocation. The private methods support these functions by fetching user and team data, sorting topics, and formatting bid details.&lt;br /&gt;
&lt;br /&gt;
====== Method: bidding_data ======&lt;br /&gt;
&lt;br /&gt;
Collects bidding data for an assignment, including topics, max allowed proposals, and individual reviewer bids.&lt;br /&gt;
&lt;br /&gt;
[[File:X1x1.png|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_review_topics ======&lt;br /&gt;
&lt;br /&gt;
Assigns reviewers to topics based on matched preferences and clears previous assignments.&lt;br /&gt;
&lt;br /&gt;
[[File:X2x.png|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_topic_to_reviewer ======&lt;br /&gt;
&lt;br /&gt;
Assigns a single topic to a reviewer by linking them to a team under that topic.&lt;br /&gt;
&lt;br /&gt;
[[File:X3x.png|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: reviewer_bidding_data ======&lt;br /&gt;
&lt;br /&gt;
Retrieves bid details for a specific reviewer, including self-selected topics and bid priorities.&lt;br /&gt;
&lt;br /&gt;
[[File:File4.png|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: fallback_algorithm ======&lt;br /&gt;
&lt;br /&gt;
Assigns topics to reviewers using a fallback approach when the initial bidding fails.&lt;br /&gt;
&lt;br /&gt;
[[File:X5x.png|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Private Methods ======&lt;br /&gt;
&lt;br /&gt;
* sorted_topic_queue – Sorts topics based on the number of team members and returns them in descending order&lt;br /&gt;
* assign_topics – Iterates through reviewers and assigns topics from the sorted queue, ensuring balanced distribution&lt;br /&gt;
* find_available_topic – Selects an available topic for a reviewer while avoiding self-selected topics&lt;br /&gt;
* reviewer_team_id – Retrieves the team ID associated with a given reviewer&lt;br /&gt;
* find_reviewer_user_id – Fetches the user ID for a given reviewer&lt;br /&gt;
* fetch_self_topic – Gets the topic that the user has self-selected for an assignment&lt;br /&gt;
* fetch_team_id – Finds the team ID for a given user in an assignment&lt;br /&gt;
* fetch_team_bids – Retrieves all bid records associated with a specific team&lt;br /&gt;
* format_bid – Converts a bid record into a structured format with topic ID, priority, and a formatted timestamp&lt;br /&gt;
&lt;br /&gt;
[[File:X6x.png|700px]]&lt;br /&gt;
&lt;br /&gt;
[[File:X7x.png|700px]]&lt;br /&gt;
&lt;br /&gt;
=== ''Service'' ===&lt;br /&gt;
&lt;br /&gt;
The ReviewBiddingAlgorithmService is a service object responsible for handling communication between the application and the external web service that executes the review bidding algorithm. It prepares bidding data, sends it to the web service, processes the response, and provides a fallback mechanism in case of failure.&lt;br /&gt;
&lt;br /&gt;
This service allows to encapsulate all logic required to interact with the external topic-matching web service. It separates the algorithm execution concerns from the controller, improving modularity, testability, and maintainability of the code.&lt;br /&gt;
&lt;br /&gt;
====== Method: self.process_bidding ======&lt;br /&gt;
&lt;br /&gt;
This is the primary entry point for the controller. It accepts the assignment_id and a list of reviewer_ids, then prepares the bidding data by calling ReviewBid.bidding_data(...). It passes the data to the web service by calling run_bidding_algorithm. If the web service is unavailable or fails, the method logs an error and falls back to an internal method: ReviewBid.fallback_algorithm. The result is returned as a hash mapping reviewer IDs to arrays of assigned topic IDs.&lt;br /&gt;
&lt;br /&gt;
====== Method: self.run_bidding_algorithm ======&lt;br /&gt;
&lt;br /&gt;
This method retrieves the review bidding web service URL from the app configuration (config/webservices.yml) and calls the internal send_bidding_request method to make the actual request.It logs the outgoing URL for debugging and delegates the response parsing.&lt;br /&gt;
&lt;br /&gt;
====== Private Method: send_bidding_request ======&lt;br /&gt;
&lt;br /&gt;
This private class method handles the HTTP POST request using RestClient. It sends the bidding data as JSON and expects a JSON response. If the request fails due to a connection error, server error, or timeout, the method logs the exception and returns false, allowing the caller to trigger a fallback.&lt;br /&gt;
&lt;br /&gt;
[[File:Review_bidding_algorithm_service.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Fallback Algorithm ===&lt;br /&gt;
=====   ''Introduction''   =====&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm in Expertiza is designed to ensure automatic topic assignment when the primary Bidding Algorithm fails due to Web Service unavailability.  &lt;br /&gt;
&lt;br /&gt;
Normally, Expertiza allows reviewers to bid on topics, and the ''ReviewBiddingAlgorithmService'' processes these bids to assign topics. However, when this web service ''fails'' (due to API downtime, server issues, or unexpected errors), the system must switch to fallback and automatically assign topics to reviewers.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Solution''   =====&lt;br /&gt;
It is triggered when the web service is unavailable. It ensures fair topic assignment by:  &lt;br /&gt;
* Prioritizing topics with the largest teams.  &lt;br /&gt;
* Using a round-robin approach to distribute topics among reviewers.  &lt;br /&gt;
* Ensuring reviewers do not get their own team’s topic.  &lt;br /&gt;
&lt;br /&gt;
=====   ''When is this Used?''  ===== &lt;br /&gt;
* The ReviewBiddingAlgorithmService fails due to an API issue.  &lt;br /&gt;
* The web service times out or returns an error.  &lt;br /&gt;
* Unexpected exceptions occur in the bidding process.  &lt;br /&gt;
&lt;br /&gt;
Instead of stopping the review process, the system automatically falls-back to an internal algorithm to distribute topics.  &lt;br /&gt;
&lt;br /&gt;
=====   ''How Does the Fallback Algorithm Work?''   ===== &lt;br /&gt;
The algorithm follows these **four main steps:  &lt;br /&gt;
* Fetch available topics – Retrieves all topics for the given assignment.  &lt;br /&gt;
* Sort topics by team size – Topics with more members are given priority.  &lt;br /&gt;
* Create a topic queue – Topics are arranged in descending order of team size.  &lt;br /&gt;
* Assign topics in a round-robin manner – Reviewers are assigned topics while avoiding their own team's topic.  &lt;br /&gt;
&lt;br /&gt;
This ensures ''fair and balanced'' distribution of topics.&lt;br /&gt;
  &lt;br /&gt;
=====   ''Implementation - Controller Code (Triggering the Fallback)''   =====&lt;br /&gt;
If the primary bidding service fails, the system catches the error and calls the Fallback Algorithm.&lt;br /&gt;
&lt;br /&gt;
[[File:X5x.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: If ''ReviewBiddingAlgorithmService'' fails, the system automatically calls fallback_algorithm.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Implementation - Model Code (Fallback Algorithm)''   =====&lt;br /&gt;
This method ensures fair topic assignment when the bidding system fails.&lt;br /&gt;
&lt;br /&gt;
[[File:X5x.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: This function ensures every reviewer receives a topic without requiring manual intervention.&lt;br /&gt;
&lt;br /&gt;
=====   ''RSpec Testing of Fallback Algorithm''   =====&lt;br /&gt;
To verify correctness, we use unit tests in ''review_bid_spec.rb''&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm ensures that ''topics are assigned fairly'' even when the primary bidding service fails. By prioritizing ''larger teams'', ''avoiding self-review'', and using a ''round-robin strategy'', the fallback mechanism keeps the review process smooth and automatic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
This section outlines the test plan for this project including testing scenarios/edge cases, the manual testing plan, and the automatic/RSpec testing plan.&lt;br /&gt;
&lt;br /&gt;
=== ''Testing Scenarios'' ===&lt;br /&gt;
This section outlines the various bidding scenarios that could occur. These scenarios should be tested in either '''Manual Testing''' or '''Automatic Testing'''.&lt;br /&gt;
&lt;br /&gt;
==== Basic Bidding Scenario ====&lt;br /&gt;
*Reviewers bid on multiple projects at different times&lt;br /&gt;
** Bidding algorithm should give priority to reviewers that bid first and should assign based on reviewers ranking&lt;br /&gt;
&lt;br /&gt;
====   Edge Cases   ====&lt;br /&gt;
* All reviewers bid on the same project&lt;br /&gt;
** If different time stamps: bidding algorithm should give priority to reviewers that bid first&lt;br /&gt;
** If same time stamps: bidding algorithm should assign reviews randomly&lt;br /&gt;
* None of the reviews bid on any projects&lt;br /&gt;
** Bidding algorithm should assign reviews randomly&lt;br /&gt;
* Reviewer bids on their own project&lt;br /&gt;
** Bidding algorithm should not allow a reviewer to bid on their own project and should have validation to prevent assigning a reviewer their own project&lt;br /&gt;
* None of the reviewers bid on a specific project&lt;br /&gt;
** Bidding algorithm should still assign reviewers to this project&lt;br /&gt;
&lt;br /&gt;
===   ''Manual Testing''   ===&lt;br /&gt;
Manual testing should be preformed on an Expertiza server and webserver platform &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Plan for Expertiza Server ====&lt;br /&gt;
* test that an instructor can allow review bidding for an assignment&lt;br /&gt;
* test that server routes correctly when review bidding is allowed&lt;br /&gt;
** test that task box links to bidding page before algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to bidding page before algorithm is run&lt;br /&gt;
** test that task box links to review page with bidding information after algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to review page with bidding information after algorithm is run&lt;br /&gt;
* test that the bidding UI is implemented as expected&lt;br /&gt;
* test that a participant can bid on projects to review&lt;br /&gt;
** test that a participant can move projects into the bidding column&lt;br /&gt;
** test that a participant can reorder projects in the bidding column&lt;br /&gt;
** test that a participant's bidding preferences save&lt;br /&gt;
** test that a participant can't bid for their own topic&lt;br /&gt;
* test that run algorithm button calls webserver with correct information and returns review assignments for each user&lt;br /&gt;
&lt;br /&gt;
==== Directions for Manual Testing of Expertiza Server ====&lt;br /&gt;
1. Go to [http://152.7.99.70:8081/ testing server] &amp;lt;br&amp;gt;&lt;br /&gt;
2. Log in as username: '''instructor6''' password: '''password''' &amp;lt;br&amp;gt;&lt;br /&gt;
3. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''General''' tab make sure '''Has teams?''' and '''Has topics?''' are checked&lt;br /&gt;
:# In the '''Topics''' tab check '''Allow review to choose which topic to review?''' then click '''save'''&lt;br /&gt;
:# In the '''Topics''' tab select '''Bidding''' then click '''save'''&lt;br /&gt;
4. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# This UI is based on '''instructor6''' being a '''participant''' assigned to topic '''Topic4'''&lt;br /&gt;
::# The UI blocks user from bidding on their own project &lt;br /&gt;
::# Check that user can bid on topics and reorder bids&lt;br /&gt;
::# Check that users topic preferences save on page refresh&lt;br /&gt;
::# Impersonate other participants and repeat bidding UI tests ('''student7601''', '''student7602''', '''student7603''', '''student7604''', '''student7605''', '''student7606''', '''student7607''', '''student7608''', '''student7609'')&lt;br /&gt;
5. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''Topics''' tab click '''Run Review Algorithm''' button&lt;br /&gt;
6. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# '''E2085 Manual Testing review''' should now link to the reviewing page&lt;br /&gt;
::# The number of required reviews should already be displayed&lt;br /&gt;
::# A '''Request Another Review''' button should be present unless reviews listed is equal to the number of reviews allowed&lt;br /&gt;
::# '''Begin''' a review and test '''save''' and '''submit'''&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Demo Video for Expertiza Server ====&lt;br /&gt;
Video demonstration of manual testing: [https://www.screencast.com/t/0rSg1zDW here]&lt;br /&gt;
&lt;br /&gt;
=== ''Automatic/PyTest Testing '' ===&lt;br /&gt;
Pytest tests are written for the webservice to test a well formed and a malformed request.&lt;br /&gt;
&lt;br /&gt;
===   ''Automatic/RSpec Testing ''   ===&lt;br /&gt;
RSpec tests will need to be refactored according to the changes that we make in the expertiza repository. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== RSpec Testing Plan ====&lt;br /&gt;
These RSpec tests will need to:&lt;br /&gt;
* test basic functionality of review bids controller&lt;br /&gt;
* test basic functionality of review bid model&lt;br /&gt;
&lt;br /&gt;
==== Directions for RSpec Testing ====&lt;br /&gt;
:# on personal device using [https://github.com/ncsu-ngw/expertiza forked repo]&lt;br /&gt;
:# Run the following commands:&lt;br /&gt;
&lt;br /&gt;
 # review bids controller: &lt;br /&gt;
 bundle exec rspec spec/controllers/review_bids_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
 # review bid model: &lt;br /&gt;
 bundle exec rspec spec/models/review_bid_spec.rb&lt;br /&gt;
 &lt;br /&gt;
 # review bidding algorithm service:&lt;br /&gt;
 bundle exec rspec spec/services/review_bidding_algorithm_service_spec.rb&lt;br /&gt;
&lt;br /&gt;
==Test Coverage==&lt;br /&gt;
Code Climate: [https://codeclimate.com/github/expertiza/expertiza/pull/2931 here]&lt;br /&gt;
&lt;br /&gt;
[[File:code-climate.png|700px]]&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
&lt;br /&gt;
'''Mentor:''' Janice Uwujaren (juwujar) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ashwin Muniswamy (akumarm) &amp;lt;br&amp;gt;&lt;br /&gt;
Arturo Serdan (aaserdan) &amp;lt;br&amp;gt;&lt;br /&gt;
Nicholas Winsen (nwinsen) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====''Previous Implementations''=====&lt;br /&gt;
Fall 2019 [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Spring 2020 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2020 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2024 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2508._Reimplement_bidding-algorithm_web_service here]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====''Relevant Links''=====&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/2931 &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
''Video Demo'': https://app.screencast.com/vaiJnWpHf0r07&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:X7x.png&amp;diff=162685</id>
		<title>File:X7x.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:X7x.png&amp;diff=162685"/>
		<updated>2025-03-25T02:31:05Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:X6x.png&amp;diff=162684</id>
		<title>File:X6x.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:X6x.png&amp;diff=162684"/>
		<updated>2025-03-25T02:30:51Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:X5x.png&amp;diff=162682</id>
		<title>File:X5x.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:X5x.png&amp;diff=162682"/>
		<updated>2025-03-25T02:30:12Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:X3x.png&amp;diff=162681</id>
		<title>File:X3x.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:X3x.png&amp;diff=162681"/>
		<updated>2025-03-25T02:29:32Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:X2x.png&amp;diff=162680</id>
		<title>File:X2x.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:X2x.png&amp;diff=162680"/>
		<updated>2025-03-25T02:28:47Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:X1x1.png&amp;diff=162668</id>
		<title>File:X1x1.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:X1x1.png&amp;diff=162668"/>
		<updated>2025-03-25T02:26:06Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:File7.png&amp;diff=162659</id>
		<title>File:File7.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:File7.png&amp;diff=162659"/>
		<updated>2025-03-25T02:19:20Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: Akumarm uploaded a new version of File:File7.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:File6.png&amp;diff=162658</id>
		<title>File:File6.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:File6.png&amp;diff=162658"/>
		<updated>2025-03-25T02:19:09Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: Akumarm uploaded a new version of File:File6.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:File5.png&amp;diff=162657</id>
		<title>File:File5.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:File5.png&amp;diff=162657"/>
		<updated>2025-03-25T02:18:58Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: Akumarm uploaded a new version of File:File5.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:File4.png&amp;diff=162656</id>
		<title>File:File4.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:File4.png&amp;diff=162656"/>
		<updated>2025-03-25T02:18:47Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:3.png&amp;diff=162655</id>
		<title>File:3.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:3.png&amp;diff=162655"/>
		<updated>2025-03-25T02:18:22Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: Akumarm uploaded a new version of File:3.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;IS-A and HAS-A Rules of Inheritance&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:File2.png&amp;diff=162654</id>
		<title>File:File2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:File2.png&amp;diff=162654"/>
		<updated>2025-03-25T02:18:11Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: Akumarm uploaded a new version of File:File2.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:File1.png&amp;diff=162652</id>
		<title>File:File1.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:File1.png&amp;diff=162652"/>
		<updated>2025-03-25T02:17:50Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: Akumarm uploaded a new version of File:File1.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162651</id>
		<title>CSC/ECE 517 Spring 2025 - E2508. Reimplement bidding-algorithm web service</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162651"/>
		<updated>2025-03-25T02:15:24Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Project Overview==&lt;br /&gt;
===   ''Background''   ===&lt;br /&gt;
The previous implementation of the bidding service was hosted on peerlogic by a former student. The University no longer has access to this hosting service, and  is requiring a new solution. It is also asked that the webservice accept a better and cleaner json format which is easier to interpret and read.&lt;br /&gt;
&lt;br /&gt;
===   ''Objectives''   ===&lt;br /&gt;
# Reimplement trading cycles on a webservice&lt;br /&gt;
# Figure out a new hosting solution for the BiddingService web service. (VCL)&lt;br /&gt;
# Host the webservice on VCL&lt;br /&gt;
# Using tmux, figure out a way to keep the process running with a production wsgi service compatible with Flask.&lt;br /&gt;
# Create new tests for the repository&lt;br /&gt;
# Create a list of required packages that future maintainers can install easily&lt;br /&gt;
# Create a tests directory that users can test the functionality of the code with&lt;br /&gt;
# Modularize the code further, eliminate code smells.&lt;br /&gt;
# Refactor existing backend logic to account for the new json format&lt;br /&gt;
# Refactor existing backend code to send HTTP requests to the correct IP address&lt;br /&gt;
# Refactor existing frontend code to provide a list for users to select multiple topics on the frontend&lt;br /&gt;
# Allow users to prioritize their topic selection on the frontend&lt;br /&gt;
# Users should not be allowed to bid on their review topics on the frontend&lt;br /&gt;
# Display the results of the matched topics on the frontend&lt;br /&gt;
&lt;br /&gt;
===   ''Previous Work''   ===&lt;br /&gt;
There have been three previous implementations: &amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2019 [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Spring 2020 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2020 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2024 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2508._Reimplement_bidding-algorithm_web_service here]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/2931 &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Files Modified''   ===&lt;br /&gt;
This is a list of all the files added or changed in completing this project. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Changed'': &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/app.py - accomodated for changes in JsonParser&lt;br /&gt;
*app/json_parser.py - moved functions out due to SRP&lt;br /&gt;
*app/topics_matcher.py&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Added'': &amp;lt;br&amp;gt;&lt;br /&gt;
*app/tests/sample.json &amp;lt;br&amp;gt; - Sample input for the tests.&lt;br /&gt;
&lt;br /&gt;
*app/tests/test_assignment.py &amp;lt;br&amp;gt; Test File to test forms of input - tests both a successful and unsuccessful input&lt;br /&gt;
&lt;br /&gt;
*app/utils/popular_topics.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/student_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/topic_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
&lt;br /&gt;
*setup.py - required for wsgi&lt;br /&gt;
*wsgi.py - for hosting the server via gunicorn on VCL.&lt;br /&gt;
*.gitignore - to ignore anything that we may not want pushed (mostly for venv)&lt;br /&gt;
*requirements.txt - a list of requirements made easy for future maintainers&lt;br /&gt;
&lt;br /&gt;
=== ''Webservice'' ===&lt;br /&gt;
===== ''app'' =====&lt;br /&gt;
&lt;br /&gt;
The entry point to the Web service is the app.py file where we have the POST Method match_topics.&lt;br /&gt;
This receives the input in a json format from Expertiza. The input will contain a list of task ids, and then an Object of users, which each contain their student id and correlated bids that they made. Each bid contains a task id, a priority, and a timestamp. The input format was reworked to align to this style since it made more sense to have each student have a list of bids instead of the previous implementation which did not have this case. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:App2508.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''json parser'' =====&lt;br /&gt;
The json parser converts the json into a Dictionary. The previous implementation also had the parser create a preferences dictionary for the Student to store their topic preferences and one for Topics to store list of topics which have been selected by students and also the priority for the selection using the Timestamps. However, this was removed due to the Single Responsibility Principle. We felt the json parser was doing too much and should only be parsing the json!&lt;br /&gt;
&lt;br /&gt;
[[File:init_parser.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The student priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:student_prio.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The topic priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:topic_priorities.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== ''Test Input'' =====&lt;br /&gt;
&lt;br /&gt;
Sample Test case:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Case:&amp;lt;/b&amp;gt; There are a few very popular topics and the students who bid for them and bid early should receive it.&lt;br /&gt;
Popular Topics: 3969, 3971, 3972&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;tid&amp;quot;: [4427, 4428, 4429, 4430],&lt;br /&gt;
    &amp;quot;users&amp;quot;: {&lt;br /&gt;
      &amp;quot;40763&amp;quot;: {&lt;br /&gt;
          &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4429&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40764&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4427&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40765&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:15 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:16 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:17 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4428&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;max_accepted_proposals&amp;quot;: 3&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''Output'' =====&lt;br /&gt;
&lt;br /&gt;
 Since there is competition for these topics, the algorithm recognizes this and makes sure to assign them only to the students who bid for it.&lt;br /&gt;
		Other students who picked other topics or did not pick anything are assigned different topics.&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
    &amp;quot;40763&amp;quot;: [&lt;br /&gt;
        4427,&lt;br /&gt;
        4428,&lt;br /&gt;
        4430&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40764&amp;quot;: [&lt;br /&gt;
        4428,&lt;br /&gt;
        4430,&lt;br /&gt;
        4429&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40765&amp;quot;: [&lt;br /&gt;
        4429,&lt;br /&gt;
        4427,&lt;br /&gt;
        4430&lt;br /&gt;
    ]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== ''Controller'' ===&lt;br /&gt;
&lt;br /&gt;
The controller includes 8 methods that handle the review bidding process. The public methods cover authorization, rendering views, saving user bids, and coordinating review assignment. The private methods support these functions by abstracting data gathering and algorithm coordination logic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Method: action_allowed? ======&lt;br /&gt;
&lt;br /&gt;
This method controls user access to controller actions. It allows 'Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator', and 'Student' roles to access show, set_priority, and index. Other actions are restricted to non-student roles. It ensures proper permissions for accessing review bidding features.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: index ======&lt;br /&gt;
&lt;br /&gt;
This method gathers information for the &amp;quot;Your Work&amp;quot; page, where users can view their assigned reviews. It checks user identity, retrieves associated reviews, and counts completed reviews. The view rendered is sign_up_sheet/review_bids_others_work.View: others_work.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_index.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: show ======&lt;br /&gt;
&lt;br /&gt;
This method renders the bidding page where users select topics they'd prefer to review. It fetches the assignment, available topics, and any existing bids. Already assigned or signed-up topics are excluded. The page also lists any assigned reviews.View: show.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_show.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: set_priority ======&lt;br /&gt;
&lt;br /&gt;
This method stores or updates a participant's topic preferences. It removes old bids not in the current selection and creates or updates the remaining bids with new priorities. This method is triggered when users submit their topic rankings on the bidding page.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_set_priority.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_bidding ======&lt;br /&gt;
&lt;br /&gt;
This method coordinates the assignment of review topics. It gathers reviewer IDs and invokes the bidding algorithm using a service. It validates the output and uses ReviewBid.assign_review_topics to perform the actual assignment. Bidding is then disabled.&lt;br /&gt;
&lt;br /&gt;
[[File:Assign_bidding.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: fetch_reviewer_ids (Private) ======&lt;br /&gt;
&lt;br /&gt;
This helper method retrieves all AssignmentParticipant IDs for a given assignment. These IDs represent the reviewers participating in the bidding process.&lt;br /&gt;
&lt;br /&gt;
====== Method: process_bidding (Private) ======&lt;br /&gt;
This helper method delegates the logic for running the bidding algorithm to the service class ReviewBiddingAlgorithmService. It takes the assignment ID and list of reviewers as input and returns matched topic assignments.&lt;br /&gt;
&lt;br /&gt;
====== Method: ensure_valid_topics (Private) ======&lt;br /&gt;
This method ensures that all reviewers have valid topic assignment entries, even if the algorithm returns nothing (e.g., due to web service failure). It initializes empty topic arrays for any missing reviewers.&lt;br /&gt;
&lt;br /&gt;
[[File:Controller_private_methods.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== ''Model'' ===&lt;br /&gt;
&lt;br /&gt;
The model includes 13 methods that manage the review bidding process. The public methods handle bidding data retrieval, review topic assignment, and fallback allocation. The private methods support these functions by fetching user and team data, sorting topics, and formatting bid details.&lt;br /&gt;
&lt;br /&gt;
====== Method: bidding_data ======&lt;br /&gt;
&lt;br /&gt;
Collects bidding data for an assignment, including topics, max allowed proposals, and individual reviewer bids.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_review_topics ======&lt;br /&gt;
&lt;br /&gt;
Assigns reviewers to topics based on matched preferences and clears previous assignments.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_topic_to_reviewer ======&lt;br /&gt;
&lt;br /&gt;
Assigns a single topic to a reviewer by linking them to a team under that topic.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: reviewer_bidding_data ======&lt;br /&gt;
&lt;br /&gt;
Retrieves bid details for a specific reviewer, including self-selected topics and bid priorities.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: fallback_algorithm ======&lt;br /&gt;
&lt;br /&gt;
Assigns topics to reviewers using a fallback approach when the initial bidding fails.&lt;br /&gt;
&lt;br /&gt;
====== Private Methods ======&lt;br /&gt;
&lt;br /&gt;
* sorted_topic_queue – Sorts topics based on the number of team members and returns them in descending order&lt;br /&gt;
* assign_topics – Iterates through reviewers and assigns topics from the sorted queue, ensuring balanced distribution&lt;br /&gt;
* find_available_topic – Selects an available topic for a reviewer while avoiding self-selected topics&lt;br /&gt;
* reviewer_team_id – Retrieves the team ID associated with a given reviewer&lt;br /&gt;
* find_reviewer_user_id – Fetches the user ID for a given reviewer&lt;br /&gt;
* fetch_self_topic – Gets the topic that the user has self-selected for an assignment&lt;br /&gt;
* fetch_team_id – Finds the team ID for a given user in an assignment&lt;br /&gt;
* fetch_team_bids – Retrieves all bid records associated with a specific team&lt;br /&gt;
* format_bid – Converts a bid record into a structured format with topic ID, priority, and a formatted timestamp&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
=== ''Service'' ===&lt;br /&gt;
&lt;br /&gt;
The ReviewBiddingAlgorithmService is a service object responsible for handling communication between the application and the external web service that executes the review bidding algorithm. It prepares bidding data, sends it to the web service, processes the response, and provides a fallback mechanism in case of failure.&lt;br /&gt;
&lt;br /&gt;
This service allows to encapsulate all logic required to interact with the external topic-matching web service. It separates the algorithm execution concerns from the controller, improving modularity, testability, and maintainability of the code.&lt;br /&gt;
&lt;br /&gt;
====== Method: self.process_bidding ======&lt;br /&gt;
&lt;br /&gt;
This is the primary entry point for the controller. It accepts the assignment_id and a list of reviewer_ids, then prepares the bidding data by calling ReviewBid.bidding_data(...). It passes the data to the web service by calling run_bidding_algorithm. If the web service is unavailable or fails, the method logs an error and falls back to an internal method: ReviewBid.fallback_algorithm. The result is returned as a hash mapping reviewer IDs to arrays of assigned topic IDs.&lt;br /&gt;
&lt;br /&gt;
====== Method: self.run_bidding_algorithm ======&lt;br /&gt;
&lt;br /&gt;
This method retrieves the review bidding web service URL from the app configuration (config/webservices.yml) and calls the internal send_bidding_request method to make the actual request.It logs the outgoing URL for debugging and delegates the response parsing.&lt;br /&gt;
&lt;br /&gt;
====== Private Method: send_bidding_request ======&lt;br /&gt;
&lt;br /&gt;
This private class method handles the HTTP POST request using RestClient. It sends the bidding data as JSON and expects a JSON response. If the request fails due to a connection error, server error, or timeout, the method logs the exception and returns false, allowing the caller to trigger a fallback.&lt;br /&gt;
&lt;br /&gt;
[[File:Review_bidding_algorithm_service.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Fallback Algorithm ===&lt;br /&gt;
=====   ''Introduction''   =====&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm in Expertiza is designed to ensure automatic topic assignment when the primary Bidding Algorithm fails due to Web Service unavailability.  &lt;br /&gt;
&lt;br /&gt;
Normally, Expertiza allows reviewers to bid on topics, and the ''ReviewBiddingAlgorithmService'' processes these bids to assign topics. However, when this web service ''fails'' (due to API downtime, server issues, or unexpected errors), the system must switch to fallback and automatically assign topics to reviewers.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Solution''   =====&lt;br /&gt;
It is triggered when the web service is unavailable. It ensures fair topic assignment by:  &lt;br /&gt;
* Prioritizing topics with the largest teams.  &lt;br /&gt;
* Using a round-robin approach to distribute topics among reviewers.  &lt;br /&gt;
* Ensuring reviewers do not get their own team’s topic.  &lt;br /&gt;
&lt;br /&gt;
=====   ''When is this Used?''  ===== &lt;br /&gt;
* The ReviewBiddingAlgorithmService fails due to an API issue.  &lt;br /&gt;
* The web service times out or returns an error.  &lt;br /&gt;
* Unexpected exceptions occur in the bidding process.  &lt;br /&gt;
&lt;br /&gt;
Instead of stopping the review process, the system automatically falls-back to an internal algorithm to distribute topics.  &lt;br /&gt;
&lt;br /&gt;
=====   ''How Does the Fallback Algorithm Work?''   ===== &lt;br /&gt;
The algorithm follows these **four main steps:  &lt;br /&gt;
* Fetch available topics – Retrieves all topics for the given assignment.  &lt;br /&gt;
* Sort topics by team size – Topics with more members are given priority.  &lt;br /&gt;
* Create a topic queue – Topics are arranged in descending order of team size.  &lt;br /&gt;
* Assign topics in a round-robin manner – Reviewers are assigned topics while avoiding their own team's topic.  &lt;br /&gt;
&lt;br /&gt;
This ensures ''fair and balanced'' distribution of topics.&lt;br /&gt;
  &lt;br /&gt;
=====   ''Implementation - Controller Code (Triggering the Fallback)''   =====&lt;br /&gt;
If the primary bidding service fails, the system catches the error and calls the Fallback Algorithm.&lt;br /&gt;
&lt;br /&gt;
[[File:Controller-code.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: If ''ReviewBiddingAlgorithmService'' fails, the system automatically calls fallback_algorithm.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Implementation - Model Code (Fallback Algorithm)''   =====&lt;br /&gt;
This method ensures fair topic assignment when the bidding system fails.&lt;br /&gt;
&lt;br /&gt;
[[File:Model-code.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: This function ensures every reviewer receives a topic without requiring manual intervention.&lt;br /&gt;
&lt;br /&gt;
=====   ''RSpec Testing of Fallback Algorithm''   =====&lt;br /&gt;
To verify correctness, we use unit tests in ''review_bid_spec.rb''&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm ensures that ''topics are assigned fairly'' even when the primary bidding service fails. By prioritizing ''larger teams'', ''avoiding self-review'', and using a ''round-robin strategy'', the fallback mechanism keeps the review process smooth and automatic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
This section outlines the test plan for this project including testing scenarios/edge cases, the manual testing plan, and the automatic/RSpec testing plan.&lt;br /&gt;
&lt;br /&gt;
=== ''Testing Scenarios'' ===&lt;br /&gt;
This section outlines the various bidding scenarios that could occur. These scenarios should be tested in either '''Manual Testing''' or '''Automatic Testing'''.&lt;br /&gt;
&lt;br /&gt;
==== Basic Bidding Scenario ====&lt;br /&gt;
*Reviewers bid on multiple projects at different times&lt;br /&gt;
** Bidding algorithm should give priority to reviewers that bid first and should assign based on reviewers ranking&lt;br /&gt;
&lt;br /&gt;
====   Edge Cases   ====&lt;br /&gt;
* All reviewers bid on the same project&lt;br /&gt;
** If different time stamps: bidding algorithm should give priority to reviewers that bid first&lt;br /&gt;
** If same time stamps: bidding algorithm should assign reviews randomly&lt;br /&gt;
* None of the reviews bid on any projects&lt;br /&gt;
** Bidding algorithm should assign reviews randomly&lt;br /&gt;
* Reviewer bids on their own project&lt;br /&gt;
** Bidding algorithm should not allow a reviewer to bid on their own project and should have validation to prevent assigning a reviewer their own project&lt;br /&gt;
* None of the reviewers bid on a specific project&lt;br /&gt;
** Bidding algorithm should still assign reviewers to this project&lt;br /&gt;
&lt;br /&gt;
===   ''Manual Testing''   ===&lt;br /&gt;
Manual testing should be preformed on an Expertiza server and webserver platform &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Plan for Expertiza Server ====&lt;br /&gt;
* test that an instructor can allow review bidding for an assignment&lt;br /&gt;
* test that server routes correctly when review bidding is allowed&lt;br /&gt;
** test that task box links to bidding page before algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to bidding page before algorithm is run&lt;br /&gt;
** test that task box links to review page with bidding information after algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to review page with bidding information after algorithm is run&lt;br /&gt;
* test that the bidding UI is implemented as expected&lt;br /&gt;
* test that a participant can bid on projects to review&lt;br /&gt;
** test that a participant can move projects into the bidding column&lt;br /&gt;
** test that a participant can reorder projects in the bidding column&lt;br /&gt;
** test that a participant's bidding preferences save&lt;br /&gt;
** test that a participant can't bid for their own topic&lt;br /&gt;
* test that run algorithm button calls webserver with correct information and returns review assignments for each user&lt;br /&gt;
&lt;br /&gt;
==== Directions for Manual Testing of Expertiza Server ====&lt;br /&gt;
1. Go to [http://152.7.99.70:8081/ testing server] &amp;lt;br&amp;gt;&lt;br /&gt;
2. Log in as username: '''instructor6''' password: '''password''' &amp;lt;br&amp;gt;&lt;br /&gt;
3. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''General''' tab make sure '''Has teams?''' and '''Has topics?''' are checked&lt;br /&gt;
:# In the '''Topics''' tab check '''Allow review to choose which topic to review?''' then click '''save'''&lt;br /&gt;
:# In the '''Topics''' tab select '''Bidding''' then click '''save'''&lt;br /&gt;
4. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# This UI is based on '''instructor6''' being a '''participant''' assigned to topic '''Topic4'''&lt;br /&gt;
::# The UI blocks user from bidding on their own project &lt;br /&gt;
::# Check that user can bid on topics and reorder bids&lt;br /&gt;
::# Check that users topic preferences save on page refresh&lt;br /&gt;
::# Impersonate other participants and repeat bidding UI tests ('''student7601''', '''student7602''', '''student7603''', '''student7604''', '''student7605''', '''student7606''', '''student7607''', '''student7608''', '''student7609'')&lt;br /&gt;
5. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''Topics''' tab click '''Run Review Algorithm''' button&lt;br /&gt;
6. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# '''E2085 Manual Testing review''' should now link to the reviewing page&lt;br /&gt;
::# The number of required reviews should already be displayed&lt;br /&gt;
::# A '''Request Another Review''' button should be present unless reviews listed is equal to the number of reviews allowed&lt;br /&gt;
::# '''Begin''' a review and test '''save''' and '''submit'''&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Demo Video for Expertiza Server ====&lt;br /&gt;
Video demonstration of manual testing: [https://www.screencast.com/t/0rSg1zDW here]&lt;br /&gt;
&lt;br /&gt;
=== ''Automatic/PyTest Testing '' ===&lt;br /&gt;
Pytest tests are written for the webservice to test a well formed and a malformed request.&lt;br /&gt;
&lt;br /&gt;
===   ''Automatic/RSpec Testing ''   ===&lt;br /&gt;
RSpec tests will need to be refactored according to the changes that we make in the expertiza repository. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== RSpec Testing Plan ====&lt;br /&gt;
These RSpec tests will need to:&lt;br /&gt;
* test basic functionality of review bids controller&lt;br /&gt;
* test basic functionality of review bid model&lt;br /&gt;
&lt;br /&gt;
==== Directions for RSpec Testing ====&lt;br /&gt;
:# on personal device using [https://github.com/ncsu-ngw/expertiza forked repo]&lt;br /&gt;
:# Run the following commands:&lt;br /&gt;
&lt;br /&gt;
 # review bids controller: &lt;br /&gt;
 bundle exec rspec spec/controllers/review_bids_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
 # review bid model: &lt;br /&gt;
 bundle exec rspec spec/models/review_bid_spec.rb&lt;br /&gt;
 &lt;br /&gt;
 # review bidding algorithm service:&lt;br /&gt;
 bundle exec rspec spec/services/review_bidding_algorithm_service_spec.rb&lt;br /&gt;
&lt;br /&gt;
==Test Coverage==&lt;br /&gt;
Code Climate: [https://codeclimate.com/github/expertiza/expertiza/pull/2931 here]&lt;br /&gt;
&lt;br /&gt;
[[File:code-climate.png|700px]]&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
&lt;br /&gt;
'''Mentor:''' Janice Uwujaren (juwujar) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ashwin Muniswamy (akumarm) &amp;lt;br&amp;gt;&lt;br /&gt;
Arturo Serdan (aaserdan) &amp;lt;br&amp;gt;&lt;br /&gt;
Nicholas Winsen (nwinsen) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====''Previous Implementations''=====&lt;br /&gt;
Fall 2019 [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Spring 2020 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2020 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2024 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2508._Reimplement_bidding-algorithm_web_service here]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====''Relevant Links''=====&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/2931 &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
''Video Demo'': https://app.screencast.com/vaiJnWpHf0r07&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162650</id>
		<title>CSC/ECE 517 Spring 2025 - E2508. Reimplement bidding-algorithm web service</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162650"/>
		<updated>2025-03-25T02:15:00Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Project Overview==&lt;br /&gt;
===   ''Background''   ===&lt;br /&gt;
The previous implementation of the bidding service was hosted on peerlogic by a former student. The University no longer has access to this hosting service, and  is requiring a new solution. It is also asked that the webservice accept a better and cleaner json format which is easier to interpret and read.&lt;br /&gt;
&lt;br /&gt;
===   ''Objectives''   ===&lt;br /&gt;
# Reimplement trading cycles on a webservice&lt;br /&gt;
# Figure out a new hosting solution for the BiddingService web service. (VCL)&lt;br /&gt;
# Host the webservice on VCL&lt;br /&gt;
# Using tmux, figure out a way to keep the process running with a production wsgi service compatible with Flask.&lt;br /&gt;
# Create new tests for the repository&lt;br /&gt;
# Create a list of required packages that future maintainers can install easily&lt;br /&gt;
# Create a tests directory that users can test the functionality of the code with&lt;br /&gt;
# Modularize the code further, eliminate code smells.&lt;br /&gt;
# Refactor existing backend logic to account for the new json format&lt;br /&gt;
# Refactor existing backend code to send HTTP requests to the correct IP address&lt;br /&gt;
# Refactor existing frontend code to provide a list for users to select multiple topics on the frontend&lt;br /&gt;
# Allow users to prioritize their topic selection on the frontend&lt;br /&gt;
# Users should not be allowed to bid on their review topics on the frontend&lt;br /&gt;
# Display the results of the matched topics on the frontend&lt;br /&gt;
&lt;br /&gt;
===   ''Previous Work''   ===&lt;br /&gt;
There have been three previous implementations: &amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2019 [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Spring 2020 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2020 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2024 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2508._Reimplement_bidding-algorithm_web_service here]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/2931 &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Files Modified''   ===&lt;br /&gt;
This is a list of all the files added or changed in completing this project. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Changed'': &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/app.py - accomodated for changes in JsonParser&lt;br /&gt;
*app/json_parser.py - moved functions out due to SRP&lt;br /&gt;
*app/topics_matcher.py&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Added'': &amp;lt;br&amp;gt;&lt;br /&gt;
*app/tests/sample.json &amp;lt;br&amp;gt; - Sample input for the tests.&lt;br /&gt;
&lt;br /&gt;
*app/tests/test_assignment.py &amp;lt;br&amp;gt; Test File to test forms of input - tests both a successful and unsuccessful input&lt;br /&gt;
&lt;br /&gt;
*app/utils/popular_topics.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/student_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/topic_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
&lt;br /&gt;
*setup.py - required for wsgi&lt;br /&gt;
*wsgi.py - for hosting the server via gunicorn on VCL.&lt;br /&gt;
*.gitignore - to ignore anything that we may not want pushed (mostly for venv)&lt;br /&gt;
*requirements.txt - a list of requirements made easy for future maintainers&lt;br /&gt;
&lt;br /&gt;
=== ''Webservice'' ===&lt;br /&gt;
===== ''app'' =====&lt;br /&gt;
&lt;br /&gt;
The entry point to the Web service is the app.py file where we have the POST Method match_topics.&lt;br /&gt;
This receives the input in a json format from Expertiza. The input will contain a list of task ids, and then an Object of users, which each contain their student id and correlated bids that they made. Each bid contains a task id, a priority, and a timestamp. The input format was reworked to align to this style since it made more sense to have each student have a list of bids instead of the previous implementation which did not have this case. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:App2508.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''json parser'' =====&lt;br /&gt;
The json parser converts the json into a Dictionary. The previous implementation also had the parser create a preferences dictionary for the Student to store their topic preferences and one for Topics to store list of topics which have been selected by students and also the priority for the selection using the Timestamps. However, this was removed due to the Single Responsibility Principle. We felt the json parser was doing too much and should only be parsing the json!&lt;br /&gt;
&lt;br /&gt;
[[File:init_parser.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The student priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:student_prio.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The topic priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:topic_priorities.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== ''Test Input'' =====&lt;br /&gt;
&lt;br /&gt;
Sample Test case:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Case:&amp;lt;/b&amp;gt; There are a few very popular topics and the students who bid for them and bid early should receive it.&lt;br /&gt;
Popular Topics: 3969, 3971, 3972&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;tid&amp;quot;: [4427, 4428, 4429, 4430],&lt;br /&gt;
    &amp;quot;users&amp;quot;: {&lt;br /&gt;
      &amp;quot;40763&amp;quot;: {&lt;br /&gt;
          &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4429&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40764&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4427&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40765&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:15 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:16 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:17 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4428&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;max_accepted_proposals&amp;quot;: 3&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''Output'' =====&lt;br /&gt;
&lt;br /&gt;
 Since there is competition for these topics, the algorithm recognizes this and makes sure to assign them only to the students who bid for it.&lt;br /&gt;
		Other students who picked other topics or did not pick anything are assigned different topics.&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
    &amp;quot;40763&amp;quot;: [&lt;br /&gt;
        4427,&lt;br /&gt;
        4428,&lt;br /&gt;
        4430&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40764&amp;quot;: [&lt;br /&gt;
        4428,&lt;br /&gt;
        4430,&lt;br /&gt;
        4429&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40765&amp;quot;: [&lt;br /&gt;
        4429,&lt;br /&gt;
        4427,&lt;br /&gt;
        4430&lt;br /&gt;
    ]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== ''Controller'' ===&lt;br /&gt;
&lt;br /&gt;
The controller includes 8 methods that handle the review bidding process. The public methods cover authorization, rendering views, saving user bids, and coordinating review assignment. The private methods support these functions by abstracting data gathering and algorithm coordination logic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Method: action_allowed? ======&lt;br /&gt;
&lt;br /&gt;
This method controls user access to controller actions. It allows 'Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator', and 'Student' roles to access show, set_priority, and index. Other actions are restricted to non-student roles. It ensures proper permissions for accessing review bidding features.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: index ======&lt;br /&gt;
&lt;br /&gt;
This method gathers information for the &amp;quot;Your Work&amp;quot; page, where users can view their assigned reviews. It checks user identity, retrieves associated reviews, and counts completed reviews. The view rendered is sign_up_sheet/review_bids_others_work.View: others_work.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_index.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: show ======&lt;br /&gt;
&lt;br /&gt;
This method renders the bidding page where users select topics they'd prefer to review. It fetches the assignment, available topics, and any existing bids. Already assigned or signed-up topics are excluded. The page also lists any assigned reviews.View: show.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_show.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: set_priority ======&lt;br /&gt;
&lt;br /&gt;
This method stores or updates a participant's topic preferences. It removes old bids not in the current selection and creates or updates the remaining bids with new priorities. This method is triggered when users submit their topic rankings on the bidding page.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_set_priority.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_bidding ======&lt;br /&gt;
&lt;br /&gt;
This method coordinates the assignment of review topics. It gathers reviewer IDs and invokes the bidding algorithm using a service. It validates the output and uses ReviewBid.assign_review_topics to perform the actual assignment. Bidding is then disabled.&lt;br /&gt;
&lt;br /&gt;
[[File:Assign_bidding.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: fetch_reviewer_ids (Private) ======&lt;br /&gt;
&lt;br /&gt;
This helper method retrieves all AssignmentParticipant IDs for a given assignment. These IDs represent the reviewers participating in the bidding process.&lt;br /&gt;
&lt;br /&gt;
====== Method: process_bidding (Private) ======&lt;br /&gt;
This helper method delegates the logic for running the bidding algorithm to the service class ReviewBiddingAlgorithmService. It takes the assignment ID and list of reviewers as input and returns matched topic assignments.&lt;br /&gt;
&lt;br /&gt;
====== Method: ensure_valid_topics (Private) ======&lt;br /&gt;
This method ensures that all reviewers have valid topic assignment entries, even if the algorithm returns nothing (e.g., due to web service failure). It initializes empty topic arrays for any missing reviewers.&lt;br /&gt;
&lt;br /&gt;
[[File:Controller_private_methods.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== ''Model'' ===&lt;br /&gt;
&lt;br /&gt;
The model includes 13 methods that manage the review bidding process. The public methods handle bidding data retrieval, review topic assignment, and fallback allocation. The private methods support these functions by fetching user and team data, sorting topics, and formatting bid details.&lt;br /&gt;
&lt;br /&gt;
====== Method: bidding_data ======&lt;br /&gt;
&lt;br /&gt;
Collects bidding data for an assignment, including topics, max allowed proposals, and individual reviewer bids.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_review_topics ======&lt;br /&gt;
&lt;br /&gt;
Assigns reviewers to topics based on matched preferences and clears previous assignments.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_topic_to_reviewer ======&lt;br /&gt;
&lt;br /&gt;
Assigns a single topic to a reviewer by linking them to a team under that topic.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: reviewer_bidding_data ======&lt;br /&gt;
&lt;br /&gt;
Retrieves bid details for a specific reviewer, including self-selected topics and bid priorities.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: fallback_algorithm ======&lt;br /&gt;
&lt;br /&gt;
Assigns topics to reviewers using a fallback approach when the initial bidding fails.&lt;br /&gt;
&lt;br /&gt;
====== Private Methods: fallback_algorithm ======&lt;br /&gt;
&lt;br /&gt;
* sorted_topic_queue – Sorts topics based on the number of team members and returns them in descending order&lt;br /&gt;
* assign_topics – Iterates through reviewers and assigns topics from the sorted queue, ensuring balanced distribution&lt;br /&gt;
* find_available_topic – Selects an available topic for a reviewer while avoiding self-selected topics&lt;br /&gt;
* reviewer_team_id – Retrieves the team ID associated with a given reviewer&lt;br /&gt;
* find_reviewer_user_id – Fetches the user ID for a given reviewer&lt;br /&gt;
* fetch_self_topic – Gets the topic that the user has self-selected for an assignment&lt;br /&gt;
* fetch_team_id – Finds the team ID for a given user in an assignment&lt;br /&gt;
* fetch_team_bids – Retrieves all bid records associated with a specific team&lt;br /&gt;
* format_bid – Converts a bid record into a structured format with topic ID, priority, and a formatted timestamp&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
=== ''Service'' ===&lt;br /&gt;
&lt;br /&gt;
The ReviewBiddingAlgorithmService is a service object responsible for handling communication between the application and the external web service that executes the review bidding algorithm. It prepares bidding data, sends it to the web service, processes the response, and provides a fallback mechanism in case of failure.&lt;br /&gt;
&lt;br /&gt;
This service allows to encapsulate all logic required to interact with the external topic-matching web service. It separates the algorithm execution concerns from the controller, improving modularity, testability, and maintainability of the code.&lt;br /&gt;
&lt;br /&gt;
====== Method: self.process_bidding ======&lt;br /&gt;
&lt;br /&gt;
This is the primary entry point for the controller. It accepts the assignment_id and a list of reviewer_ids, then prepares the bidding data by calling ReviewBid.bidding_data(...). It passes the data to the web service by calling run_bidding_algorithm. If the web service is unavailable or fails, the method logs an error and falls back to an internal method: ReviewBid.fallback_algorithm. The result is returned as a hash mapping reviewer IDs to arrays of assigned topic IDs.&lt;br /&gt;
&lt;br /&gt;
====== Method: self.run_bidding_algorithm ======&lt;br /&gt;
&lt;br /&gt;
This method retrieves the review bidding web service URL from the app configuration (config/webservices.yml) and calls the internal send_bidding_request method to make the actual request.It logs the outgoing URL for debugging and delegates the response parsing.&lt;br /&gt;
&lt;br /&gt;
====== Private Method: send_bidding_request ======&lt;br /&gt;
&lt;br /&gt;
This private class method handles the HTTP POST request using RestClient. It sends the bidding data as JSON and expects a JSON response. If the request fails due to a connection error, server error, or timeout, the method logs the exception and returns false, allowing the caller to trigger a fallback.&lt;br /&gt;
&lt;br /&gt;
[[File:Review_bidding_algorithm_service.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Fallback Algorithm ===&lt;br /&gt;
=====   ''Introduction''   =====&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm in Expertiza is designed to ensure automatic topic assignment when the primary Bidding Algorithm fails due to Web Service unavailability.  &lt;br /&gt;
&lt;br /&gt;
Normally, Expertiza allows reviewers to bid on topics, and the ''ReviewBiddingAlgorithmService'' processes these bids to assign topics. However, when this web service ''fails'' (due to API downtime, server issues, or unexpected errors), the system must switch to fallback and automatically assign topics to reviewers.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Solution''   =====&lt;br /&gt;
It is triggered when the web service is unavailable. It ensures fair topic assignment by:  &lt;br /&gt;
* Prioritizing topics with the largest teams.  &lt;br /&gt;
* Using a round-robin approach to distribute topics among reviewers.  &lt;br /&gt;
* Ensuring reviewers do not get their own team’s topic.  &lt;br /&gt;
&lt;br /&gt;
=====   ''When is this Used?''  ===== &lt;br /&gt;
* The ReviewBiddingAlgorithmService fails due to an API issue.  &lt;br /&gt;
* The web service times out or returns an error.  &lt;br /&gt;
* Unexpected exceptions occur in the bidding process.  &lt;br /&gt;
&lt;br /&gt;
Instead of stopping the review process, the system automatically falls-back to an internal algorithm to distribute topics.  &lt;br /&gt;
&lt;br /&gt;
=====   ''How Does the Fallback Algorithm Work?''   ===== &lt;br /&gt;
The algorithm follows these **four main steps:  &lt;br /&gt;
* Fetch available topics – Retrieves all topics for the given assignment.  &lt;br /&gt;
* Sort topics by team size – Topics with more members are given priority.  &lt;br /&gt;
* Create a topic queue – Topics are arranged in descending order of team size.  &lt;br /&gt;
* Assign topics in a round-robin manner – Reviewers are assigned topics while avoiding their own team's topic.  &lt;br /&gt;
&lt;br /&gt;
This ensures ''fair and balanced'' distribution of topics.&lt;br /&gt;
  &lt;br /&gt;
=====   ''Implementation - Controller Code (Triggering the Fallback)''   =====&lt;br /&gt;
If the primary bidding service fails, the system catches the error and calls the Fallback Algorithm.&lt;br /&gt;
&lt;br /&gt;
[[File:Controller-code.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: If ''ReviewBiddingAlgorithmService'' fails, the system automatically calls fallback_algorithm.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Implementation - Model Code (Fallback Algorithm)''   =====&lt;br /&gt;
This method ensures fair topic assignment when the bidding system fails.&lt;br /&gt;
&lt;br /&gt;
[[File:Model-code.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: This function ensures every reviewer receives a topic without requiring manual intervention.&lt;br /&gt;
&lt;br /&gt;
=====   ''RSpec Testing of Fallback Algorithm''   =====&lt;br /&gt;
To verify correctness, we use unit tests in ''review_bid_spec.rb''&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm ensures that ''topics are assigned fairly'' even when the primary bidding service fails. By prioritizing ''larger teams'', ''avoiding self-review'', and using a ''round-robin strategy'', the fallback mechanism keeps the review process smooth and automatic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
This section outlines the test plan for this project including testing scenarios/edge cases, the manual testing plan, and the automatic/RSpec testing plan.&lt;br /&gt;
&lt;br /&gt;
=== ''Testing Scenarios'' ===&lt;br /&gt;
This section outlines the various bidding scenarios that could occur. These scenarios should be tested in either '''Manual Testing''' or '''Automatic Testing'''.&lt;br /&gt;
&lt;br /&gt;
==== Basic Bidding Scenario ====&lt;br /&gt;
*Reviewers bid on multiple projects at different times&lt;br /&gt;
** Bidding algorithm should give priority to reviewers that bid first and should assign based on reviewers ranking&lt;br /&gt;
&lt;br /&gt;
====   Edge Cases   ====&lt;br /&gt;
* All reviewers bid on the same project&lt;br /&gt;
** If different time stamps: bidding algorithm should give priority to reviewers that bid first&lt;br /&gt;
** If same time stamps: bidding algorithm should assign reviews randomly&lt;br /&gt;
* None of the reviews bid on any projects&lt;br /&gt;
** Bidding algorithm should assign reviews randomly&lt;br /&gt;
* Reviewer bids on their own project&lt;br /&gt;
** Bidding algorithm should not allow a reviewer to bid on their own project and should have validation to prevent assigning a reviewer their own project&lt;br /&gt;
* None of the reviewers bid on a specific project&lt;br /&gt;
** Bidding algorithm should still assign reviewers to this project&lt;br /&gt;
&lt;br /&gt;
===   ''Manual Testing''   ===&lt;br /&gt;
Manual testing should be preformed on an Expertiza server and webserver platform &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Plan for Expertiza Server ====&lt;br /&gt;
* test that an instructor can allow review bidding for an assignment&lt;br /&gt;
* test that server routes correctly when review bidding is allowed&lt;br /&gt;
** test that task box links to bidding page before algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to bidding page before algorithm is run&lt;br /&gt;
** test that task box links to review page with bidding information after algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to review page with bidding information after algorithm is run&lt;br /&gt;
* test that the bidding UI is implemented as expected&lt;br /&gt;
* test that a participant can bid on projects to review&lt;br /&gt;
** test that a participant can move projects into the bidding column&lt;br /&gt;
** test that a participant can reorder projects in the bidding column&lt;br /&gt;
** test that a participant's bidding preferences save&lt;br /&gt;
** test that a participant can't bid for their own topic&lt;br /&gt;
* test that run algorithm button calls webserver with correct information and returns review assignments for each user&lt;br /&gt;
&lt;br /&gt;
==== Directions for Manual Testing of Expertiza Server ====&lt;br /&gt;
1. Go to [http://152.7.99.70:8081/ testing server] &amp;lt;br&amp;gt;&lt;br /&gt;
2. Log in as username: '''instructor6''' password: '''password''' &amp;lt;br&amp;gt;&lt;br /&gt;
3. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''General''' tab make sure '''Has teams?''' and '''Has topics?''' are checked&lt;br /&gt;
:# In the '''Topics''' tab check '''Allow review to choose which topic to review?''' then click '''save'''&lt;br /&gt;
:# In the '''Topics''' tab select '''Bidding''' then click '''save'''&lt;br /&gt;
4. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# This UI is based on '''instructor6''' being a '''participant''' assigned to topic '''Topic4'''&lt;br /&gt;
::# The UI blocks user from bidding on their own project &lt;br /&gt;
::# Check that user can bid on topics and reorder bids&lt;br /&gt;
::# Check that users topic preferences save on page refresh&lt;br /&gt;
::# Impersonate other participants and repeat bidding UI tests ('''student7601''', '''student7602''', '''student7603''', '''student7604''', '''student7605''', '''student7606''', '''student7607''', '''student7608''', '''student7609'')&lt;br /&gt;
5. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''Topics''' tab click '''Run Review Algorithm''' button&lt;br /&gt;
6. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# '''E2085 Manual Testing review''' should now link to the reviewing page&lt;br /&gt;
::# The number of required reviews should already be displayed&lt;br /&gt;
::# A '''Request Another Review''' button should be present unless reviews listed is equal to the number of reviews allowed&lt;br /&gt;
::# '''Begin''' a review and test '''save''' and '''submit'''&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Demo Video for Expertiza Server ====&lt;br /&gt;
Video demonstration of manual testing: [https://www.screencast.com/t/0rSg1zDW here]&lt;br /&gt;
&lt;br /&gt;
=== ''Automatic/PyTest Testing '' ===&lt;br /&gt;
Pytest tests are written for the webservice to test a well formed and a malformed request.&lt;br /&gt;
&lt;br /&gt;
===   ''Automatic/RSpec Testing ''   ===&lt;br /&gt;
RSpec tests will need to be refactored according to the changes that we make in the expertiza repository. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== RSpec Testing Plan ====&lt;br /&gt;
These RSpec tests will need to:&lt;br /&gt;
* test basic functionality of review bids controller&lt;br /&gt;
* test basic functionality of review bid model&lt;br /&gt;
&lt;br /&gt;
==== Directions for RSpec Testing ====&lt;br /&gt;
:# on personal device using [https://github.com/ncsu-ngw/expertiza forked repo]&lt;br /&gt;
:# Run the following commands:&lt;br /&gt;
&lt;br /&gt;
 # review bids controller: &lt;br /&gt;
 bundle exec rspec spec/controllers/review_bids_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
 # review bid model: &lt;br /&gt;
 bundle exec rspec spec/models/review_bid_spec.rb&lt;br /&gt;
 &lt;br /&gt;
 # review bidding algorithm service:&lt;br /&gt;
 bundle exec rspec spec/services/review_bidding_algorithm_service_spec.rb&lt;br /&gt;
&lt;br /&gt;
==Test Coverage==&lt;br /&gt;
Code Climate: [https://codeclimate.com/github/expertiza/expertiza/pull/2931 here]&lt;br /&gt;
&lt;br /&gt;
[[File:code-climate.png|700px]]&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
&lt;br /&gt;
'''Mentor:''' Janice Uwujaren (juwujar) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ashwin Muniswamy (akumarm) &amp;lt;br&amp;gt;&lt;br /&gt;
Arturo Serdan (aaserdan) &amp;lt;br&amp;gt;&lt;br /&gt;
Nicholas Winsen (nwinsen) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====''Previous Implementations''=====&lt;br /&gt;
Fall 2019 [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Spring 2020 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2020 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2024 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2508._Reimplement_bidding-algorithm_web_service here]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====''Relevant Links''=====&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/2931 &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
''Video Demo'': https://app.screencast.com/vaiJnWpHf0r07&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162649</id>
		<title>CSC/ECE 517 Spring 2025 - E2508. Reimplement bidding-algorithm web service</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162649"/>
		<updated>2025-03-25T02:10:59Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Project Overview==&lt;br /&gt;
===   ''Background''   ===&lt;br /&gt;
The previous implementation of the bidding service was hosted on peerlogic by a former student. The University no longer has access to this hosting service, and  is requiring a new solution. It is also asked that the webservice accept a better and cleaner json format which is easier to interpret and read.&lt;br /&gt;
&lt;br /&gt;
===   ''Objectives''   ===&lt;br /&gt;
# Reimplement trading cycles on a webservice&lt;br /&gt;
# Figure out a new hosting solution for the BiddingService web service. (VCL)&lt;br /&gt;
# Host the webservice on VCL&lt;br /&gt;
# Using tmux, figure out a way to keep the process running with a production wsgi service compatible with Flask.&lt;br /&gt;
# Create new tests for the repository&lt;br /&gt;
# Create a list of required packages that future maintainers can install easily&lt;br /&gt;
# Create a tests directory that users can test the functionality of the code with&lt;br /&gt;
# Modularize the code further, eliminate code smells.&lt;br /&gt;
# Refactor existing backend logic to account for the new json format&lt;br /&gt;
# Refactor existing backend code to send HTTP requests to the correct IP address&lt;br /&gt;
# Refactor existing frontend code to provide a list for users to select multiple topics on the frontend&lt;br /&gt;
# Allow users to prioritize their topic selection on the frontend&lt;br /&gt;
# Users should not be allowed to bid on their review topics on the frontend&lt;br /&gt;
# Display the results of the matched topics on the frontend&lt;br /&gt;
&lt;br /&gt;
===   ''Previous Work''   ===&lt;br /&gt;
There have been three previous implementations: &amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2019 [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Spring 2020 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2020 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2024 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2508._Reimplement_bidding-algorithm_web_service here]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/2931 &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Files Modified''   ===&lt;br /&gt;
This is a list of all the files added or changed in completing this project. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Changed'': &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/app.py - accomodated for changes in JsonParser&lt;br /&gt;
*app/json_parser.py - moved functions out due to SRP&lt;br /&gt;
*app/topics_matcher.py&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Added'': &amp;lt;br&amp;gt;&lt;br /&gt;
*app/tests/sample.json &amp;lt;br&amp;gt; - Sample input for the tests.&lt;br /&gt;
&lt;br /&gt;
*app/tests/test_assignment.py &amp;lt;br&amp;gt; Test File to test forms of input - tests both a successful and unsuccessful input&lt;br /&gt;
&lt;br /&gt;
*app/utils/popular_topics.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/student_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/topic_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
&lt;br /&gt;
*setup.py - required for wsgi&lt;br /&gt;
*wsgi.py - for hosting the server via gunicorn on VCL.&lt;br /&gt;
*.gitignore - to ignore anything that we may not want pushed (mostly for venv)&lt;br /&gt;
*requirements.txt - a list of requirements made easy for future maintainers&lt;br /&gt;
&lt;br /&gt;
=== ''Webservice'' ===&lt;br /&gt;
===== ''app'' =====&lt;br /&gt;
&lt;br /&gt;
The entry point to the Web service is the app.py file where we have the POST Method match_topics.&lt;br /&gt;
This receives the input in a json format from Expertiza. The input will contain a list of task ids, and then an Object of users, which each contain their student id and correlated bids that they made. Each bid contains a task id, a priority, and a timestamp. The input format was reworked to align to this style since it made more sense to have each student have a list of bids instead of the previous implementation which did not have this case. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:App2508.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''json parser'' =====&lt;br /&gt;
The json parser converts the json into a Dictionary. The previous implementation also had the parser create a preferences dictionary for the Student to store their topic preferences and one for Topics to store list of topics which have been selected by students and also the priority for the selection using the Timestamps. However, this was removed due to the Single Responsibility Principle. We felt the json parser was doing too much and should only be parsing the json!&lt;br /&gt;
&lt;br /&gt;
[[File:init_parser.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The student priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:student_prio.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The topic priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:topic_priorities.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== ''Test Input'' =====&lt;br /&gt;
&lt;br /&gt;
Sample Test case:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Case:&amp;lt;/b&amp;gt; There are a few very popular topics and the students who bid for them and bid early should receive it.&lt;br /&gt;
Popular Topics: 3969, 3971, 3972&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;tid&amp;quot;: [4427, 4428, 4429, 4430],&lt;br /&gt;
    &amp;quot;users&amp;quot;: {&lt;br /&gt;
      &amp;quot;40763&amp;quot;: {&lt;br /&gt;
          &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4429&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40764&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4427&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40765&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:15 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:16 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:17 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4428&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;max_accepted_proposals&amp;quot;: 3&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''Output'' =====&lt;br /&gt;
&lt;br /&gt;
 Since there is competition for these topics, the algorithm recognizes this and makes sure to assign them only to the students who bid for it.&lt;br /&gt;
		Other students who picked other topics or did not pick anything are assigned different topics.&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
    &amp;quot;40763&amp;quot;: [&lt;br /&gt;
        4427,&lt;br /&gt;
        4428,&lt;br /&gt;
        4430&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40764&amp;quot;: [&lt;br /&gt;
        4428,&lt;br /&gt;
        4430,&lt;br /&gt;
        4429&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40765&amp;quot;: [&lt;br /&gt;
        4429,&lt;br /&gt;
        4427,&lt;br /&gt;
        4430&lt;br /&gt;
    ]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== ''Controller'' ===&lt;br /&gt;
&lt;br /&gt;
The controller includes 8 methods that handle the review bidding process. The public methods cover authorization, rendering views, saving user bids, and coordinating review assignment. The private methods support these functions by abstracting data gathering and algorithm coordination logic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Method: action_allowed? ======&lt;br /&gt;
&lt;br /&gt;
This method controls user access to controller actions. It allows 'Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator', and 'Student' roles to access show, set_priority, and index. Other actions are restricted to non-student roles. It ensures proper permissions for accessing review bidding features.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: index ======&lt;br /&gt;
&lt;br /&gt;
This method gathers information for the &amp;quot;Your Work&amp;quot; page, where users can view their assigned reviews. It checks user identity, retrieves associated reviews, and counts completed reviews. The view rendered is sign_up_sheet/review_bids_others_work.View: others_work.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_index.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: show ======&lt;br /&gt;
&lt;br /&gt;
This method renders the bidding page where users select topics they'd prefer to review. It fetches the assignment, available topics, and any existing bids. Already assigned or signed-up topics are excluded. The page also lists any assigned reviews.View: show.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_show.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: set_priority ======&lt;br /&gt;
&lt;br /&gt;
This method stores or updates a participant's topic preferences. It removes old bids not in the current selection and creates or updates the remaining bids with new priorities. This method is triggered when users submit their topic rankings on the bidding page.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_set_priority.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_bidding ======&lt;br /&gt;
&lt;br /&gt;
This method coordinates the assignment of review topics. It gathers reviewer IDs and invokes the bidding algorithm using a service. It validates the output and uses ReviewBid.assign_review_topics to perform the actual assignment. Bidding is then disabled.&lt;br /&gt;
&lt;br /&gt;
[[File:Assign_bidding.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: fetch_reviewer_ids (Private) ======&lt;br /&gt;
&lt;br /&gt;
This helper method retrieves all AssignmentParticipant IDs for a given assignment. These IDs represent the reviewers participating in the bidding process.&lt;br /&gt;
&lt;br /&gt;
====== Method: process_bidding (Private) ======&lt;br /&gt;
This helper method delegates the logic for running the bidding algorithm to the service class ReviewBiddingAlgorithmService. It takes the assignment ID and list of reviewers as input and returns matched topic assignments.&lt;br /&gt;
&lt;br /&gt;
====== Method: ensure_valid_topics (Private) ======&lt;br /&gt;
This method ensures that all reviewers have valid topic assignment entries, even if the algorithm returns nothing (e.g., due to web service failure). It initializes empty topic arrays for any missing reviewers.&lt;br /&gt;
&lt;br /&gt;
[[File:Controller_private_methods.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== ''Model'' ===&lt;br /&gt;
&lt;br /&gt;
The model includes 13 methods that manage the review bidding process. The public methods handle bidding data retrieval, review topic assignment, and fallback allocation. The private methods support these functions by fetching user and team data, sorting topics, and formatting bid details.&lt;br /&gt;
&lt;br /&gt;
====== Method: bidding_data ======&lt;br /&gt;
&lt;br /&gt;
Collects bidding data for an assignment, including topics, max allowed proposals, and individual reviewer bids.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_review_topics ======&lt;br /&gt;
&lt;br /&gt;
Assigns reviewers to topics based on matched preferences and clears previous assignments.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_topic_to_reviewer ======&lt;br /&gt;
&lt;br /&gt;
Assigns a single topic to a reviewer by linking them to a team under that topic.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: reviewer_bidding_data ======&lt;br /&gt;
&lt;br /&gt;
Retrieves bid details for a specific reviewer, including self-selected topics and bid priorities.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: fallback_algorithm ======&lt;br /&gt;
&lt;br /&gt;
Assigns topics to reviewers using a fallback approach when the initial bidding fails.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
=== ''Service'' ===&lt;br /&gt;
&lt;br /&gt;
The ReviewBiddingAlgorithmService is a service object responsible for handling communication between the application and the external web service that executes the review bidding algorithm. It prepares bidding data, sends it to the web service, processes the response, and provides a fallback mechanism in case of failure.&lt;br /&gt;
&lt;br /&gt;
This service allows to encapsulate all logic required to interact with the external topic-matching web service. It separates the algorithm execution concerns from the controller, improving modularity, testability, and maintainability of the code.&lt;br /&gt;
&lt;br /&gt;
====== Method: self.process_bidding ======&lt;br /&gt;
&lt;br /&gt;
This is the primary entry point for the controller. It accepts the assignment_id and a list of reviewer_ids, then prepares the bidding data by calling ReviewBid.bidding_data(...). It passes the data to the web service by calling run_bidding_algorithm. If the web service is unavailable or fails, the method logs an error and falls back to an internal method: ReviewBid.fallback_algorithm. The result is returned as a hash mapping reviewer IDs to arrays of assigned topic IDs.&lt;br /&gt;
&lt;br /&gt;
====== Method: self.run_bidding_algorithm ======&lt;br /&gt;
&lt;br /&gt;
This method retrieves the review bidding web service URL from the app configuration (config/webservices.yml) and calls the internal send_bidding_request method to make the actual request.It logs the outgoing URL for debugging and delegates the response parsing.&lt;br /&gt;
&lt;br /&gt;
====== Private Method: send_bidding_request ======&lt;br /&gt;
&lt;br /&gt;
This private class method handles the HTTP POST request using RestClient. It sends the bidding data as JSON and expects a JSON response. If the request fails due to a connection error, server error, or timeout, the method logs the exception and returns false, allowing the caller to trigger a fallback.&lt;br /&gt;
&lt;br /&gt;
[[File:Review_bidding_algorithm_service.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Fallback Algorithm ===&lt;br /&gt;
=====   ''Introduction''   =====&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm in Expertiza is designed to ensure automatic topic assignment when the primary Bidding Algorithm fails due to Web Service unavailability.  &lt;br /&gt;
&lt;br /&gt;
Normally, Expertiza allows reviewers to bid on topics, and the ''ReviewBiddingAlgorithmService'' processes these bids to assign topics. However, when this web service ''fails'' (due to API downtime, server issues, or unexpected errors), the system must switch to fallback and automatically assign topics to reviewers.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Solution''   =====&lt;br /&gt;
It is triggered when the web service is unavailable. It ensures fair topic assignment by:  &lt;br /&gt;
* Prioritizing topics with the largest teams.  &lt;br /&gt;
* Using a round-robin approach to distribute topics among reviewers.  &lt;br /&gt;
* Ensuring reviewers do not get their own team’s topic.  &lt;br /&gt;
&lt;br /&gt;
=====   ''When is this Used?''  ===== &lt;br /&gt;
* The ReviewBiddingAlgorithmService fails due to an API issue.  &lt;br /&gt;
* The web service times out or returns an error.  &lt;br /&gt;
* Unexpected exceptions occur in the bidding process.  &lt;br /&gt;
&lt;br /&gt;
Instead of stopping the review process, the system automatically falls-back to an internal algorithm to distribute topics.  &lt;br /&gt;
&lt;br /&gt;
=====   ''How Does the Fallback Algorithm Work?''   ===== &lt;br /&gt;
The algorithm follows these **four main steps:  &lt;br /&gt;
* Fetch available topics – Retrieves all topics for the given assignment.  &lt;br /&gt;
* Sort topics by team size – Topics with more members are given priority.  &lt;br /&gt;
* Create a topic queue – Topics are arranged in descending order of team size.  &lt;br /&gt;
* Assign topics in a round-robin manner – Reviewers are assigned topics while avoiding their own team's topic.  &lt;br /&gt;
&lt;br /&gt;
This ensures ''fair and balanced'' distribution of topics.&lt;br /&gt;
  &lt;br /&gt;
=====   ''Implementation - Controller Code (Triggering the Fallback)''   =====&lt;br /&gt;
If the primary bidding service fails, the system catches the error and calls the Fallback Algorithm.&lt;br /&gt;
&lt;br /&gt;
[[File:Controller-code.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: If ''ReviewBiddingAlgorithmService'' fails, the system automatically calls fallback_algorithm.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Implementation - Model Code (Fallback Algorithm)''   =====&lt;br /&gt;
This method ensures fair topic assignment when the bidding system fails.&lt;br /&gt;
&lt;br /&gt;
[[File:Model-code.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: This function ensures every reviewer receives a topic without requiring manual intervention.&lt;br /&gt;
&lt;br /&gt;
=====   ''RSpec Testing of Fallback Algorithm''   =====&lt;br /&gt;
To verify correctness, we use unit tests in ''review_bid_spec.rb''&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm ensures that ''topics are assigned fairly'' even when the primary bidding service fails. By prioritizing ''larger teams'', ''avoiding self-review'', and using a ''round-robin strategy'', the fallback mechanism keeps the review process smooth and automatic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
This section outlines the test plan for this project including testing scenarios/edge cases, the manual testing plan, and the automatic/RSpec testing plan.&lt;br /&gt;
&lt;br /&gt;
=== ''Testing Scenarios'' ===&lt;br /&gt;
This section outlines the various bidding scenarios that could occur. These scenarios should be tested in either '''Manual Testing''' or '''Automatic Testing'''.&lt;br /&gt;
&lt;br /&gt;
==== Basic Bidding Scenario ====&lt;br /&gt;
*Reviewers bid on multiple projects at different times&lt;br /&gt;
** Bidding algorithm should give priority to reviewers that bid first and should assign based on reviewers ranking&lt;br /&gt;
&lt;br /&gt;
====   Edge Cases   ====&lt;br /&gt;
* All reviewers bid on the same project&lt;br /&gt;
** If different time stamps: bidding algorithm should give priority to reviewers that bid first&lt;br /&gt;
** If same time stamps: bidding algorithm should assign reviews randomly&lt;br /&gt;
* None of the reviews bid on any projects&lt;br /&gt;
** Bidding algorithm should assign reviews randomly&lt;br /&gt;
* Reviewer bids on their own project&lt;br /&gt;
** Bidding algorithm should not allow a reviewer to bid on their own project and should have validation to prevent assigning a reviewer their own project&lt;br /&gt;
* None of the reviewers bid on a specific project&lt;br /&gt;
** Bidding algorithm should still assign reviewers to this project&lt;br /&gt;
&lt;br /&gt;
===   ''Manual Testing''   ===&lt;br /&gt;
Manual testing should be preformed on an Expertiza server and webserver platform &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Plan for Expertiza Server ====&lt;br /&gt;
* test that an instructor can allow review bidding for an assignment&lt;br /&gt;
* test that server routes correctly when review bidding is allowed&lt;br /&gt;
** test that task box links to bidding page before algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to bidding page before algorithm is run&lt;br /&gt;
** test that task box links to review page with bidding information after algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to review page with bidding information after algorithm is run&lt;br /&gt;
* test that the bidding UI is implemented as expected&lt;br /&gt;
* test that a participant can bid on projects to review&lt;br /&gt;
** test that a participant can move projects into the bidding column&lt;br /&gt;
** test that a participant can reorder projects in the bidding column&lt;br /&gt;
** test that a participant's bidding preferences save&lt;br /&gt;
** test that a participant can't bid for their own topic&lt;br /&gt;
* test that run algorithm button calls webserver with correct information and returns review assignments for each user&lt;br /&gt;
&lt;br /&gt;
==== Directions for Manual Testing of Expertiza Server ====&lt;br /&gt;
1. Go to [http://152.7.99.70:8081/ testing server] &amp;lt;br&amp;gt;&lt;br /&gt;
2. Log in as username: '''instructor6''' password: '''password''' &amp;lt;br&amp;gt;&lt;br /&gt;
3. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''General''' tab make sure '''Has teams?''' and '''Has topics?''' are checked&lt;br /&gt;
:# In the '''Topics''' tab check '''Allow review to choose which topic to review?''' then click '''save'''&lt;br /&gt;
:# In the '''Topics''' tab select '''Bidding''' then click '''save'''&lt;br /&gt;
4. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# This UI is based on '''instructor6''' being a '''participant''' assigned to topic '''Topic4'''&lt;br /&gt;
::# The UI blocks user from bidding on their own project &lt;br /&gt;
::# Check that user can bid on topics and reorder bids&lt;br /&gt;
::# Check that users topic preferences save on page refresh&lt;br /&gt;
::# Impersonate other participants and repeat bidding UI tests ('''student7601''', '''student7602''', '''student7603''', '''student7604''', '''student7605''', '''student7606''', '''student7607''', '''student7608''', '''student7609'')&lt;br /&gt;
5. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''Topics''' tab click '''Run Review Algorithm''' button&lt;br /&gt;
6. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# '''E2085 Manual Testing review''' should now link to the reviewing page&lt;br /&gt;
::# The number of required reviews should already be displayed&lt;br /&gt;
::# A '''Request Another Review''' button should be present unless reviews listed is equal to the number of reviews allowed&lt;br /&gt;
::# '''Begin''' a review and test '''save''' and '''submit'''&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Demo Video for Expertiza Server ====&lt;br /&gt;
Video demonstration of manual testing: [https://www.screencast.com/t/0rSg1zDW here]&lt;br /&gt;
&lt;br /&gt;
=== ''Automatic/PyTest Testing '' ===&lt;br /&gt;
Pytest tests are written for the webservice to test a well formed and a malformed request.&lt;br /&gt;
&lt;br /&gt;
===   ''Automatic/RSpec Testing ''   ===&lt;br /&gt;
RSpec tests will need to be refactored according to the changes that we make in the expertiza repository. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== RSpec Testing Plan ====&lt;br /&gt;
These RSpec tests will need to:&lt;br /&gt;
* test basic functionality of review bids controller&lt;br /&gt;
* test basic functionality of review bid model&lt;br /&gt;
&lt;br /&gt;
==== Directions for RSpec Testing ====&lt;br /&gt;
:# on personal device using [https://github.com/ncsu-ngw/expertiza forked repo]&lt;br /&gt;
:# Run the following commands:&lt;br /&gt;
&lt;br /&gt;
 # review bids controller: &lt;br /&gt;
 bundle exec rspec spec/controllers/review_bids_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
 # review bid model: &lt;br /&gt;
 bundle exec rspec spec/models/review_bid_spec.rb&lt;br /&gt;
 &lt;br /&gt;
 # review bidding algorithm service:&lt;br /&gt;
 bundle exec rspec spec/services/review_bidding_algorithm_service_spec.rb&lt;br /&gt;
&lt;br /&gt;
==Test Coverage==&lt;br /&gt;
Code Climate: [https://codeclimate.com/github/expertiza/expertiza/pull/2931 here]&lt;br /&gt;
&lt;br /&gt;
[[File:code-climate.png|700px]]&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
&lt;br /&gt;
'''Mentor:''' Janice Uwujaren (juwujar) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ashwin Muniswamy (akumarm) &amp;lt;br&amp;gt;&lt;br /&gt;
Arturo Serdan (aaserdan) &amp;lt;br&amp;gt;&lt;br /&gt;
Nicholas Winsen (nwinsen) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====''Previous Implementations''=====&lt;br /&gt;
Fall 2019 [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Spring 2020 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2020 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2024 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2508._Reimplement_bidding-algorithm_web_service here]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====''Relevant Links''=====&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/2931 &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
''Video Demo'': https://app.screencast.com/vaiJnWpHf0r07&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162648</id>
		<title>CSC/ECE 517 Spring 2025 - E2508. Reimplement bidding-algorithm web service</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162648"/>
		<updated>2025-03-25T02:05:50Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Project Overview==&lt;br /&gt;
===   ''Background''   ===&lt;br /&gt;
The previous implementation of the bidding service was hosted on peerlogic by a former student. The University no longer has access to this hosting service, and  is requiring a new solution. It is also asked that the webservice accept a better and cleaner json format which is easier to interpret and read.&lt;br /&gt;
&lt;br /&gt;
===   ''Objectives''   ===&lt;br /&gt;
# Reimplement trading cycles on a webservice&lt;br /&gt;
# Figure out a new hosting solution for the BiddingService web service. (VCL)&lt;br /&gt;
# Host the webservice on VCL&lt;br /&gt;
# Using tmux, figure out a way to keep the process running with a production wsgi service compatible with Flask.&lt;br /&gt;
# Create new tests for the repository&lt;br /&gt;
# Create a list of required packages that future maintainers can install easily&lt;br /&gt;
# Create a tests directory that users can test the functionality of the code with&lt;br /&gt;
# Modularize the code further, eliminate code smells.&lt;br /&gt;
# Refactor existing backend logic to account for the new json format&lt;br /&gt;
# Refactor existing backend code to send HTTP requests to the correct IP address&lt;br /&gt;
# Refactor existing frontend code to provide a list for users to select multiple topics on the frontend&lt;br /&gt;
# Allow users to prioritize their topic selection on the frontend&lt;br /&gt;
# Users should not be allowed to bid on their review topics on the frontend&lt;br /&gt;
# Display the results of the matched topics on the frontend&lt;br /&gt;
&lt;br /&gt;
===   ''Previous Work''   ===&lt;br /&gt;
There have been three previous implementations: &amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2019 [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Spring 2020 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2020 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2024 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2508._Reimplement_bidding-algorithm_web_service here]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/2931 &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Files Modified''   ===&lt;br /&gt;
This is a list of all the files added or changed in completing this project. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Changed'': &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/app.py - accomodated for changes in JsonParser&lt;br /&gt;
*app/json_parser.py - moved functions out due to SRP&lt;br /&gt;
*app/topics_matcher.py&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Added'': &amp;lt;br&amp;gt;&lt;br /&gt;
*app/tests/sample.json &amp;lt;br&amp;gt; - Sample input for the tests.&lt;br /&gt;
&lt;br /&gt;
*app/tests/test_assignment.py &amp;lt;br&amp;gt; Test File to test forms of input - tests both a successful and unsuccessful input&lt;br /&gt;
&lt;br /&gt;
*app/utils/popular_topics.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/student_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/topic_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
&lt;br /&gt;
*setup.py - required for wsgi&lt;br /&gt;
*wsgi.py - for hosting the server via gunicorn on VCL.&lt;br /&gt;
*.gitignore - to ignore anything that we may not want pushed (mostly for venv)&lt;br /&gt;
*requirements.txt - a list of requirements made easy for future maintainers&lt;br /&gt;
&lt;br /&gt;
=== ''Webservice'' ===&lt;br /&gt;
===== ''app'' =====&lt;br /&gt;
&lt;br /&gt;
The entry point to the Web service is the app.py file where we have the POST Method match_topics.&lt;br /&gt;
This receives the input in a json format from Expertiza. The input will contain a list of task ids, and then an Object of users, which each contain their student id and correlated bids that they made. Each bid contains a task id, a priority, and a timestamp. The input format was reworked to align to this style since it made more sense to have each student have a list of bids instead of the previous implementation which did not have this case. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:App2508.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''json parser'' =====&lt;br /&gt;
The json parser converts the json into a Dictionary. The previous implementation also had the parser create a preferences dictionary for the Student to store their topic preferences and one for Topics to store list of topics which have been selected by students and also the priority for the selection using the Timestamps. However, this was removed due to the Single Responsibility Principle. We felt the json parser was doing too much and should only be parsing the json!&lt;br /&gt;
&lt;br /&gt;
[[File:init_parser.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The student priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:student_prio.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The topic priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:topic_priorities.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== ''Test Input'' =====&lt;br /&gt;
&lt;br /&gt;
Sample Test case:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Case:&amp;lt;/b&amp;gt; There are a few very popular topics and the students who bid for them and bid early should receive it.&lt;br /&gt;
Popular Topics: 3969, 3971, 3972&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;tid&amp;quot;: [4427, 4428, 4429, 4430],&lt;br /&gt;
    &amp;quot;users&amp;quot;: {&lt;br /&gt;
      &amp;quot;40763&amp;quot;: {&lt;br /&gt;
          &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4429&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40764&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4427&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40765&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:15 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:16 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:17 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4428&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;max_accepted_proposals&amp;quot;: 3&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''Output'' =====&lt;br /&gt;
&lt;br /&gt;
 Since there is competition for these topics, the algorithm recognizes this and makes sure to assign them only to the students who bid for it.&lt;br /&gt;
		Other students who picked other topics or did not pick anything are assigned different topics.&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
    &amp;quot;40763&amp;quot;: [&lt;br /&gt;
        4427,&lt;br /&gt;
        4428,&lt;br /&gt;
        4430&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40764&amp;quot;: [&lt;br /&gt;
        4428,&lt;br /&gt;
        4430,&lt;br /&gt;
        4429&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40765&amp;quot;: [&lt;br /&gt;
        4429,&lt;br /&gt;
        4427,&lt;br /&gt;
        4430&lt;br /&gt;
    ]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== ''Controller'' ===&lt;br /&gt;
&lt;br /&gt;
The controller includes 8 methods that handle the review bidding process. The public methods cover authorization, rendering views, saving user bids, and coordinating review assignment. The private methods support these functions by abstracting data gathering and algorithm coordination logic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Method: action_allowed? ======&lt;br /&gt;
&lt;br /&gt;
This method controls user access to controller actions. It allows 'Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator', and 'Student' roles to access show, set_priority, and index. Other actions are restricted to non-student roles. It ensures proper permissions for accessing review bidding features.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: index ======&lt;br /&gt;
&lt;br /&gt;
This method gathers information for the &amp;quot;Your Work&amp;quot; page, where users can view their assigned reviews. It checks user identity, retrieves associated reviews, and counts completed reviews. The view rendered is sign_up_sheet/review_bids_others_work.View: others_work.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_index.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: show ======&lt;br /&gt;
&lt;br /&gt;
This method renders the bidding page where users select topics they'd prefer to review. It fetches the assignment, available topics, and any existing bids. Already assigned or signed-up topics are excluded. The page also lists any assigned reviews.View: show.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_show.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: set_priority ======&lt;br /&gt;
&lt;br /&gt;
This method stores or updates a participant's topic preferences. It removes old bids not in the current selection and creates or updates the remaining bids with new priorities. This method is triggered when users submit their topic rankings on the bidding page.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_set_priority.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_bidding ======&lt;br /&gt;
&lt;br /&gt;
This method coordinates the assignment of review topics. It gathers reviewer IDs and invokes the bidding algorithm using a service. It validates the output and uses ReviewBid.assign_review_topics to perform the actual assignment. Bidding is then disabled.&lt;br /&gt;
&lt;br /&gt;
[[File:Assign_bidding.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: fetch_reviewer_ids (Private) ======&lt;br /&gt;
&lt;br /&gt;
This helper method retrieves all AssignmentParticipant IDs for a given assignment. These IDs represent the reviewers participating in the bidding process.&lt;br /&gt;
&lt;br /&gt;
====== Method: process_bidding (Private) ======&lt;br /&gt;
This helper method delegates the logic for running the bidding algorithm to the service class ReviewBiddingAlgorithmService. It takes the assignment ID and list of reviewers as input and returns matched topic assignments.&lt;br /&gt;
&lt;br /&gt;
====== Method: ensure_valid_topics (Private) ======&lt;br /&gt;
This method ensures that all reviewers have valid topic assignment entries, even if the algorithm returns nothing (e.g., due to web service failure). It initializes empty topic arrays for any missing reviewers.&lt;br /&gt;
&lt;br /&gt;
[[File:Controller_private_methods.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== ''Model'' ===&lt;br /&gt;
&lt;br /&gt;
The controller includes 8 methods that handle the review bidding process. The public methods cover authorization, rendering views, saving user bids, and coordinating review assignment. The private methods support these functions by abstracting data gathering and algorithm coordination logic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Method: action_allowed? ======&lt;br /&gt;
&lt;br /&gt;
This method controls user access to controller actions. It allows 'Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator', and 'Student' roles to access show, set_priority, and index. Other actions are restricted to non-student roles. It ensures proper permissions for accessing review bidding features.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: index ======&lt;br /&gt;
&lt;br /&gt;
This method controls user access to controller actions. It allows 'Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator', and 'Student' roles to access show, set_priority, and index. Other actions are restricted to non-student roles. It ensures proper permissions for accessing review bidding features.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: index ======&lt;br /&gt;
&lt;br /&gt;
This method controls user access to controller actions. It allows 'Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator', and 'Student' roles to access show, set_priority, and index. Other actions are restricted to non-student roles. It ensures proper permissions for accessing review bidding features.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: index ======&lt;br /&gt;
&lt;br /&gt;
This method controls user access to controller actions. It allows 'Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator', and 'Student' roles to access show, set_priority, and index. Other actions are restricted to non-student roles. It ensures proper permissions for accessing review bidding features.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method private: index ======&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== ''Service'' ===&lt;br /&gt;
&lt;br /&gt;
The ReviewBiddingAlgorithmService is a service object responsible for handling communication between the application and the external web service that executes the review bidding algorithm. It prepares bidding data, sends it to the web service, processes the response, and provides a fallback mechanism in case of failure.&lt;br /&gt;
&lt;br /&gt;
This service allows to encapsulate all logic required to interact with the external topic-matching web service. It separates the algorithm execution concerns from the controller, improving modularity, testability, and maintainability of the code.&lt;br /&gt;
&lt;br /&gt;
====== Method: self.process_bidding ======&lt;br /&gt;
&lt;br /&gt;
This is the primary entry point for the controller. It accepts the assignment_id and a list of reviewer_ids, then prepares the bidding data by calling ReviewBid.bidding_data(...). It passes the data to the web service by calling run_bidding_algorithm. If the web service is unavailable or fails, the method logs an error and falls back to an internal method: ReviewBid.fallback_algorithm. The result is returned as a hash mapping reviewer IDs to arrays of assigned topic IDs.&lt;br /&gt;
&lt;br /&gt;
====== Method: self.run_bidding_algorithm ======&lt;br /&gt;
&lt;br /&gt;
This method retrieves the review bidding web service URL from the app configuration (config/webservices.yml) and calls the internal send_bidding_request method to make the actual request.It logs the outgoing URL for debugging and delegates the response parsing.&lt;br /&gt;
&lt;br /&gt;
====== Private Method: send_bidding_request ======&lt;br /&gt;
&lt;br /&gt;
This private class method handles the HTTP POST request using RestClient. It sends the bidding data as JSON and expects a JSON response. If the request fails due to a connection error, server error, or timeout, the method logs the exception and returns false, allowing the caller to trigger a fallback.&lt;br /&gt;
&lt;br /&gt;
[[File:Review_bidding_algorithm_service.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Fallback Algorithm ===&lt;br /&gt;
=====   ''Introduction''   =====&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm in Expertiza is designed to ensure automatic topic assignment when the primary Bidding Algorithm fails due to Web Service unavailability.  &lt;br /&gt;
&lt;br /&gt;
Normally, Expertiza allows reviewers to bid on topics, and the ''ReviewBiddingAlgorithmService'' processes these bids to assign topics. However, when this web service ''fails'' (due to API downtime, server issues, or unexpected errors), the system must switch to fallback and automatically assign topics to reviewers.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Solution''   =====&lt;br /&gt;
It is triggered when the web service is unavailable. It ensures fair topic assignment by:  &lt;br /&gt;
* Prioritizing topics with the largest teams.  &lt;br /&gt;
* Using a round-robin approach to distribute topics among reviewers.  &lt;br /&gt;
* Ensuring reviewers do not get their own team’s topic.  &lt;br /&gt;
&lt;br /&gt;
=====   ''When is this Used?''  ===== &lt;br /&gt;
* The ReviewBiddingAlgorithmService fails due to an API issue.  &lt;br /&gt;
* The web service times out or returns an error.  &lt;br /&gt;
* Unexpected exceptions occur in the bidding process.  &lt;br /&gt;
&lt;br /&gt;
Instead of stopping the review process, the system automatically falls-back to an internal algorithm to distribute topics.  &lt;br /&gt;
&lt;br /&gt;
=====   ''How Does the Fallback Algorithm Work?''   ===== &lt;br /&gt;
The algorithm follows these **four main steps:  &lt;br /&gt;
* Fetch available topics – Retrieves all topics for the given assignment.  &lt;br /&gt;
* Sort topics by team size – Topics with more members are given priority.  &lt;br /&gt;
* Create a topic queue – Topics are arranged in descending order of team size.  &lt;br /&gt;
* Assign topics in a round-robin manner – Reviewers are assigned topics while avoiding their own team's topic.  &lt;br /&gt;
&lt;br /&gt;
This ensures ''fair and balanced'' distribution of topics.&lt;br /&gt;
  &lt;br /&gt;
=====   ''Implementation - Controller Code (Triggering the Fallback)''   =====&lt;br /&gt;
If the primary bidding service fails, the system catches the error and calls the Fallback Algorithm.&lt;br /&gt;
&lt;br /&gt;
[[File:Controller-code.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: If ''ReviewBiddingAlgorithmService'' fails, the system automatically calls fallback_algorithm.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Implementation - Model Code (Fallback Algorithm)''   =====&lt;br /&gt;
This method ensures fair topic assignment when the bidding system fails.&lt;br /&gt;
&lt;br /&gt;
[[File:Model-code.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: This function ensures every reviewer receives a topic without requiring manual intervention.&lt;br /&gt;
&lt;br /&gt;
=====   ''RSpec Testing of Fallback Algorithm''   =====&lt;br /&gt;
To verify correctness, we use unit tests in ''review_bid_spec.rb''&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm ensures that ''topics are assigned fairly'' even when the primary bidding service fails. By prioritizing ''larger teams'', ''avoiding self-review'', and using a ''round-robin strategy'', the fallback mechanism keeps the review process smooth and automatic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
This section outlines the test plan for this project including testing scenarios/edge cases, the manual testing plan, and the automatic/RSpec testing plan.&lt;br /&gt;
&lt;br /&gt;
=== ''Testing Scenarios'' ===&lt;br /&gt;
This section outlines the various bidding scenarios that could occur. These scenarios should be tested in either '''Manual Testing''' or '''Automatic Testing'''.&lt;br /&gt;
&lt;br /&gt;
==== Basic Bidding Scenario ====&lt;br /&gt;
*Reviewers bid on multiple projects at different times&lt;br /&gt;
** Bidding algorithm should give priority to reviewers that bid first and should assign based on reviewers ranking&lt;br /&gt;
&lt;br /&gt;
====   Edge Cases   ====&lt;br /&gt;
* All reviewers bid on the same project&lt;br /&gt;
** If different time stamps: bidding algorithm should give priority to reviewers that bid first&lt;br /&gt;
** If same time stamps: bidding algorithm should assign reviews randomly&lt;br /&gt;
* None of the reviews bid on any projects&lt;br /&gt;
** Bidding algorithm should assign reviews randomly&lt;br /&gt;
* Reviewer bids on their own project&lt;br /&gt;
** Bidding algorithm should not allow a reviewer to bid on their own project and should have validation to prevent assigning a reviewer their own project&lt;br /&gt;
* None of the reviewers bid on a specific project&lt;br /&gt;
** Bidding algorithm should still assign reviewers to this project&lt;br /&gt;
&lt;br /&gt;
===   ''Manual Testing''   ===&lt;br /&gt;
Manual testing should be preformed on an Expertiza server and webserver platform &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Plan for Expertiza Server ====&lt;br /&gt;
* test that an instructor can allow review bidding for an assignment&lt;br /&gt;
* test that server routes correctly when review bidding is allowed&lt;br /&gt;
** test that task box links to bidding page before algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to bidding page before algorithm is run&lt;br /&gt;
** test that task box links to review page with bidding information after algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to review page with bidding information after algorithm is run&lt;br /&gt;
* test that the bidding UI is implemented as expected&lt;br /&gt;
* test that a participant can bid on projects to review&lt;br /&gt;
** test that a participant can move projects into the bidding column&lt;br /&gt;
** test that a participant can reorder projects in the bidding column&lt;br /&gt;
** test that a participant's bidding preferences save&lt;br /&gt;
** test that a participant can't bid for their own topic&lt;br /&gt;
* test that run algorithm button calls webserver with correct information and returns review assignments for each user&lt;br /&gt;
&lt;br /&gt;
==== Directions for Manual Testing of Expertiza Server ====&lt;br /&gt;
1. Go to [http://152.7.99.70:8081/ testing server] &amp;lt;br&amp;gt;&lt;br /&gt;
2. Log in as username: '''instructor6''' password: '''password''' &amp;lt;br&amp;gt;&lt;br /&gt;
3. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''General''' tab make sure '''Has teams?''' and '''Has topics?''' are checked&lt;br /&gt;
:# In the '''Topics''' tab check '''Allow review to choose which topic to review?''' then click '''save'''&lt;br /&gt;
:# In the '''Topics''' tab select '''Bidding''' then click '''save'''&lt;br /&gt;
4. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# This UI is based on '''instructor6''' being a '''participant''' assigned to topic '''Topic4'''&lt;br /&gt;
::# The UI blocks user from bidding on their own project &lt;br /&gt;
::# Check that user can bid on topics and reorder bids&lt;br /&gt;
::# Check that users topic preferences save on page refresh&lt;br /&gt;
::# Impersonate other participants and repeat bidding UI tests ('''student7601''', '''student7602''', '''student7603''', '''student7604''', '''student7605''', '''student7606''', '''student7607''', '''student7608''', '''student7609'')&lt;br /&gt;
5. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''Topics''' tab click '''Run Review Algorithm''' button&lt;br /&gt;
6. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# '''E2085 Manual Testing review''' should now link to the reviewing page&lt;br /&gt;
::# The number of required reviews should already be displayed&lt;br /&gt;
::# A '''Request Another Review''' button should be present unless reviews listed is equal to the number of reviews allowed&lt;br /&gt;
::# '''Begin''' a review and test '''save''' and '''submit'''&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Demo Video for Expertiza Server ====&lt;br /&gt;
Video demonstration of manual testing: [https://www.screencast.com/t/0rSg1zDW here]&lt;br /&gt;
&lt;br /&gt;
=== ''Automatic/PyTest Testing '' ===&lt;br /&gt;
Pytest tests are written for the webservice to test a well formed and a malformed request.&lt;br /&gt;
&lt;br /&gt;
===   ''Automatic/RSpec Testing ''   ===&lt;br /&gt;
RSpec tests will need to be refactored according to the changes that we make in the expertiza repository. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== RSpec Testing Plan ====&lt;br /&gt;
These RSpec tests will need to:&lt;br /&gt;
* test basic functionality of review bids controller&lt;br /&gt;
* test basic functionality of review bid model&lt;br /&gt;
&lt;br /&gt;
==== Directions for RSpec Testing ====&lt;br /&gt;
:# on personal device using [https://github.com/ncsu-ngw/expertiza forked repo]&lt;br /&gt;
:# Run the following commands:&lt;br /&gt;
&lt;br /&gt;
 # review bids controller: &lt;br /&gt;
 bundle exec rspec spec/controllers/review_bids_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
 # review bid model: &lt;br /&gt;
 bundle exec rspec spec/models/review_bid_spec.rb&lt;br /&gt;
 &lt;br /&gt;
 # review bidding algorithm service:&lt;br /&gt;
 bundle exec rspec spec/services/review_bidding_algorithm_service_spec.rb&lt;br /&gt;
&lt;br /&gt;
==Test Coverage==&lt;br /&gt;
Code Climate: [https://codeclimate.com/github/expertiza/expertiza/pull/2931 here]&lt;br /&gt;
&lt;br /&gt;
[[File:code-climate.png|700px]]&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
&lt;br /&gt;
'''Mentor:''' Janice Uwujaren (juwujar) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ashwin Muniswamy (akumarm) &amp;lt;br&amp;gt;&lt;br /&gt;
Arturo Serdan (aaserdan) &amp;lt;br&amp;gt;&lt;br /&gt;
Nicholas Winsen (nwinsen) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====''Previous Implementations''=====&lt;br /&gt;
Fall 2019 [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Spring 2020 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2020 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2024 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2508._Reimplement_bidding-algorithm_web_service here]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====''Relevant Links''=====&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/2931 &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
''Video Demo'': https://app.screencast.com/vaiJnWpHf0r07&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162641</id>
		<title>CSC/ECE 517 Spring 2025 - E2508. Reimplement bidding-algorithm web service</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162641"/>
		<updated>2025-03-25T01:55:15Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Project Overview==&lt;br /&gt;
===   ''Background''   ===&lt;br /&gt;
The previous implementation of the bidding service was hosted on peerlogic by a former student. The University no longer has access to this hosting service, and  is requiring a new solution. It is also asked that the webservice accept a better and cleaner json format which is easier to interpret and read.&lt;br /&gt;
&lt;br /&gt;
===   ''Objectives''   ===&lt;br /&gt;
# Reimplement trading cycles on a webservice&lt;br /&gt;
# Figure out a new hosting solution for the BiddingService web service. (VCL)&lt;br /&gt;
# Host the webservice on VCL&lt;br /&gt;
# Using tmux, figure out a way to keep the process running with a production wsgi service compatible with Flask.&lt;br /&gt;
# Create new tests for the repository&lt;br /&gt;
# Create a list of required packages that future maintainers can install easily&lt;br /&gt;
# Create a tests directory that users can test the functionality of the code with&lt;br /&gt;
# Modularize the code further, eliminate code smells.&lt;br /&gt;
# Refactor existing backend logic to account for the new json format&lt;br /&gt;
# Refactor existing backend code to send HTTP requests to the correct IP address&lt;br /&gt;
# Refactor existing frontend code to provide a list for users to select multiple topics on the frontend&lt;br /&gt;
# Allow users to prioritize their topic selection on the frontend&lt;br /&gt;
# Users should not be allowed to bid on their review topics on the frontend&lt;br /&gt;
# Display the results of the matched topics on the frontend&lt;br /&gt;
&lt;br /&gt;
===   ''Previous Work''   ===&lt;br /&gt;
There have been three previous implementations: &amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2019 [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Spring 2020 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2020 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2024 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2508._Reimplement_bidding-algorithm_web_service here]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/2931 &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Files Modified''   ===&lt;br /&gt;
This is a list of all the files added or changed in completing this project. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Changed'': &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/app.py - accomodated for changes in JsonParser&lt;br /&gt;
*app/json_parser.py - moved functions out due to SRP&lt;br /&gt;
*app/topics_matcher.py&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Added'': &amp;lt;br&amp;gt;&lt;br /&gt;
*app/tests/sample.json &amp;lt;br&amp;gt; - Sample input for the tests.&lt;br /&gt;
&lt;br /&gt;
*app/tests/test_assignment.py &amp;lt;br&amp;gt; Test File to test forms of input - tests both a successful and unsuccessful input&lt;br /&gt;
&lt;br /&gt;
*app/utils/popular_topics.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/student_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/topic_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
&lt;br /&gt;
*setup.py - required for wsgi&lt;br /&gt;
*wsgi.py - for hosting the server via gunicorn on VCL.&lt;br /&gt;
*.gitignore - to ignore anything that we may not want pushed (mostly for venv)&lt;br /&gt;
*requirements.txt - a list of requirements made easy for future maintainers&lt;br /&gt;
&lt;br /&gt;
=== ''Webservice'' ===&lt;br /&gt;
===== ''app'' =====&lt;br /&gt;
&lt;br /&gt;
The entry point to the Web service is the app.py file where we have the POST Method match_topics.&lt;br /&gt;
This receives the input in a json format from Expertiza. The input will contain a list of task ids, and then an Object of users, which each contain their student id and correlated bids that they made. Each bid contains a task id, a priority, and a timestamp. The input format was reworked to align to this style since it made more sense to have each student have a list of bids instead of the previous implementation which did not have this case. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:App2508.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''json parser'' =====&lt;br /&gt;
The json parser converts the json into a Dictionary. The previous implementation also had the parser create a preferences dictionary for the Student to store their topic preferences and one for Topics to store list of topics which have been selected by students and also the priority for the selection using the Timestamps. However, this was removed due to the Single Responsibility Principle. We felt the json parser was doing too much and should only be parsing the json!&lt;br /&gt;
&lt;br /&gt;
[[File:init_parser.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The student priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:student_prio.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The topic priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:topic_priorities.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== ''Test Input'' =====&lt;br /&gt;
&lt;br /&gt;
Sample Test case:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Case:&amp;lt;/b&amp;gt; There are a few very popular topics and the students who bid for them and bid early should receive it.&lt;br /&gt;
Popular Topics: 3969, 3971, 3972&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;tid&amp;quot;: [4427, 4428, 4429, 4430],&lt;br /&gt;
    &amp;quot;users&amp;quot;: {&lt;br /&gt;
      &amp;quot;40763&amp;quot;: {&lt;br /&gt;
          &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4429&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40764&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4427&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40765&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:15 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:16 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:17 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4428&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;max_accepted_proposals&amp;quot;: 3&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''Output'' =====&lt;br /&gt;
&lt;br /&gt;
 Since there is competition for these topics, the algorithm recognizes this and makes sure to assign them only to the students who bid for it.&lt;br /&gt;
		Other students who picked other topics or did not pick anything are assigned different topics.&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
    &amp;quot;40763&amp;quot;: [&lt;br /&gt;
        4427,&lt;br /&gt;
        4428,&lt;br /&gt;
        4430&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40764&amp;quot;: [&lt;br /&gt;
        4428,&lt;br /&gt;
        4430,&lt;br /&gt;
        4429&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40765&amp;quot;: [&lt;br /&gt;
        4429,&lt;br /&gt;
        4427,&lt;br /&gt;
        4430&lt;br /&gt;
    ]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== ''Controller'' ===&lt;br /&gt;
&lt;br /&gt;
The controller includes 8 methods that handle the review bidding process. The public methods cover authorization, rendering views, saving user bids, and coordinating review assignment. The private methods support these functions by abstracting data gathering and algorithm coordination logic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Method: action_allowed? ======&lt;br /&gt;
&lt;br /&gt;
This method controls user access to controller actions. It allows 'Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator', and 'Student' roles to access show, set_priority, and index. Other actions are restricted to non-student roles. It ensures proper permissions for accessing review bidding features.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: index ======&lt;br /&gt;
&lt;br /&gt;
This method gathers information for the &amp;quot;Your Work&amp;quot; page, where users can view their assigned reviews. It checks user identity, retrieves associated reviews, and counts completed reviews. The view rendered is sign_up_sheet/review_bids_others_work.View: others_work.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_index.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: show ======&lt;br /&gt;
&lt;br /&gt;
This method renders the bidding page where users select topics they'd prefer to review. It fetches the assignment, available topics, and any existing bids. Already assigned or signed-up topics are excluded. The page also lists any assigned reviews.View: show.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_show.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: set_priority ======&lt;br /&gt;
&lt;br /&gt;
This method stores or updates a participant's topic preferences. It removes old bids not in the current selection and creates or updates the remaining bids with new priorities. This method is triggered when users submit their topic rankings on the bidding page.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_set_priority.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_bidding ======&lt;br /&gt;
&lt;br /&gt;
This method coordinates the assignment of review topics. It gathers reviewer IDs and invokes the bidding algorithm using a service. It validates the output and uses ReviewBid.assign_review_topics to perform the actual assignment. Bidding is then disabled.&lt;br /&gt;
&lt;br /&gt;
[[File:Assign_bidding.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: fetch_reviewer_ids (Private) ======&lt;br /&gt;
&lt;br /&gt;
This helper method retrieves all AssignmentParticipant IDs for a given assignment. These IDs represent the reviewers participating in the bidding process.&lt;br /&gt;
&lt;br /&gt;
====== Method: process_bidding (Private) ======&lt;br /&gt;
This helper method delegates the logic for running the bidding algorithm to the service class ReviewBiddingAlgorithmService. It takes the assignment ID and list of reviewers as input and returns matched topic assignments.&lt;br /&gt;
&lt;br /&gt;
====== Method: ensure_valid_topics (Private) ======&lt;br /&gt;
This method ensures that all reviewers have valid topic assignment entries, even if the algorithm returns nothing (e.g., due to web service failure). It initializes empty topic arrays for any missing reviewers.&lt;br /&gt;
&lt;br /&gt;
[[File:Controller_private_methods.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
=== ''Service'' ===&lt;br /&gt;
&lt;br /&gt;
The ReviewBiddingAlgorithmService is a service object responsible for handling communication between the application and the external web service that executes the review bidding algorithm. It prepares bidding data, sends it to the web service, processes the response, and provides a fallback mechanism in case of failure.&lt;br /&gt;
&lt;br /&gt;
This service allows to encapsulate all logic required to interact with the external topic-matching web service. It separates the algorithm execution concerns from the controller, improving modularity, testability, and maintainability of the code.&lt;br /&gt;
&lt;br /&gt;
====== Method: self.process_bidding ======&lt;br /&gt;
&lt;br /&gt;
This is the primary entry point for the controller. It accepts the assignment_id and a list of reviewer_ids, then prepares the bidding data by calling ReviewBid.bidding_data(...). It passes the data to the web service by calling run_bidding_algorithm. If the web service is unavailable or fails, the method logs an error and falls back to an internal method: ReviewBid.fallback_algorithm. The result is returned as a hash mapping reviewer IDs to arrays of assigned topic IDs.&lt;br /&gt;
&lt;br /&gt;
====== Method: self.run_bidding_algorithm ======&lt;br /&gt;
&lt;br /&gt;
This method retrieves the review bidding web service URL from the app configuration (config/webservices.yml) and calls the internal send_bidding_request method to make the actual request.It logs the outgoing URL for debugging and delegates the response parsing.&lt;br /&gt;
&lt;br /&gt;
====== Private Method: send_bidding_request ======&lt;br /&gt;
&lt;br /&gt;
This private class method handles the HTTP POST request using RestClient. It sends the bidding data as JSON and expects a JSON response. If the request fails due to a connection error, server error, or timeout, the method logs the exception and returns false, allowing the caller to trigger a fallback.&lt;br /&gt;
&lt;br /&gt;
[[File:Review_bidding_algorithm_service.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Fallback Algorithm ===&lt;br /&gt;
=====   ''Introduction''   =====&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm in Expertiza is designed to ensure automatic topic assignment when the primary Bidding Algorithm fails due to Web Service unavailability.  &lt;br /&gt;
&lt;br /&gt;
Normally, Expertiza allows reviewers to bid on topics, and the ''ReviewBiddingAlgorithmService'' processes these bids to assign topics. However, when this web service ''fails'' (due to API downtime, server issues, or unexpected errors), the system must switch to fallback and automatically assign topics to reviewers.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Solution''   =====&lt;br /&gt;
It is triggered when the web service is unavailable. It ensures fair topic assignment by:  &lt;br /&gt;
* Prioritizing topics with the largest teams.  &lt;br /&gt;
* Using a round-robin approach to distribute topics among reviewers.  &lt;br /&gt;
* Ensuring reviewers do not get their own team’s topic.  &lt;br /&gt;
&lt;br /&gt;
=====   ''When is this Used?''  ===== &lt;br /&gt;
* The ReviewBiddingAlgorithmService fails due to an API issue.  &lt;br /&gt;
* The web service times out or returns an error.  &lt;br /&gt;
* Unexpected exceptions occur in the bidding process.  &lt;br /&gt;
&lt;br /&gt;
Instead of stopping the review process, the system automatically falls-back to an internal algorithm to distribute topics.  &lt;br /&gt;
&lt;br /&gt;
=====   ''How Does the Fallback Algorithm Work?''   ===== &lt;br /&gt;
The algorithm follows these **four main steps:  &lt;br /&gt;
* Fetch available topics – Retrieves all topics for the given assignment.  &lt;br /&gt;
* Sort topics by team size – Topics with more members are given priority.  &lt;br /&gt;
* Create a topic queue – Topics are arranged in descending order of team size.  &lt;br /&gt;
* Assign topics in a round-robin manner – Reviewers are assigned topics while avoiding their own team's topic.  &lt;br /&gt;
&lt;br /&gt;
This ensures ''fair and balanced'' distribution of topics.&lt;br /&gt;
  &lt;br /&gt;
=====   ''Implementation - Controller Code (Triggering the Fallback)''   =====&lt;br /&gt;
If the primary bidding service fails, the system catches the error and calls the Fallback Algorithm.&lt;br /&gt;
&lt;br /&gt;
[[File:Controller-code.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: If ''ReviewBiddingAlgorithmService'' fails, the system automatically calls fallback_algorithm.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Implementation - Model Code (Fallback Algorithm)''   =====&lt;br /&gt;
This method ensures fair topic assignment when the bidding system fails.&lt;br /&gt;
&lt;br /&gt;
[[File:Model-code.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: This function ensures every reviewer receives a topic without requiring manual intervention.&lt;br /&gt;
&lt;br /&gt;
=====   ''RSpec Testing of Fallback Algorithm''   =====&lt;br /&gt;
To verify correctness, we use unit tests in ''review_bid_spec.rb''&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm ensures that ''topics are assigned fairly'' even when the primary bidding service fails. By prioritizing ''larger teams'', ''avoiding self-review'', and using a ''round-robin strategy'', the fallback mechanism keeps the review process smooth and automatic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
This section outlines the test plan for this project including testing scenarios/edge cases, the manual testing plan, and the automatic/RSpec testing plan.&lt;br /&gt;
&lt;br /&gt;
=== ''Testing Scenarios'' ===&lt;br /&gt;
This section outlines the various bidding scenarios that could occur. These scenarios should be tested in either '''Manual Testing''' or '''Automatic Testing'''.&lt;br /&gt;
&lt;br /&gt;
==== Basic Bidding Scenario ====&lt;br /&gt;
*Reviewers bid on multiple projects at different times&lt;br /&gt;
** Bidding algorithm should give priority to reviewers that bid first and should assign based on reviewers ranking&lt;br /&gt;
&lt;br /&gt;
====   Edge Cases   ====&lt;br /&gt;
* All reviewers bid on the same project&lt;br /&gt;
** If different time stamps: bidding algorithm should give priority to reviewers that bid first&lt;br /&gt;
** If same time stamps: bidding algorithm should assign reviews randomly&lt;br /&gt;
* None of the reviews bid on any projects&lt;br /&gt;
** Bidding algorithm should assign reviews randomly&lt;br /&gt;
* Reviewer bids on their own project&lt;br /&gt;
** Bidding algorithm should not allow a reviewer to bid on their own project and should have validation to prevent assigning a reviewer their own project&lt;br /&gt;
* None of the reviewers bid on a specific project&lt;br /&gt;
** Bidding algorithm should still assign reviewers to this project&lt;br /&gt;
&lt;br /&gt;
===   ''Manual Testing''   ===&lt;br /&gt;
Manual testing should be preformed on an Expertiza server and webserver platform &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Plan for Expertiza Server ====&lt;br /&gt;
* test that an instructor can allow review bidding for an assignment&lt;br /&gt;
* test that server routes correctly when review bidding is allowed&lt;br /&gt;
** test that task box links to bidding page before algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to bidding page before algorithm is run&lt;br /&gt;
** test that task box links to review page with bidding information after algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to review page with bidding information after algorithm is run&lt;br /&gt;
* test that the bidding UI is implemented as expected&lt;br /&gt;
* test that a participant can bid on projects to review&lt;br /&gt;
** test that a participant can move projects into the bidding column&lt;br /&gt;
** test that a participant can reorder projects in the bidding column&lt;br /&gt;
** test that a participant's bidding preferences save&lt;br /&gt;
** test that a participant can't bid for their own topic&lt;br /&gt;
* test that run algorithm button calls webserver with correct information and returns review assignments for each user&lt;br /&gt;
&lt;br /&gt;
==== Directions for Manual Testing of Expertiza Server ====&lt;br /&gt;
1. Go to [http://152.7.99.70:8081/ testing server] &amp;lt;br&amp;gt;&lt;br /&gt;
2. Log in as username: '''instructor6''' password: '''password''' &amp;lt;br&amp;gt;&lt;br /&gt;
3. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''General''' tab make sure '''Has teams?''' and '''Has topics?''' are checked&lt;br /&gt;
:# In the '''Topics''' tab check '''Allow review to choose which topic to review?''' then click '''save'''&lt;br /&gt;
:# In the '''Topics''' tab select '''Bidding''' then click '''save'''&lt;br /&gt;
4. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# This UI is based on '''instructor6''' being a '''participant''' assigned to topic '''Topic4'''&lt;br /&gt;
::# The UI blocks user from bidding on their own project &lt;br /&gt;
::# Check that user can bid on topics and reorder bids&lt;br /&gt;
::# Check that users topic preferences save on page refresh&lt;br /&gt;
::# Impersonate other participants and repeat bidding UI tests ('''student7601''', '''student7602''', '''student7603''', '''student7604''', '''student7605''', '''student7606''', '''student7607''', '''student7608''', '''student7609'')&lt;br /&gt;
5. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''Topics''' tab click '''Run Review Algorithm''' button&lt;br /&gt;
6. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# '''E2085 Manual Testing review''' should now link to the reviewing page&lt;br /&gt;
::# The number of required reviews should already be displayed&lt;br /&gt;
::# A '''Request Another Review''' button should be present unless reviews listed is equal to the number of reviews allowed&lt;br /&gt;
::# '''Begin''' a review and test '''save''' and '''submit'''&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Demo Video for Expertiza Server ====&lt;br /&gt;
Video demonstration of manual testing: [https://www.screencast.com/t/0rSg1zDW here]&lt;br /&gt;
&lt;br /&gt;
=== ''Automatic/PyTest Testing '' ===&lt;br /&gt;
Pytest tests are written for the webservice to test a well formed and a malformed request.&lt;br /&gt;
&lt;br /&gt;
===   ''Automatic/RSpec Testing ''   ===&lt;br /&gt;
RSpec tests will need to be refactored according to the changes that we make in the expertiza repository. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== RSpec Testing Plan ====&lt;br /&gt;
These RSpec tests will need to:&lt;br /&gt;
* test basic functionality of review bids controller&lt;br /&gt;
* test basic functionality of review bid model&lt;br /&gt;
&lt;br /&gt;
==== Directions for RSpec Testing ====&lt;br /&gt;
:# on personal device using [https://github.com/ncsu-ngw/expertiza forked repo]&lt;br /&gt;
:# Run the following commands:&lt;br /&gt;
&lt;br /&gt;
 # review bids controller: &lt;br /&gt;
 bundle exec rspec spec/controllers/review_bids_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
 # review bid model: &lt;br /&gt;
 bundle exec rspec spec/models/review_bid_spec.rb&lt;br /&gt;
 &lt;br /&gt;
 # review bidding algorithm service:&lt;br /&gt;
 bundle exec rspec spec/services/review_bidding_algorithm_service_spec.rb&lt;br /&gt;
&lt;br /&gt;
==Test Coverage==&lt;br /&gt;
Code Climate: [https://codeclimate.com/github/expertiza/expertiza/pull/2931 here]&lt;br /&gt;
&lt;br /&gt;
[[File:code-climate.png|700px]]&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
&lt;br /&gt;
'''Mentor:''' Janice Uwujaren (juwujar) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ashwin Muniswamy (akumarm) &amp;lt;br&amp;gt;&lt;br /&gt;
Arturo Serdan (aaserdan) &amp;lt;br&amp;gt;&lt;br /&gt;
Nicholas Winsen (nwinsen) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
=====''Previous Implementations''=====&lt;br /&gt;
Fall 2019 [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Spring 2020 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2020 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2024 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2508._Reimplement_bidding-algorithm_web_service here]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====''Relevant Links''=====&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/2931 &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
''Video Demo'': https://app.screencast.com/vaiJnWpHf0r07&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162640</id>
		<title>CSC/ECE 517 Spring 2025 - E2508. Reimplement bidding-algorithm web service</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162640"/>
		<updated>2025-03-25T01:53:58Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Project Overview==&lt;br /&gt;
===   ''Background''   ===&lt;br /&gt;
The previous implementation of the bidding service was hosted on peerlogic by a former student. The University no longer has access to this hosting service, and  is requiring a new solution. It is also asked that the webservice accept a better and cleaner json format which is easier to interpret and read.&lt;br /&gt;
&lt;br /&gt;
===   ''Objectives''   ===&lt;br /&gt;
# Reimplement trading cycles on a webservice&lt;br /&gt;
# Figure out a new hosting solution for the BiddingService web service. (VCL)&lt;br /&gt;
# Host the webservice on VCL&lt;br /&gt;
# Using tmux, figure out a way to keep the process running with a production wsgi service compatible with Flask.&lt;br /&gt;
# Create new tests for the repository&lt;br /&gt;
# Create a list of required packages that future maintainers can install easily&lt;br /&gt;
# Create a tests directory that users can test the functionality of the code with&lt;br /&gt;
# Modularize the code further, eliminate code smells.&lt;br /&gt;
# Refactor existing backend logic to account for the new json format&lt;br /&gt;
# Refactor existing backend code to send HTTP requests to the correct IP address&lt;br /&gt;
# Refactor existing frontend code to provide a list for users to select multiple topics on the frontend&lt;br /&gt;
# Allow users to prioritize their topic selection on the frontend&lt;br /&gt;
# Users should not be allowed to bid on their review topics on the frontend&lt;br /&gt;
# Display the results of the matched topics on the frontend&lt;br /&gt;
&lt;br /&gt;
===   ''Previous Work''   ===&lt;br /&gt;
There have been three previous implementations: &amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2019 [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Spring 2020 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2020 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2024 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2508._Reimplement_bidding-algorithm_web_service here]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/2931 &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Files Modified''   ===&lt;br /&gt;
This is a list of all the files added or changed in completing this project. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Changed'': &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/app.py - accomodated for changes in JsonParser&lt;br /&gt;
*app/json_parser.py - moved functions out due to SRP&lt;br /&gt;
*app/topics_matcher.py&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Added'': &amp;lt;br&amp;gt;&lt;br /&gt;
*app/tests/sample.json &amp;lt;br&amp;gt; - Sample input for the tests.&lt;br /&gt;
&lt;br /&gt;
*app/tests/test_assignment.py &amp;lt;br&amp;gt; Test File to test forms of input - tests both a successful and unsuccessful input&lt;br /&gt;
&lt;br /&gt;
*app/utils/popular_topics.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/student_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/topic_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
&lt;br /&gt;
*setup.py - required for wsgi&lt;br /&gt;
*wsgi.py - for hosting the server via gunicorn on VCL.&lt;br /&gt;
*.gitignore - to ignore anything that we may not want pushed (mostly for venv)&lt;br /&gt;
*requirements.txt - a list of requirements made easy for future maintainers&lt;br /&gt;
&lt;br /&gt;
=== ''Webservice'' ===&lt;br /&gt;
===== ''app'' =====&lt;br /&gt;
&lt;br /&gt;
The entry point to the Web service is the app.py file where we have the POST Method match_topics.&lt;br /&gt;
This receives the input in a json format from Expertiza. The input will contain a list of task ids, and then an Object of users, which each contain their student id and correlated bids that they made. Each bid contains a task id, a priority, and a timestamp. The input format was reworked to align to this style since it made more sense to have each student have a list of bids instead of the previous implementation which did not have this case. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:App2508.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''json parser'' =====&lt;br /&gt;
The json parser converts the json into a Dictionary. The previous implementation also had the parser create a preferences dictionary for the Student to store their topic preferences and one for Topics to store list of topics which have been selected by students and also the priority for the selection using the Timestamps. However, this was removed due to the Single Responsibility Principle. We felt the json parser was doing too much and should only be parsing the json!&lt;br /&gt;
&lt;br /&gt;
[[File:init_parser.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The student priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:student_prio.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The topic priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:topic_priorities.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== ''Test Input'' =====&lt;br /&gt;
&lt;br /&gt;
Sample Test case:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Case:&amp;lt;/b&amp;gt; There are a few very popular topics and the students who bid for them and bid early should receive it.&lt;br /&gt;
Popular Topics: 3969, 3971, 3972&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;tid&amp;quot;: [4427, 4428, 4429, 4430],&lt;br /&gt;
    &amp;quot;users&amp;quot;: {&lt;br /&gt;
      &amp;quot;40763&amp;quot;: {&lt;br /&gt;
          &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4429&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40764&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4427&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40765&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:15 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:16 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:17 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4428&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;max_accepted_proposals&amp;quot;: 3&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''Output'' =====&lt;br /&gt;
&lt;br /&gt;
 Since there is competition for these topics, the algorithm recognizes this and makes sure to assign them only to the students who bid for it.&lt;br /&gt;
		Other students who picked other topics or did not pick anything are assigned different topics.&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
    &amp;quot;40763&amp;quot;: [&lt;br /&gt;
        4427,&lt;br /&gt;
        4428,&lt;br /&gt;
        4430&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40764&amp;quot;: [&lt;br /&gt;
        4428,&lt;br /&gt;
        4430,&lt;br /&gt;
        4429&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40765&amp;quot;: [&lt;br /&gt;
        4429,&lt;br /&gt;
        4427,&lt;br /&gt;
        4430&lt;br /&gt;
    ]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== ''Controller'' ===&lt;br /&gt;
&lt;br /&gt;
The controller includes 8 methods that handle the review bidding process. The public methods cover authorization, rendering views, saving user bids, and coordinating review assignment. The private methods support these functions by abstracting data gathering and algorithm coordination logic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Method: action_allowed? ======&lt;br /&gt;
&lt;br /&gt;
This method controls user access to controller actions. It allows 'Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator', and 'Student' roles to access show, set_priority, and index. Other actions are restricted to non-student roles. It ensures proper permissions for accessing review bidding features.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: index ======&lt;br /&gt;
&lt;br /&gt;
This method gathers information for the &amp;quot;Your Work&amp;quot; page, where users can view their assigned reviews. It checks user identity, retrieves associated reviews, and counts completed reviews. The view rendered is sign_up_sheet/review_bids_others_work.View: others_work.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_index.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: show ======&lt;br /&gt;
&lt;br /&gt;
This method renders the bidding page where users select topics they'd prefer to review. It fetches the assignment, available topics, and any existing bids. Already assigned or signed-up topics are excluded. The page also lists any assigned reviews.View: show.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_show.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: set_priority ======&lt;br /&gt;
&lt;br /&gt;
This method stores or updates a participant's topic preferences. It removes old bids not in the current selection and creates or updates the remaining bids with new priorities. This method is triggered when users submit their topic rankings on the bidding page.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_set_priority.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_bidding ======&lt;br /&gt;
&lt;br /&gt;
This method coordinates the assignment of review topics. It gathers reviewer IDs and invokes the bidding algorithm using a service. It validates the output and uses ReviewBid.assign_review_topics to perform the actual assignment. Bidding is then disabled.&lt;br /&gt;
&lt;br /&gt;
[[File:Assign_bidding.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: fetch_reviewer_ids (Private) ======&lt;br /&gt;
&lt;br /&gt;
This helper method retrieves all AssignmentParticipant IDs for a given assignment. These IDs represent the reviewers participating in the bidding process.&lt;br /&gt;
&lt;br /&gt;
====== Method: process_bidding (Private) ======&lt;br /&gt;
This helper method delegates the logic for running the bidding algorithm to the service class ReviewBiddingAlgorithmService. It takes the assignment ID and list of reviewers as input and returns matched topic assignments.&lt;br /&gt;
&lt;br /&gt;
====== Method: ensure_valid_topics (Private) ======&lt;br /&gt;
This method ensures that all reviewers have valid topic assignment entries, even if the algorithm returns nothing (e.g., due to web service failure). It initializes empty topic arrays for any missing reviewers.&lt;br /&gt;
&lt;br /&gt;
[[File:Controller_private_methods.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
=== ''Service'' ===&lt;br /&gt;
&lt;br /&gt;
The ReviewBiddingAlgorithmService is a service object responsible for handling communication between the application and the external web service that executes the review bidding algorithm. It prepares bidding data, sends it to the web service, processes the response, and provides a fallback mechanism in case of failure.&lt;br /&gt;
&lt;br /&gt;
This service allows to encapsulate all logic required to interact with the external topic-matching web service. It separates the algorithm execution concerns from the controller, improving modularity, testability, and maintainability of the code.&lt;br /&gt;
&lt;br /&gt;
====== Method: self.process_bidding ======&lt;br /&gt;
&lt;br /&gt;
This is the primary entry point for the controller. It accepts the assignment_id and a list of reviewer_ids, then prepares the bidding data by calling ReviewBid.bidding_data(...). It passes the data to the web service by calling run_bidding_algorithm. If the web service is unavailable or fails, the method logs an error and falls back to an internal method: ReviewBid.fallback_algorithm. The result is returned as a hash mapping reviewer IDs to arrays of assigned topic IDs.&lt;br /&gt;
&lt;br /&gt;
====== Method: self.run_bidding_algorithm ======&lt;br /&gt;
&lt;br /&gt;
This method retrieves the review bidding web service URL from the app configuration (config/webservices.yml) and calls the internal send_bidding_request method to make the actual request.It logs the outgoing URL for debugging and delegates the response parsing.&lt;br /&gt;
&lt;br /&gt;
====== Private Method: send_bidding_request ======&lt;br /&gt;
&lt;br /&gt;
This private class method handles the HTTP POST request using RestClient. It sends the bidding data as JSON and expects a JSON response. If the request fails due to a connection error, server error, or timeout, the method logs the exception and returns false, allowing the caller to trigger a fallback.&lt;br /&gt;
&lt;br /&gt;
[[File:Review_bidding_algorithm_service.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Fallback Algorithm ===&lt;br /&gt;
=====   ''Introduction''   =====&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm in Expertiza is designed to ensure automatic topic assignment when the primary Bidding Algorithm fails due to Web Service unavailability.  &lt;br /&gt;
&lt;br /&gt;
Normally, Expertiza allows reviewers to bid on topics, and the ''ReviewBiddingAlgorithmService'' processes these bids to assign topics. However, when this web service ''fails'' (due to API downtime, server issues, or unexpected errors), the system must switch to fallback and automatically assign topics to reviewers.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Solution''   =====&lt;br /&gt;
It is triggered when the web service is unavailable. It ensures fair topic assignment by:  &lt;br /&gt;
* Prioritizing topics with the largest teams.  &lt;br /&gt;
* Using a round-robin approach to distribute topics among reviewers.  &lt;br /&gt;
* Ensuring reviewers do not get their own team’s topic.  &lt;br /&gt;
&lt;br /&gt;
=====   ''When is this Used?''  ===== &lt;br /&gt;
* The ReviewBiddingAlgorithmService fails due to an API issue.  &lt;br /&gt;
* The web service times out or returns an error.  &lt;br /&gt;
* Unexpected exceptions occur in the bidding process.  &lt;br /&gt;
&lt;br /&gt;
Instead of stopping the review process, the system automatically falls-back to an internal algorithm to distribute topics.  &lt;br /&gt;
&lt;br /&gt;
=====   ''How Does the Fallback Algorithm Work?''   ===== &lt;br /&gt;
The algorithm follows these **four main steps:  &lt;br /&gt;
* Fetch available topics – Retrieves all topics for the given assignment.  &lt;br /&gt;
* Sort topics by team size – Topics with more members are given priority.  &lt;br /&gt;
* Create a topic queue – Topics are arranged in descending order of team size.  &lt;br /&gt;
* Assign topics in a round-robin manner – Reviewers are assigned topics while avoiding their own team's topic.  &lt;br /&gt;
&lt;br /&gt;
This ensures ''fair and balanced'' distribution of topics.&lt;br /&gt;
  &lt;br /&gt;
=====   ''Implementation - Controller Code (Triggering the Fallback)''   =====&lt;br /&gt;
If the primary bidding service fails, the system catches the error and calls the Fallback Algorithm.&lt;br /&gt;
&lt;br /&gt;
[[File:Controller-code.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: If ''ReviewBiddingAlgorithmService'' fails, the system automatically calls fallback_algorithm.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Implementation - Model Code (Fallback Algorithm)''   =====&lt;br /&gt;
This method ensures fair topic assignment when the bidding system fails.&lt;br /&gt;
&lt;br /&gt;
[[File:Model-code.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: This function ensures every reviewer receives a topic without requiring manual intervention.&lt;br /&gt;
&lt;br /&gt;
=====   ''RSpec Testing of Fallback Algorithm''   =====&lt;br /&gt;
To verify correctness, we use unit tests in ''review_bid_spec.rb''&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm ensures that ''topics are assigned fairly'' even when the primary bidding service fails. By prioritizing ''larger teams'', ''avoiding self-review'', and using a ''round-robin strategy'', the fallback mechanism keeps the review process smooth and automatic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
This section outlines the test plan for this project including testing scenarios/edge cases, the manual testing plan, and the automatic/RSpec testing plan.&lt;br /&gt;
&lt;br /&gt;
=== ''Testing Scenarios'' ===&lt;br /&gt;
This section outlines the various bidding scenarios that could occur. These scenarios should be tested in either '''Manual Testing''' or '''Automatic Testing'''.&lt;br /&gt;
&lt;br /&gt;
==== Basic Bidding Scenario ====&lt;br /&gt;
*Reviewers bid on multiple projects at different times&lt;br /&gt;
** Bidding algorithm should give priority to reviewers that bid first and should assign based on reviewers ranking&lt;br /&gt;
&lt;br /&gt;
====   Edge Cases   ====&lt;br /&gt;
* All reviewers bid on the same project&lt;br /&gt;
** If different time stamps: bidding algorithm should give priority to reviewers that bid first&lt;br /&gt;
** If same time stamps: bidding algorithm should assign reviews randomly&lt;br /&gt;
* None of the reviews bid on any projects&lt;br /&gt;
** Bidding algorithm should assign reviews randomly&lt;br /&gt;
* Reviewer bids on their own project&lt;br /&gt;
** Bidding algorithm should not allow a reviewer to bid on their own project and should have validation to prevent assigning a reviewer their own project&lt;br /&gt;
* None of the reviewers bid on a specific project&lt;br /&gt;
** Bidding algorithm should still assign reviewers to this project&lt;br /&gt;
&lt;br /&gt;
===   ''Manual Testing''   ===&lt;br /&gt;
Manual testing should be preformed on an Expertiza server and webserver platform &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Plan for Expertiza Server ====&lt;br /&gt;
* test that an instructor can allow review bidding for an assignment&lt;br /&gt;
* test that server routes correctly when review bidding is allowed&lt;br /&gt;
** test that task box links to bidding page before algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to bidding page before algorithm is run&lt;br /&gt;
** test that task box links to review page with bidding information after algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to review page with bidding information after algorithm is run&lt;br /&gt;
* test that the bidding UI is implemented as expected&lt;br /&gt;
* test that a participant can bid on projects to review&lt;br /&gt;
** test that a participant can move projects into the bidding column&lt;br /&gt;
** test that a participant can reorder projects in the bidding column&lt;br /&gt;
** test that a participant's bidding preferences save&lt;br /&gt;
** test that a participant can't bid for their own topic&lt;br /&gt;
* test that run algorithm button calls webserver with correct information and returns review assignments for each user&lt;br /&gt;
&lt;br /&gt;
==== Directions for Manual Testing of Expertiza Server ====&lt;br /&gt;
1. Go to [http://152.7.99.70:8081/ testing server] &amp;lt;br&amp;gt;&lt;br /&gt;
2. Log in as username: '''instructor6''' password: '''password''' &amp;lt;br&amp;gt;&lt;br /&gt;
3. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''General''' tab make sure '''Has teams?''' and '''Has topics?''' are checked&lt;br /&gt;
:# In the '''Topics''' tab check '''Allow review to choose which topic to review?''' then click '''save'''&lt;br /&gt;
:# In the '''Topics''' tab select '''Bidding''' then click '''save'''&lt;br /&gt;
4. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# This UI is based on '''instructor6''' being a '''participant''' assigned to topic '''Topic4'''&lt;br /&gt;
::# The UI blocks user from bidding on their own project &lt;br /&gt;
::# Check that user can bid on topics and reorder bids&lt;br /&gt;
::# Check that users topic preferences save on page refresh&lt;br /&gt;
::# Impersonate other participants and repeat bidding UI tests ('''student7601''', '''student7602''', '''student7603''', '''student7604''', '''student7605''', '''student7606''', '''student7607''', '''student7608''', '''student7609'')&lt;br /&gt;
5. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''Topics''' tab click '''Run Review Algorithm''' button&lt;br /&gt;
6. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# '''E2085 Manual Testing review''' should now link to the reviewing page&lt;br /&gt;
::# The number of required reviews should already be displayed&lt;br /&gt;
::# A '''Request Another Review''' button should be present unless reviews listed is equal to the number of reviews allowed&lt;br /&gt;
::# '''Begin''' a review and test '''save''' and '''submit'''&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Demo Video for Expertiza Server ====&lt;br /&gt;
Video demonstration of manual testing: [https://www.screencast.com/t/0rSg1zDW here]&lt;br /&gt;
&lt;br /&gt;
=== ''Automatic/PyTest Testing '' ===&lt;br /&gt;
Pytest tests are written for the webservice to test a well formed and a malformed request.&lt;br /&gt;
&lt;br /&gt;
===   ''Automatic/RSpec Testing ''   ===&lt;br /&gt;
RSpec tests will need to be refactored according to the changes that we make in the expertiza repository. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== RSpec Testing Plan ====&lt;br /&gt;
These RSpec tests will need to:&lt;br /&gt;
* test basic functionality of review bids controller&lt;br /&gt;
* test basic functionality of review bid model&lt;br /&gt;
&lt;br /&gt;
==== Directions for RSpec Testing ====&lt;br /&gt;
:# on personal device using [https://github.com/ncsu-ngw/expertiza forked repo]&lt;br /&gt;
:# Run the following commands:&lt;br /&gt;
&lt;br /&gt;
 # review bids controller: &lt;br /&gt;
 bundle exec rspec spec/controllers/review_bids_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
 # review bid model: &lt;br /&gt;
 bundle exec rspec spec/models/review_bid_spec.rb&lt;br /&gt;
 &lt;br /&gt;
 # review bidding algorithm service:&lt;br /&gt;
 bundle exec rspec spec/services/review_bidding_algorithm_service_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Test Coverage==&lt;br /&gt;
Code Climate: [https://codeclimate.com/github/expertiza/expertiza/pull/2931 here]&lt;br /&gt;
&lt;br /&gt;
[[File:code-climate.png|700px]]&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
&lt;br /&gt;
'''Mentor:''' Janice Uwujaren (juwujar) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ashwin Muniswamy (akumarm) &amp;lt;br&amp;gt;&lt;br /&gt;
Arturo Serdan (aaserdan) &amp;lt;br&amp;gt;&lt;br /&gt;
Nicholas Winsen (nwinsen) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
''Previous Implementations'': &lt;br /&gt;
Fall 2019 [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Spring 2020 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2020 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2024 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2508._Reimplement_bidding-algorithm_web_service here]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''Relevant Links''&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/2931 &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
''Video Demo'': https://app.screencast.com/vaiJnWpHf0r07&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162639</id>
		<title>CSC/ECE 517 Spring 2025 - E2508. Reimplement bidding-algorithm web service</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162639"/>
		<updated>2025-03-25T01:53:20Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Project Overview==&lt;br /&gt;
===   ''Background''   ===&lt;br /&gt;
The previous implementation of the bidding service was hosted on peerlogic by a former student. The University no longer has access to this hosting service, and  is requiring a new solution. It is also asked that the webservice accept a better and cleaner json format which is easier to interpret and read.&lt;br /&gt;
&lt;br /&gt;
===   ''Objectives''   ===&lt;br /&gt;
# Reimplement trading cycles on a webservice&lt;br /&gt;
# Figure out a new hosting solution for the BiddingService web service. (VCL)&lt;br /&gt;
# Host the webservice on VCL&lt;br /&gt;
# Using tmux, figure out a way to keep the process running with a production wsgi service compatible with Flask.&lt;br /&gt;
# Create new tests for the repository&lt;br /&gt;
# Create a list of required packages that future maintainers can install easily&lt;br /&gt;
# Create a tests directory that users can test the functionality of the code with&lt;br /&gt;
# Modularize the code further, eliminate code smells.&lt;br /&gt;
# Refactor existing backend logic to account for the new json format&lt;br /&gt;
# Refactor existing backend code to send HTTP requests to the correct IP address&lt;br /&gt;
# Refactor existing frontend code to provide a list for users to select multiple topics on the frontend&lt;br /&gt;
# Allow users to prioritize their topic selection on the frontend&lt;br /&gt;
# Users should not be allowed to bid on their review topics on the frontend&lt;br /&gt;
# Display the results of the matched topics on the frontend&lt;br /&gt;
&lt;br /&gt;
===   ''Previous Work''   ===&lt;br /&gt;
There have been three previous implementations: &amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2019 [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Spring 2020 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2020 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2024 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2508._Reimplement_bidding-algorithm_web_service here]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/2931 &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Files Modified''   ===&lt;br /&gt;
This is a list of all the files added or changed in completing this project. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Changed'': &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/app.py - accomodated for changes in JsonParser&lt;br /&gt;
*app/json_parser.py - moved functions out due to SRP&lt;br /&gt;
*app/topics_matcher.py&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Added'': &amp;lt;br&amp;gt;&lt;br /&gt;
*app/tests/sample.json &amp;lt;br&amp;gt; - Sample input for the tests.&lt;br /&gt;
&lt;br /&gt;
*app/tests/test_assignment.py &amp;lt;br&amp;gt; Test File to test forms of input - tests both a successful and unsuccessful input&lt;br /&gt;
&lt;br /&gt;
*app/utils/popular_topics.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/student_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/topic_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
&lt;br /&gt;
*setup.py - required for wsgi&lt;br /&gt;
*wsgi.py - for hosting the server via gunicorn on VCL.&lt;br /&gt;
*.gitignore - to ignore anything that we may not want pushed (mostly for venv)&lt;br /&gt;
*requirements.txt - a list of requirements made easy for future maintainers&lt;br /&gt;
&lt;br /&gt;
=== ''Webservice'' ===&lt;br /&gt;
===== ''app'' =====&lt;br /&gt;
&lt;br /&gt;
The entry point to the Web service is the app.py file where we have the POST Method match_topics.&lt;br /&gt;
This receives the input in a json format from Expertiza. The input will contain a list of task ids, and then an Object of users, which each contain their student id and correlated bids that they made. Each bid contains a task id, a priority, and a timestamp. The input format was reworked to align to this style since it made more sense to have each student have a list of bids instead of the previous implementation which did not have this case. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:App2508.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''json parser'' =====&lt;br /&gt;
The json parser converts the json into a Dictionary. The previous implementation also had the parser create a preferences dictionary for the Student to store their topic preferences and one for Topics to store list of topics which have been selected by students and also the priority for the selection using the Timestamps. However, this was removed due to the Single Responsibility Principle. We felt the json parser was doing too much and should only be parsing the json!&lt;br /&gt;
&lt;br /&gt;
[[File:init_parser.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The student priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:student_prio.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The topic priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:topic_priorities.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== ''Test Input'' =====&lt;br /&gt;
&lt;br /&gt;
Sample Test case:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Case:&amp;lt;/b&amp;gt; There are a few very popular topics and the students who bid for them and bid early should receive it.&lt;br /&gt;
Popular Topics: 3969, 3971, 3972&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;tid&amp;quot;: [4427, 4428, 4429, 4430],&lt;br /&gt;
    &amp;quot;users&amp;quot;: {&lt;br /&gt;
      &amp;quot;40763&amp;quot;: {&lt;br /&gt;
          &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4429&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40764&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4427&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40765&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:15 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:16 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:17 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4428&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;max_accepted_proposals&amp;quot;: 3&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''Output'' =====&lt;br /&gt;
&lt;br /&gt;
 Since there is competition for these topics, the algorithm recognizes this and makes sure to assign them only to the students who bid for it.&lt;br /&gt;
		Other students who picked other topics or did not pick anything are assigned different topics.&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
    &amp;quot;40763&amp;quot;: [&lt;br /&gt;
        4427,&lt;br /&gt;
        4428,&lt;br /&gt;
        4430&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40764&amp;quot;: [&lt;br /&gt;
        4428,&lt;br /&gt;
        4430,&lt;br /&gt;
        4429&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40765&amp;quot;: [&lt;br /&gt;
        4429,&lt;br /&gt;
        4427,&lt;br /&gt;
        4430&lt;br /&gt;
    ]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== ''Controller'' ===&lt;br /&gt;
&lt;br /&gt;
The controller includes 8 methods that handle the review bidding process. The public methods cover authorization, rendering views, saving user bids, and coordinating review assignment. The private methods support these functions by abstracting data gathering and algorithm coordination logic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Method: action_allowed? ======&lt;br /&gt;
&lt;br /&gt;
This method controls user access to controller actions. It allows 'Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator', and 'Student' roles to access show, set_priority, and index. Other actions are restricted to non-student roles. It ensures proper permissions for accessing review bidding features.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: index ======&lt;br /&gt;
&lt;br /&gt;
This method gathers information for the &amp;quot;Your Work&amp;quot; page, where users can view their assigned reviews. It checks user identity, retrieves associated reviews, and counts completed reviews. The view rendered is sign_up_sheet/review_bids_others_work.View: others_work.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_index.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: show ======&lt;br /&gt;
&lt;br /&gt;
This method renders the bidding page where users select topics they'd prefer to review. It fetches the assignment, available topics, and any existing bids. Already assigned or signed-up topics are excluded. The page also lists any assigned reviews.View: show.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_show.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: set_priority ======&lt;br /&gt;
&lt;br /&gt;
This method stores or updates a participant's topic preferences. It removes old bids not in the current selection and creates or updates the remaining bids with new priorities. This method is triggered when users submit their topic rankings on the bidding page.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_set_priority.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_bidding ======&lt;br /&gt;
&lt;br /&gt;
This method coordinates the assignment of review topics. It gathers reviewer IDs and invokes the bidding algorithm using a service. It validates the output and uses ReviewBid.assign_review_topics to perform the actual assignment. Bidding is then disabled.&lt;br /&gt;
&lt;br /&gt;
[[File:Assign_bidding.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: fetch_reviewer_ids (Private) ======&lt;br /&gt;
&lt;br /&gt;
This helper method retrieves all AssignmentParticipant IDs for a given assignment. These IDs represent the reviewers participating in the bidding process.&lt;br /&gt;
&lt;br /&gt;
====== Method: process_bidding (Private) ======&lt;br /&gt;
This helper method delegates the logic for running the bidding algorithm to the service class ReviewBiddingAlgorithmService. It takes the assignment ID and list of reviewers as input and returns matched topic assignments.&lt;br /&gt;
&lt;br /&gt;
====== Method: ensure_valid_topics (Private) ======&lt;br /&gt;
This method ensures that all reviewers have valid topic assignment entries, even if the algorithm returns nothing (e.g., due to web service failure). It initializes empty topic arrays for any missing reviewers.&lt;br /&gt;
&lt;br /&gt;
[[File:Controller_private_methods.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
=== ''Service'' ===&lt;br /&gt;
&lt;br /&gt;
The ReviewBiddingAlgorithmService is a service object responsible for handling communication between the application and the external web service that executes the review bidding algorithm. It prepares bidding data, sends it to the web service, processes the response, and provides a fallback mechanism in case of failure.&lt;br /&gt;
&lt;br /&gt;
This service allows to encapsulate all logic required to interact with the external topic-matching web service. It separates the algorithm execution concerns from the controller, improving modularity, testability, and maintainability of the code.&lt;br /&gt;
&lt;br /&gt;
====== Method: self.process_bidding ======&lt;br /&gt;
&lt;br /&gt;
This is the primary entry point for the controller. It accepts the assignment_id and a list of reviewer_ids, then prepares the bidding data by calling ReviewBid.bidding_data(...). It passes the data to the web service by calling run_bidding_algorithm. If the web service is unavailable or fails, the method logs an error and falls back to an internal method: ReviewBid.fallback_algorithm. The result is returned as a hash mapping reviewer IDs to arrays of assigned topic IDs.&lt;br /&gt;
&lt;br /&gt;
====== Method: self.run_bidding_algorithm ======&lt;br /&gt;
&lt;br /&gt;
This method retrieves the review bidding web service URL from the app configuration (config/webservices.yml) and calls the internal send_bidding_request method to make the actual request.It logs the outgoing URL for debugging and delegates the response parsing.&lt;br /&gt;
&lt;br /&gt;
====== Private Method: send_bidding_request ======&lt;br /&gt;
&lt;br /&gt;
This private class method handles the HTTP POST request using RestClient. It sends the bidding data as JSON and expects a JSON response. If the request fails due to a connection error, server error, or timeout, the method logs the exception and returns false, allowing the caller to trigger a fallback.&lt;br /&gt;
&lt;br /&gt;
[[File:Review_bidding_algorithm_service.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Fallback Algorithm ===&lt;br /&gt;
=====   ''Introduction''   =====&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm in Expertiza is designed to ensure automatic topic assignment when the primary Bidding Algorithm fails due to Web Service unavailability.  &lt;br /&gt;
&lt;br /&gt;
Normally, Expertiza allows reviewers to bid on topics, and the ''ReviewBiddingAlgorithmService'' processes these bids to assign topics. However, when this web service ''fails'' (due to API downtime, server issues, or unexpected errors), the system must switch to fallback and automatically assign topics to reviewers.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Solution''   =====&lt;br /&gt;
It is triggered when the web service is unavailable. It ensures fair topic assignment by:  &lt;br /&gt;
* Prioritizing topics with the largest teams.  &lt;br /&gt;
* Using a round-robin approach to distribute topics among reviewers.  &lt;br /&gt;
* Ensuring reviewers do not get their own team’s topic.  &lt;br /&gt;
&lt;br /&gt;
=====   ''When is this Used?''  ===== &lt;br /&gt;
* The ReviewBiddingAlgorithmService fails due to an API issue.  &lt;br /&gt;
* The web service times out or returns an error.  &lt;br /&gt;
* Unexpected exceptions occur in the bidding process.  &lt;br /&gt;
&lt;br /&gt;
Instead of stopping the review process, the system automatically falls-back to an internal algorithm to distribute topics.  &lt;br /&gt;
&lt;br /&gt;
=====   ''How Does the Fallback Algorithm Work?''   ===== &lt;br /&gt;
The algorithm follows these **four main steps:  &lt;br /&gt;
* Fetch available topics – Retrieves all topics for the given assignment.  &lt;br /&gt;
* Sort topics by team size – Topics with more members are given priority.  &lt;br /&gt;
* Create a topic queue – Topics are arranged in descending order of team size.  &lt;br /&gt;
* Assign topics in a round-robin manner – Reviewers are assigned topics while avoiding their own team's topic.  &lt;br /&gt;
&lt;br /&gt;
This ensures ''fair and balanced'' distribution of topics.&lt;br /&gt;
  &lt;br /&gt;
=====   ''Implementation - Controller Code (Triggering the Fallback)''   =====&lt;br /&gt;
If the primary bidding service fails, the system catches the error and calls the Fallback Algorithm.&lt;br /&gt;
&lt;br /&gt;
[[File:Controller-code.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: If ''ReviewBiddingAlgorithmService'' fails, the system automatically calls fallback_algorithm.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Implementation - Model Code (Fallback Algorithm)''   =====&lt;br /&gt;
This method ensures fair topic assignment when the bidding system fails.&lt;br /&gt;
&lt;br /&gt;
[[File:Model-code.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: This function ensures every reviewer receives a topic without requiring manual intervention.&lt;br /&gt;
&lt;br /&gt;
=====   ''RSpec Testing of Fallback Algorithm''   =====&lt;br /&gt;
To verify correctness, we use unit tests in ''review_bid_spec.rb''&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm ensures that ''topics are assigned fairly'' even when the primary bidding service fails. By prioritizing ''larger teams'', ''avoiding self-review'', and using a ''round-robin strategy'', the fallback mechanism keeps the review process smooth and automatic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
This section outlines the test plan for this project including testing scenarios/edge cases, the manual testing plan, and the automatic/RSpec testing plan.&lt;br /&gt;
&lt;br /&gt;
=== ''Testing Scenarios'' ===&lt;br /&gt;
This section outlines the various bidding scenarios that could occur. These scenarios should be tested in either '''Manual Testing''' or '''Automatic Testing'''.&lt;br /&gt;
&lt;br /&gt;
==== Basic Bidding Scenario ====&lt;br /&gt;
*Reviewers bid on multiple projects at different times&lt;br /&gt;
** Bidding algorithm should give priority to reviewers that bid first and should assign based on reviewers ranking&lt;br /&gt;
&lt;br /&gt;
====   Edge Cases   ====&lt;br /&gt;
* All reviewers bid on the same project&lt;br /&gt;
** If different time stamps: bidding algorithm should give priority to reviewers that bid first&lt;br /&gt;
** If same time stamps: bidding algorithm should assign reviews randomly&lt;br /&gt;
* None of the reviews bid on any projects&lt;br /&gt;
** Bidding algorithm should assign reviews randomly&lt;br /&gt;
* Reviewer bids on their own project&lt;br /&gt;
** Bidding algorithm should not allow a reviewer to bid on their own project and should have validation to prevent assigning a reviewer their own project&lt;br /&gt;
* None of the reviewers bid on a specific project&lt;br /&gt;
** Bidding algorithm should still assign reviewers to this project&lt;br /&gt;
&lt;br /&gt;
===   ''Manual Testing''   ===&lt;br /&gt;
Manual testing should be preformed on an Expertiza server and webserver platform &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Plan for Expertiza Server ====&lt;br /&gt;
* test that an instructor can allow review bidding for an assignment&lt;br /&gt;
* test that server routes correctly when review bidding is allowed&lt;br /&gt;
** test that task box links to bidding page before algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to bidding page before algorithm is run&lt;br /&gt;
** test that task box links to review page with bidding information after algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to review page with bidding information after algorithm is run&lt;br /&gt;
* test that the bidding UI is implemented as expected&lt;br /&gt;
* test that a participant can bid on projects to review&lt;br /&gt;
** test that a participant can move projects into the bidding column&lt;br /&gt;
** test that a participant can reorder projects in the bidding column&lt;br /&gt;
** test that a participant's bidding preferences save&lt;br /&gt;
** test that a participant can't bid for their own topic&lt;br /&gt;
* test that run algorithm button calls webserver with correct information and returns review assignments for each user&lt;br /&gt;
&lt;br /&gt;
==== Directions for Manual Testing of Expertiza Server ====&lt;br /&gt;
1. Go to [http://152.7.99.70:8081/ testing server] &amp;lt;br&amp;gt;&lt;br /&gt;
2. Log in as username: '''instructor6''' password: '''password''' &amp;lt;br&amp;gt;&lt;br /&gt;
3. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''General''' tab make sure '''Has teams?''' and '''Has topics?''' are checked&lt;br /&gt;
:# In the '''Topics''' tab check '''Allow review to choose which topic to review?''' then click '''save'''&lt;br /&gt;
:# In the '''Topics''' tab select '''Bidding''' then click '''save'''&lt;br /&gt;
4. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# This UI is based on '''instructor6''' being a '''participant''' assigned to topic '''Topic4'''&lt;br /&gt;
::# The UI blocks user from bidding on their own project &lt;br /&gt;
::# Check that user can bid on topics and reorder bids&lt;br /&gt;
::# Check that users topic preferences save on page refresh&lt;br /&gt;
::# Impersonate other participants and repeat bidding UI tests ('''student7601''', '''student7602''', '''student7603''', '''student7604''', '''student7605''', '''student7606''', '''student7607''', '''student7608''', '''student7609'')&lt;br /&gt;
5. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''Topics''' tab click '''Run Review Algorithm''' button&lt;br /&gt;
6. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# '''E2085 Manual Testing review''' should now link to the reviewing page&lt;br /&gt;
::# The number of required reviews should already be displayed&lt;br /&gt;
::# A '''Request Another Review''' button should be present unless reviews listed is equal to the number of reviews allowed&lt;br /&gt;
::# '''Begin''' a review and test '''save''' and '''submit'''&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Demo Video for Expertiza Server ====&lt;br /&gt;
Video demonstration of manual testing: [https://www.screencast.com/t/0rSg1zDW here]&lt;br /&gt;
&lt;br /&gt;
=== ''Automatic/PyTest Testing '' ===&lt;br /&gt;
Pytest tests are written for the webservice to test a well formed and a malformed request.&lt;br /&gt;
&lt;br /&gt;
===   ''Automatic/RSpec Testing ''   ===&lt;br /&gt;
RSpec tests will need to be refactored according to the changes that we make in the expertiza repository. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== RSpec Testing Plan ====&lt;br /&gt;
These RSpec tests will need to:&lt;br /&gt;
* test basic functionality of review bids controller&lt;br /&gt;
* test basic functionality of review bid model&lt;br /&gt;
&lt;br /&gt;
==== Directions for RSpec Testing ====&lt;br /&gt;
:# on personal device using [https://github.com/ncsu-ngw/expertiza forked repo]&lt;br /&gt;
:# Run the following commands:&lt;br /&gt;
&lt;br /&gt;
 # review bids controller: &lt;br /&gt;
 bundle exec rspec spec/controllers/review_bids_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
 # review bid model: &lt;br /&gt;
 bundle exec rspec spec/models/review_bid_spec.rb&lt;br /&gt;
 &lt;br /&gt;
 # review bidding algorithm service:&lt;br /&gt;
 bundle exec rspec spec/services/review_bidding_algorithm_service_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Test Coverage==&lt;br /&gt;
Code Climate: [https://codeclimate.com/github/expertiza/expertiza/pull/2931 here]&lt;br /&gt;
&lt;br /&gt;
[[File:code-climate.png|700px]]&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
&lt;br /&gt;
'''Mentor:''' Janice Uwujaren (juwujar) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ashwin Muniswamy (akumarm) &amp;lt;br&amp;gt;&lt;br /&gt;
Arturo Serdan (aaserdan) &amp;lt;br&amp;gt;&lt;br /&gt;
Nicholas Winsen (nwinsen) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
''Previous Implementations'': &lt;br /&gt;
Fall 2019 [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Spring 2020 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2020 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2024 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2508._Reimplement_bidding-algorithm_web_service here]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/2931 &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
''Video Demo'': https://app.screencast.com/vaiJnWpHf0r07&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162638</id>
		<title>CSC/ECE 517 Spring 2025 - E2508. Reimplement bidding-algorithm web service</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162638"/>
		<updated>2025-03-25T01:51:40Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Project Overview==&lt;br /&gt;
===   ''Background''   ===&lt;br /&gt;
The previous implementation of the bidding service was hosted on peerlogic by a former student. The University no longer has access to this hosting service, and  is requiring a new solution. It is also asked that the webservice accept a better and cleaner json format which is easier to interpret and read.&lt;br /&gt;
&lt;br /&gt;
===   ''Objectives''   ===&lt;br /&gt;
# Reimplement trading cycles on a webservice&lt;br /&gt;
# Figure out a new hosting solution for the BiddingService web service. (VCL)&lt;br /&gt;
# Host the webservice on VCL&lt;br /&gt;
# Using tmux, figure out a way to keep the process running with a production wsgi service compatible with Flask.&lt;br /&gt;
# Create new tests for the repository&lt;br /&gt;
# Create a list of required packages that future maintainers can install easily&lt;br /&gt;
# Create a tests directory that users can test the functionality of the code with&lt;br /&gt;
# Modularize the code further, eliminate code smells.&lt;br /&gt;
# Refactor existing backend logic to account for the new json format&lt;br /&gt;
# Refactor existing backend code to send HTTP requests to the correct IP address&lt;br /&gt;
# Refactor existing frontend code to provide a list for users to select multiple topics on the frontend&lt;br /&gt;
# Allow users to prioritize their topic selection on the frontend&lt;br /&gt;
# Users should not be allowed to bid on their review topics on the frontend&lt;br /&gt;
# Display the results of the matched topics on the frontend&lt;br /&gt;
&lt;br /&gt;
===   ''Previous Work''   ===&lt;br /&gt;
There have been three previous implementations: &amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2019 [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Spring 2020 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2020 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2024 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2508._Reimplement_bidding-algorithm_web_service here]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/2931 &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Files Modified''   ===&lt;br /&gt;
This is a list of all the files added or changed in completing this project. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Changed'': &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/app.py - accomodated for changes in JsonParser&lt;br /&gt;
*app/json_parser.py - moved functions out due to SRP&lt;br /&gt;
*app/topics_matcher.py&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Added'': &amp;lt;br&amp;gt;&lt;br /&gt;
*app/tests/sample.json &amp;lt;br&amp;gt; - Sample input for the tests.&lt;br /&gt;
&lt;br /&gt;
*app/tests/test_assignment.py &amp;lt;br&amp;gt; Test File to test forms of input - tests both a successful and unsuccessful input&lt;br /&gt;
&lt;br /&gt;
*app/utils/popular_topics.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/student_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/topic_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
&lt;br /&gt;
*setup.py - required for wsgi&lt;br /&gt;
*wsgi.py - for hosting the server via gunicorn on VCL.&lt;br /&gt;
*.gitignore - to ignore anything that we may not want pushed (mostly for venv)&lt;br /&gt;
*requirements.txt - a list of requirements made easy for future maintainers&lt;br /&gt;
&lt;br /&gt;
=== ''Webservice'' ===&lt;br /&gt;
===== ''app'' =====&lt;br /&gt;
&lt;br /&gt;
The entry point to the Web service is the app.py file where we have the POST Method match_topics.&lt;br /&gt;
This receives the input in a json format from Expertiza. The input will contain a list of task ids, and then an Object of users, which each contain their student id and correlated bids that they made. Each bid contains a task id, a priority, and a timestamp. The input format was reworked to align to this style since it made more sense to have each student have a list of bids instead of the previous implementation which did not have this case. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:App2508.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''json parser'' =====&lt;br /&gt;
The json parser converts the json into a Dictionary. The previous implementation also had the parser create a preferences dictionary for the Student to store their topic preferences and one for Topics to store list of topics which have been selected by students and also the priority for the selection using the Timestamps. However, this was removed due to the Single Responsibility Principle. We felt the json parser was doing too much and should only be parsing the json!&lt;br /&gt;
&lt;br /&gt;
[[File:init_parser.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The student priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:student_prio.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The topic priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:topic_priorities.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== ''Test Input'' =====&lt;br /&gt;
&lt;br /&gt;
Sample Test case:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Case:&amp;lt;/b&amp;gt; There are a few very popular topics and the students who bid for them and bid early should receive it.&lt;br /&gt;
Popular Topics: 3969, 3971, 3972&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;tid&amp;quot;: [4427, 4428, 4429, 4430],&lt;br /&gt;
    &amp;quot;users&amp;quot;: {&lt;br /&gt;
      &amp;quot;40763&amp;quot;: {&lt;br /&gt;
          &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4429&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40764&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4427&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40765&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:15 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:16 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:17 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4428&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;max_accepted_proposals&amp;quot;: 3&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''Output'' =====&lt;br /&gt;
&lt;br /&gt;
 Since there is competition for these topics, the algorithm recognizes this and makes sure to assign them only to the students who bid for it.&lt;br /&gt;
		Other students who picked other topics or did not pick anything are assigned different topics.&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
    &amp;quot;40763&amp;quot;: [&lt;br /&gt;
        4427,&lt;br /&gt;
        4428,&lt;br /&gt;
        4430&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40764&amp;quot;: [&lt;br /&gt;
        4428,&lt;br /&gt;
        4430,&lt;br /&gt;
        4429&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40765&amp;quot;: [&lt;br /&gt;
        4429,&lt;br /&gt;
        4427,&lt;br /&gt;
        4430&lt;br /&gt;
    ]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== ''Controller'' ===&lt;br /&gt;
&lt;br /&gt;
The controller includes 8 methods that handle the review bidding process. The public methods cover authorization, rendering views, saving user bids, and coordinating review assignment. The private methods support these functions by abstracting data gathering and algorithm coordination logic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Method: action_allowed? ======&lt;br /&gt;
&lt;br /&gt;
This method controls user access to controller actions. It allows 'Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator', and 'Student' roles to access show, set_priority, and index. Other actions are restricted to non-student roles. It ensures proper permissions for accessing review bidding features.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: index ======&lt;br /&gt;
&lt;br /&gt;
This method gathers information for the &amp;quot;Your Work&amp;quot; page, where users can view their assigned reviews. It checks user identity, retrieves associated reviews, and counts completed reviews. The view rendered is sign_up_sheet/review_bids_others_work.View: others_work.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_index.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: show ======&lt;br /&gt;
&lt;br /&gt;
This method renders the bidding page where users select topics they'd prefer to review. It fetches the assignment, available topics, and any existing bids. Already assigned or signed-up topics are excluded. The page also lists any assigned reviews.View: show.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_show.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: set_priority ======&lt;br /&gt;
&lt;br /&gt;
This method stores or updates a participant's topic preferences. It removes old bids not in the current selection and creates or updates the remaining bids with new priorities. This method is triggered when users submit their topic rankings on the bidding page.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_set_priority.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_bidding ======&lt;br /&gt;
&lt;br /&gt;
This method coordinates the assignment of review topics. It gathers reviewer IDs and invokes the bidding algorithm using a service. It validates the output and uses ReviewBid.assign_review_topics to perform the actual assignment. Bidding is then disabled.&lt;br /&gt;
&lt;br /&gt;
[[File:Assign_bidding.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: fetch_reviewer_ids (Private) ======&lt;br /&gt;
&lt;br /&gt;
This helper method retrieves all AssignmentParticipant IDs for a given assignment. These IDs represent the reviewers participating in the bidding process.&lt;br /&gt;
&lt;br /&gt;
====== Method: process_bidding (Private) ======&lt;br /&gt;
This helper method delegates the logic for running the bidding algorithm to the service class ReviewBiddingAlgorithmService. It takes the assignment ID and list of reviewers as input and returns matched topic assignments.&lt;br /&gt;
&lt;br /&gt;
====== Method: ensure_valid_topics (Private) ======&lt;br /&gt;
This method ensures that all reviewers have valid topic assignment entries, even if the algorithm returns nothing (e.g., due to web service failure). It initializes empty topic arrays for any missing reviewers.&lt;br /&gt;
&lt;br /&gt;
[[File:Controller_private_methods.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
=== ''Service'' ===&lt;br /&gt;
&lt;br /&gt;
The ReviewBiddingAlgorithmService is a service object responsible for handling communication between the application and the external web service that executes the review bidding algorithm. It prepares bidding data, sends it to the web service, processes the response, and provides a fallback mechanism in case of failure.&lt;br /&gt;
&lt;br /&gt;
This service allows to encapsulate all logic required to interact with the external topic-matching web service. It separates the algorithm execution concerns from the controller, improving modularity, testability, and maintainability of the code.&lt;br /&gt;
&lt;br /&gt;
====== Method: self.process_bidding ======&lt;br /&gt;
&lt;br /&gt;
This is the primary entry point for the controller. It accepts the assignment_id and a list of reviewer_ids, then prepares the bidding data by calling ReviewBid.bidding_data(...). It passes the data to the web service by calling run_bidding_algorithm. If the web service is unavailable or fails, the method logs an error and falls back to an internal method: ReviewBid.fallback_algorithm. The result is returned as a hash mapping reviewer IDs to arrays of assigned topic IDs.&lt;br /&gt;
&lt;br /&gt;
====== Method: self.run_bidding_algorithm ======&lt;br /&gt;
&lt;br /&gt;
This method retrieves the review bidding web service URL from the app configuration (config/webservices.yml) and calls the internal send_bidding_request method to make the actual request.It logs the outgoing URL for debugging and delegates the response parsing.&lt;br /&gt;
&lt;br /&gt;
====== Private Method: send_bidding_request ======&lt;br /&gt;
&lt;br /&gt;
This private class method handles the HTTP POST request using RestClient. It sends the bidding data as JSON and expects a JSON response. If the request fails due to a connection error, server error, or timeout, the method logs the exception and returns false, allowing the caller to trigger a fallback.&lt;br /&gt;
&lt;br /&gt;
[[File:Review_bidding_algorithm_service.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Fallback Algorithm ===&lt;br /&gt;
=====   ''Introduction''   =====&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm in Expertiza is designed to ensure automatic topic assignment when the primary Bidding Algorithm fails due to Web Service unavailability.  &lt;br /&gt;
&lt;br /&gt;
Normally, Expertiza allows reviewers to bid on topics, and the ''ReviewBiddingAlgorithmService'' processes these bids to assign topics. However, when this web service ''fails'' (due to API downtime, server issues, or unexpected errors), the system must switch to fallback and automatically assign topics to reviewers.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Solution''   =====&lt;br /&gt;
It is triggered when the web service is unavailable. It ensures fair topic assignment by:  &lt;br /&gt;
* Prioritizing topics with the largest teams.  &lt;br /&gt;
* Using a round-robin approach to distribute topics among reviewers.  &lt;br /&gt;
* Ensuring reviewers do not get their own team’s topic.  &lt;br /&gt;
&lt;br /&gt;
=====   ''When is this Used?''  ===== &lt;br /&gt;
* The ReviewBiddingAlgorithmService fails due to an API issue.  &lt;br /&gt;
* The web service times out or returns an error.  &lt;br /&gt;
* Unexpected exceptions occur in the bidding process.  &lt;br /&gt;
&lt;br /&gt;
Instead of stopping the review process, the system automatically falls-back to an internal algorithm to distribute topics.  &lt;br /&gt;
&lt;br /&gt;
=====   ''How Does the Fallback Algorithm Work?''   ===== &lt;br /&gt;
The algorithm follows these **four main steps:  &lt;br /&gt;
* Fetch available topics – Retrieves all topics for the given assignment.  &lt;br /&gt;
* Sort topics by team size – Topics with more members are given priority.  &lt;br /&gt;
* Create a topic queue – Topics are arranged in descending order of team size.  &lt;br /&gt;
* Assign topics in a round-robin manner – Reviewers are assigned topics while avoiding their own team's topic.  &lt;br /&gt;
&lt;br /&gt;
This ensures ''fair and balanced'' distribution of topics.&lt;br /&gt;
  &lt;br /&gt;
=====   ''Implementation - Controller Code (Triggering the Fallback)''   =====&lt;br /&gt;
If the primary bidding service fails, the system catches the error and calls the Fallback Algorithm.&lt;br /&gt;
&lt;br /&gt;
[[File:Controller-code.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: If ''ReviewBiddingAlgorithmService'' fails, the system automatically calls fallback_algorithm.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Implementation - Model Code (Fallback Algorithm)''   =====&lt;br /&gt;
This method ensures fair topic assignment when the bidding system fails.&lt;br /&gt;
&lt;br /&gt;
[[File:Model-code.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: This function ensures every reviewer receives a topic without requiring manual intervention.&lt;br /&gt;
&lt;br /&gt;
=====   ''RSpec Testing of Fallback Algorithm''   =====&lt;br /&gt;
To verify correctness, we use unit tests in ''review_bid_spec.rb''&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm ensures that ''topics are assigned fairly'' even when the primary bidding service fails. By prioritizing ''larger teams'', ''avoiding self-review'', and using a ''round-robin strategy'', the fallback mechanism keeps the review process smooth and automatic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
This section outlines the test plan for this project including testing scenarios/edge cases, the manual testing plan, and the automatic/RSpec testing plan.&lt;br /&gt;
&lt;br /&gt;
=== ''Testing Scenarios'' ===&lt;br /&gt;
This section outlines the various bidding scenarios that could occur. These scenarios should be tested in either '''Manual Testing''' or '''Automatic Testing'''.&lt;br /&gt;
&lt;br /&gt;
==== Basic Bidding Scenario ====&lt;br /&gt;
*Reviewers bid on multiple projects at different times&lt;br /&gt;
** Bidding algorithm should give priority to reviewers that bid first and should assign based on reviewers ranking&lt;br /&gt;
&lt;br /&gt;
====   Edge Cases   ====&lt;br /&gt;
* All reviewers bid on the same project&lt;br /&gt;
** If different time stamps: bidding algorithm should give priority to reviewers that bid first&lt;br /&gt;
** If same time stamps: bidding algorithm should assign reviews randomly&lt;br /&gt;
* None of the reviews bid on any projects&lt;br /&gt;
** Bidding algorithm should assign reviews randomly&lt;br /&gt;
* Reviewer bids on their own project&lt;br /&gt;
** Bidding algorithm should not allow a reviewer to bid on their own project and should have validation to prevent assigning a reviewer their own project&lt;br /&gt;
* None of the reviewers bid on a specific project&lt;br /&gt;
** Bidding algorithm should still assign reviewers to this project&lt;br /&gt;
&lt;br /&gt;
===   ''Manual Testing''   ===&lt;br /&gt;
Manual testing should be preformed on an Expertiza server and webserver platform &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Plan for Expertiza Server ====&lt;br /&gt;
* test that an instructor can allow review bidding for an assignment&lt;br /&gt;
* test that server routes correctly when review bidding is allowed&lt;br /&gt;
** test that task box links to bidding page before algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to bidding page before algorithm is run&lt;br /&gt;
** test that task box links to review page with bidding information after algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to review page with bidding information after algorithm is run&lt;br /&gt;
* test that the bidding UI is implemented as expected&lt;br /&gt;
* test that a participant can bid on projects to review&lt;br /&gt;
** test that a participant can move projects into the bidding column&lt;br /&gt;
** test that a participant can reorder projects in the bidding column&lt;br /&gt;
** test that a participant's bidding preferences save&lt;br /&gt;
** test that a participant can't bid for their own topic&lt;br /&gt;
* test that run algorithm button calls webserver with correct information and returns review assignments for each user&lt;br /&gt;
&lt;br /&gt;
==== Directions for Manual Testing of Expertiza Server ====&lt;br /&gt;
1. Go to [http://152.7.99.70:8081/ testing server] &amp;lt;br&amp;gt;&lt;br /&gt;
2. Log in as username: '''instructor6''' password: '''password''' &amp;lt;br&amp;gt;&lt;br /&gt;
3. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''General''' tab make sure '''Has teams?''' and '''Has topics?''' are checked&lt;br /&gt;
:# In the '''Topics''' tab check '''Allow review to choose which topic to review?''' then click '''save'''&lt;br /&gt;
:# In the '''Topics''' tab select '''Bidding''' then click '''save'''&lt;br /&gt;
4. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# This UI is based on '''instructor6''' being a '''participant''' assigned to topic '''Topic4'''&lt;br /&gt;
::# The UI blocks user from bidding on their own project &lt;br /&gt;
::# Check that user can bid on topics and reorder bids&lt;br /&gt;
::# Check that users topic preferences save on page refresh&lt;br /&gt;
::# Impersonate other participants and repeat bidding UI tests ('''student7601''', '''student7602''', '''student7603''', '''student7604''', '''student7605''', '''student7606''', '''student7607''', '''student7608''', '''student7609'')&lt;br /&gt;
5. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''Topics''' tab click '''Run Review Algorithm''' button&lt;br /&gt;
6. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# '''E2085 Manual Testing review''' should now link to the reviewing page&lt;br /&gt;
::# The number of required reviews should already be displayed&lt;br /&gt;
::# A '''Request Another Review''' button should be present unless reviews listed is equal to the number of reviews allowed&lt;br /&gt;
::# '''Begin''' a review and test '''save''' and '''submit'''&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Demo Video for Expertiza Server ====&lt;br /&gt;
Video demonstration of manual testing: [https://www.screencast.com/t/0rSg1zDW here]&lt;br /&gt;
&lt;br /&gt;
=== ''Automatic/PyTest Testing '' ===&lt;br /&gt;
Pytest tests are written for the webservice to test a well formed and a malformed request.&lt;br /&gt;
&lt;br /&gt;
===   ''Automatic/RSpec Testing ''   ===&lt;br /&gt;
RSpec tests will need to be refactored according to the changes that we make in the expertiza repository. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== RSpec Testing Plan ====&lt;br /&gt;
These RSpec tests will need to:&lt;br /&gt;
* test basic functionality of review bids controller&lt;br /&gt;
* test basic functionality of review bid model&lt;br /&gt;
&lt;br /&gt;
==== Directions for RSpec Testing ====&lt;br /&gt;
:# on personal device using [https://github.com/ncsu-ngw/expertiza forked repo]&lt;br /&gt;
:# Run the following commands:&lt;br /&gt;
&lt;br /&gt;
 # review bids controller: &lt;br /&gt;
 bundle exec rspec spec/controllers/review_bids_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
 # review bid model: &lt;br /&gt;
 bundle exec rspec spec/models/review_bid_spec.rb&lt;br /&gt;
 &lt;br /&gt;
 # review bidding algorithm service:&lt;br /&gt;
 bundle exec rspec spec/services/review_bidding_algorithm_service_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Test Coverage==&lt;br /&gt;
Code Climate: [https://codeclimate.com/github/expertiza/expertiza/pull/2931 here]&lt;br /&gt;
&lt;br /&gt;
[[File:code-climate.png|700px]]&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
&lt;br /&gt;
'''Mentor:''' Janice Uwujaren (juwujar) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ashwin Muniswamy (akumarm) &amp;lt;br&amp;gt;&lt;br /&gt;
Arturo Serdan (aaserdan) &amp;lt;br&amp;gt;&lt;br /&gt;
Nicholas Winsen (nwinsen) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
''Previous Implementations'': &lt;br /&gt;
[[https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Objectives]],&amp;lt;br&amp;gt;&lt;br /&gt;
[[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review 1]],&amp;lt;br&amp;gt;[[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review 2]]&amp;lt;br&amp;gt;&lt;br /&gt;
''Bidding Interface Implementation Pull Request'': [[https://github.com/expertiza/expertiza/pull/778 3]]&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/2931 &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
''Video Demo'': https://app.screencast.com/vaiJnWpHf0r07&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162636</id>
		<title>CSC/ECE 517 Spring 2025 - E2508. Reimplement bidding-algorithm web service</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162636"/>
		<updated>2025-03-25T01:50:43Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Project Overview==&lt;br /&gt;
===   ''Background''   ===&lt;br /&gt;
The previous implementation of the bidding service was hosted on peerlogic by a former student. The University no longer has access to this hosting service, and  is requiring a new solution. It is also asked that the webservice accept a better and cleaner json format which is easier to interpret and read.&lt;br /&gt;
&lt;br /&gt;
===   ''Objectives''   ===&lt;br /&gt;
# Reimplement trading cycles on a webservice&lt;br /&gt;
# Figure out a new hosting solution for the BiddingService web service. (VCL)&lt;br /&gt;
# Host the webservice on VCL&lt;br /&gt;
# Using tmux, figure out a way to keep the process running with a production wsgi service compatible with Flask.&lt;br /&gt;
# Create new tests for the repository&lt;br /&gt;
# Create a list of required packages that future maintainers can install easily&lt;br /&gt;
# Create a tests directory that users can test the functionality of the code with&lt;br /&gt;
# Modularize the code further, eliminate code smells.&lt;br /&gt;
# Refactor existing backend logic to account for the new json format&lt;br /&gt;
# Refactor existing backend code to send HTTP requests to the correct IP address&lt;br /&gt;
# Refactor existing frontend code to provide a list for users to select multiple topics on the frontend&lt;br /&gt;
# Allow users to prioritize their topic selection on the frontend&lt;br /&gt;
# Users should not be allowed to bid on their review topics on the frontend&lt;br /&gt;
# Display the results of the matched topics on the frontend&lt;br /&gt;
&lt;br /&gt;
===   ''Previous Work''   ===&lt;br /&gt;
There have been three previous implementations: &amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2019 [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Spring 2020 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2020 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2024 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2508._Reimplement_bidding-algorithm_web_service here]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/2931 &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Files Modified''   ===&lt;br /&gt;
This is a list of all the files added or changed in completing this project. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Changed'': &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/app.py - accomodated for changes in JsonParser&lt;br /&gt;
*app/json_parser.py - moved functions out due to SRP&lt;br /&gt;
*app/topics_matcher.py&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Added'': &amp;lt;br&amp;gt;&lt;br /&gt;
*app/tests/sample.json &amp;lt;br&amp;gt; - Sample input for the tests.&lt;br /&gt;
&lt;br /&gt;
*app/tests/test_assignment.py &amp;lt;br&amp;gt; Test File to test forms of input - tests both a successful and unsuccessful input&lt;br /&gt;
&lt;br /&gt;
*app/utils/popular_topics.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/student_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/topic_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
&lt;br /&gt;
*setup.py - required for wsgi&lt;br /&gt;
*wsgi.py - for hosting the server via gunicorn on VCL.&lt;br /&gt;
*.gitignore - to ignore anything that we may not want pushed (mostly for venv)&lt;br /&gt;
*requirements.txt - a list of requirements made easy for future maintainers&lt;br /&gt;
&lt;br /&gt;
=== ''Webservice'' ===&lt;br /&gt;
===== ''app'' =====&lt;br /&gt;
&lt;br /&gt;
The entry point to the Web service is the app.py file where we have the POST Method match_topics.&lt;br /&gt;
This receives the input in a json format from Expertiza. The input will contain a list of task ids, and then an Object of users, which each contain their student id and correlated bids that they made. Each bid contains a task id, a priority, and a timestamp. The input format was reworked to align to this style since it made more sense to have each student have a list of bids instead of the previous implementation which did not have this case. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:App2508.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''json parser'' =====&lt;br /&gt;
The json parser converts the json into a Dictionary. The previous implementation also had the parser create a preferences dictionary for the Student to store their topic preferences and one for Topics to store list of topics which have been selected by students and also the priority for the selection using the Timestamps. However, this was removed due to the Single Responsibility Principle. We felt the json parser was doing too much and should only be parsing the json!&lt;br /&gt;
&lt;br /&gt;
[[File:init_parser.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The student priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:student_prio.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The topic priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:topic_priorities.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== ''Test Input'' =====&lt;br /&gt;
&lt;br /&gt;
Sample Test case:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Case:&amp;lt;/b&amp;gt; There are a few very popular topics and the students who bid for them and bid early should receive it.&lt;br /&gt;
Popular Topics: 3969, 3971, 3972&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;tid&amp;quot;: [4427, 4428, 4429, 4430],&lt;br /&gt;
    &amp;quot;users&amp;quot;: {&lt;br /&gt;
      &amp;quot;40763&amp;quot;: {&lt;br /&gt;
          &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4429&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40764&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4427&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40765&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:15 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:16 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:17 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4428&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;max_accepted_proposals&amp;quot;: 3&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''Output'' =====&lt;br /&gt;
&lt;br /&gt;
 Since there is competition for these topics, the algorithm recognizes this and makes sure to assign them only to the students who bid for it.&lt;br /&gt;
		Other students who picked other topics or did not pick anything are assigned different topics.&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
    &amp;quot;40763&amp;quot;: [&lt;br /&gt;
        4427,&lt;br /&gt;
        4428,&lt;br /&gt;
        4430&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40764&amp;quot;: [&lt;br /&gt;
        4428,&lt;br /&gt;
        4430,&lt;br /&gt;
        4429&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40765&amp;quot;: [&lt;br /&gt;
        4429,&lt;br /&gt;
        4427,&lt;br /&gt;
        4430&lt;br /&gt;
    ]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== ''Controller'' ===&lt;br /&gt;
&lt;br /&gt;
The controller includes 8 methods that handle the review bidding process. The public methods cover authorization, rendering views, saving user bids, and coordinating review assignment. The private methods support these functions by abstracting data gathering and algorithm coordination logic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Method: action_allowed? ======&lt;br /&gt;
&lt;br /&gt;
This method controls user access to controller actions. It allows 'Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator', and 'Student' roles to access show, set_priority, and index. Other actions are restricted to non-student roles. It ensures proper permissions for accessing review bidding features.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG|700px]]&lt;br /&gt;
&lt;br /&gt;
====== Method: index ======&lt;br /&gt;
&lt;br /&gt;
This method gathers information for the &amp;quot;Your Work&amp;quot; page, where users can view their assigned reviews. It checks user identity, retrieves associated reviews, and counts completed reviews. The view rendered is sign_up_sheet/review_bids_others_work.View: others_work.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_index.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: show ======&lt;br /&gt;
&lt;br /&gt;
This method renders the bidding page where users select topics they'd prefer to review. It fetches the assignment, available topics, and any existing bids. Already assigned or signed-up topics are excluded. The page also lists any assigned reviews.View: show.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_show.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: set_priority ======&lt;br /&gt;
&lt;br /&gt;
This method stores or updates a participant's topic preferences. It removes old bids not in the current selection and creates or updates the remaining bids with new priorities. This method is triggered when users submit their topic rankings on the bidding page.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_set_priority.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_bidding ======&lt;br /&gt;
&lt;br /&gt;
This method coordinates the assignment of review topics. It gathers reviewer IDs and invokes the bidding algorithm using a service. It validates the output and uses ReviewBid.assign_review_topics to perform the actual assignment. Bidding is then disabled.&lt;br /&gt;
&lt;br /&gt;
[[File:Assign_bidding.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
====== Method: fetch_reviewer_ids (Private) ======&lt;br /&gt;
&lt;br /&gt;
This helper method retrieves all AssignmentParticipant IDs for a given assignment. These IDs represent the reviewers participating in the bidding process.&lt;br /&gt;
&lt;br /&gt;
====== Method: process_bidding (Private) ======&lt;br /&gt;
This helper method delegates the logic for running the bidding algorithm to the service class ReviewBiddingAlgorithmService. It takes the assignment ID and list of reviewers as input and returns matched topic assignments.&lt;br /&gt;
&lt;br /&gt;
====== Method: ensure_valid_topics (Private) ======&lt;br /&gt;
This method ensures that all reviewers have valid topic assignment entries, even if the algorithm returns nothing (e.g., due to web service failure). It initializes empty topic arrays for any missing reviewers.&lt;br /&gt;
&lt;br /&gt;
[[File:Controller_private_methods.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
=== ''Service'' ===&lt;br /&gt;
&lt;br /&gt;
The ReviewBiddingAlgorithmService is a service object responsible for handling communication between the application and the external web service that executes the review bidding algorithm. It prepares bidding data, sends it to the web service, processes the response, and provides a fallback mechanism in case of failure.&lt;br /&gt;
&lt;br /&gt;
This service allows to encapsulate all logic required to interact with the external topic-matching web service. It separates the algorithm execution concerns from the controller, improving modularity, testability, and maintainability of the code.&lt;br /&gt;
&lt;br /&gt;
====== Method: self.process_bidding ======&lt;br /&gt;
&lt;br /&gt;
This is the primary entry point for the controller. It accepts the assignment_id and a list of reviewer_ids, then prepares the bidding data by calling ReviewBid.bidding_data(...). It passes the data to the web service by calling run_bidding_algorithm. If the web service is unavailable or fails, the method logs an error and falls back to an internal method: ReviewBid.fallback_algorithm. The result is returned as a hash mapping reviewer IDs to arrays of assigned topic IDs.&lt;br /&gt;
&lt;br /&gt;
====== Method: self.run_bidding_algorithm ======&lt;br /&gt;
&lt;br /&gt;
This method retrieves the review bidding web service URL from the app configuration (config/webservices.yml) and calls the internal send_bidding_request method to make the actual request.It logs the outgoing URL for debugging and delegates the response parsing.&lt;br /&gt;
&lt;br /&gt;
====== Private Method: send_bidding_request ======&lt;br /&gt;
&lt;br /&gt;
This private class method handles the HTTP POST request using RestClient. It sends the bidding data as JSON and expects a JSON response. If the request fails due to a connection error, server error, or timeout, the method logs the exception and returns false, allowing the caller to trigger a fallback.&lt;br /&gt;
&lt;br /&gt;
[[File:Review_bidding_algorithm_service.JPG|700px]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Fallback Algorithm ===&lt;br /&gt;
=====   ''Introduction''   =====&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm in Expertiza is designed to ensure automatic topic assignment when the primary Bidding Algorithm fails due to Web Service unavailability.  &lt;br /&gt;
&lt;br /&gt;
Normally, Expertiza allows reviewers to bid on topics, and the ''ReviewBiddingAlgorithmService'' processes these bids to assign topics. However, when this web service ''fails'' (due to API downtime, server issues, or unexpected errors), the system must switch to fallback and automatically assign topics to reviewers.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Solution''   =====&lt;br /&gt;
It is triggered when the web service is unavailable. It ensures fair topic assignment by:  &lt;br /&gt;
* Prioritizing topics with the largest teams.  &lt;br /&gt;
* Using a round-robin approach to distribute topics among reviewers.  &lt;br /&gt;
* Ensuring reviewers do not get their own team’s topic.  &lt;br /&gt;
&lt;br /&gt;
=====   ''When is this Used?''  ===== &lt;br /&gt;
* The ReviewBiddingAlgorithmService fails due to an API issue.  &lt;br /&gt;
* The web service times out or returns an error.  &lt;br /&gt;
* Unexpected exceptions occur in the bidding process.  &lt;br /&gt;
&lt;br /&gt;
Instead of stopping the review process, the system automatically falls-back to an internal algorithm to distribute topics.  &lt;br /&gt;
&lt;br /&gt;
=====   ''How Does the Fallback Algorithm Work?''   ===== &lt;br /&gt;
The algorithm follows these **four main steps:  &lt;br /&gt;
* Fetch available topics – Retrieves all topics for the given assignment.  &lt;br /&gt;
* Sort topics by team size – Topics with more members are given priority.  &lt;br /&gt;
* Create a topic queue – Topics are arranged in descending order of team size.  &lt;br /&gt;
* Assign topics in a round-robin manner – Reviewers are assigned topics while avoiding their own team's topic.  &lt;br /&gt;
&lt;br /&gt;
This ensures ''fair and balanced'' distribution of topics.&lt;br /&gt;
  &lt;br /&gt;
=====   ''Implementation - Controller Code (Triggering the Fallback)''   =====&lt;br /&gt;
If the primary bidding service fails, the system catches the error and calls the Fallback Algorithm.&lt;br /&gt;
&lt;br /&gt;
[[File:Controller-code.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: If ''ReviewBiddingAlgorithmService'' fails, the system automatically calls fallback_algorithm.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Implementation - Model Code (Fallback Algorithm)''   =====&lt;br /&gt;
This method ensures fair topic assignment when the bidding system fails.&lt;br /&gt;
&lt;br /&gt;
[[File:Model-code.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: This function ensures every reviewer receives a topic without requiring manual intervention.&lt;br /&gt;
&lt;br /&gt;
=====   ''RSpec Testing of Fallback Algorithm''   =====&lt;br /&gt;
To verify correctness, we use unit tests in ''review_bid_spec.rb''&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm ensures that ''topics are assigned fairly'' even when the primary bidding service fails. By prioritizing ''larger teams'', ''avoiding self-review'', and using a ''round-robin strategy'', the fallback mechanism keeps the review process smooth and automatic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
This section outlines the test plan for this project including testing scenarios/edge cases, the manual testing plan, and the automatic/RSpec testing plan.&lt;br /&gt;
&lt;br /&gt;
=== ''Testing Scenarios'' ===&lt;br /&gt;
This section outlines the various bidding scenarios that could occur. These scenarios should be tested in either '''Manual Testing''' or '''Automatic Testing'''.&lt;br /&gt;
&lt;br /&gt;
==== Basic Bidding Scenario ====&lt;br /&gt;
*Reviewers bid on multiple projects at different times&lt;br /&gt;
** Bidding algorithm should give priority to reviewers that bid first and should assign based on reviewers ranking&lt;br /&gt;
&lt;br /&gt;
====   Edge Cases   ====&lt;br /&gt;
* All reviewers bid on the same project&lt;br /&gt;
** If different time stamps: bidding algorithm should give priority to reviewers that bid first&lt;br /&gt;
** If same time stamps: bidding algorithm should assign reviews randomly&lt;br /&gt;
* None of the reviews bid on any projects&lt;br /&gt;
** Bidding algorithm should assign reviews randomly&lt;br /&gt;
* Reviewer bids on their own project&lt;br /&gt;
** Bidding algorithm should not allow a reviewer to bid on their own project and should have validation to prevent assigning a reviewer their own project&lt;br /&gt;
* None of the reviewers bid on a specific project&lt;br /&gt;
** Bidding algorithm should still assign reviewers to this project&lt;br /&gt;
&lt;br /&gt;
===   ''Manual Testing''   ===&lt;br /&gt;
Manual testing should be preformed on an Expertiza server and webserver platform &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Plan for Expertiza Server ====&lt;br /&gt;
* test that an instructor can allow review bidding for an assignment&lt;br /&gt;
* test that server routes correctly when review bidding is allowed&lt;br /&gt;
** test that task box links to bidding page before algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to bidding page before algorithm is run&lt;br /&gt;
** test that task box links to review page with bidding information after algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to review page with bidding information after algorithm is run&lt;br /&gt;
* test that the bidding UI is implemented as expected&lt;br /&gt;
* test that a participant can bid on projects to review&lt;br /&gt;
** test that a participant can move projects into the bidding column&lt;br /&gt;
** test that a participant can reorder projects in the bidding column&lt;br /&gt;
** test that a participant's bidding preferences save&lt;br /&gt;
** test that a participant can't bid for their own topic&lt;br /&gt;
* test that run algorithm button calls webserver with correct information and returns review assignments for each user&lt;br /&gt;
&lt;br /&gt;
==== Directions for Manual Testing of Expertiza Server ====&lt;br /&gt;
1. Go to [http://152.7.99.70:8081/ testing server] &amp;lt;br&amp;gt;&lt;br /&gt;
2. Log in as username: '''instructor6''' password: '''password''' &amp;lt;br&amp;gt;&lt;br /&gt;
3. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''General''' tab make sure '''Has teams?''' and '''Has topics?''' are checked&lt;br /&gt;
:# In the '''Topics''' tab check '''Allow review to choose which topic to review?''' then click '''save'''&lt;br /&gt;
:# In the '''Topics''' tab select '''Bidding''' then click '''save'''&lt;br /&gt;
4. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# This UI is based on '''instructor6''' being a '''participant''' assigned to topic '''Topic4'''&lt;br /&gt;
::# The UI blocks user from bidding on their own project &lt;br /&gt;
::# Check that user can bid on topics and reorder bids&lt;br /&gt;
::# Check that users topic preferences save on page refresh&lt;br /&gt;
::# Impersonate other participants and repeat bidding UI tests ('''student7601''', '''student7602''', '''student7603''', '''student7604''', '''student7605''', '''student7606''', '''student7607''', '''student7608''', '''student7609'')&lt;br /&gt;
5. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''Topics''' tab click '''Run Review Algorithm''' button&lt;br /&gt;
6. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# '''E2085 Manual Testing review''' should now link to the reviewing page&lt;br /&gt;
::# The number of required reviews should already be displayed&lt;br /&gt;
::# A '''Request Another Review''' button should be present unless reviews listed is equal to the number of reviews allowed&lt;br /&gt;
::# '''Begin''' a review and test '''save''' and '''submit'''&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Demo Video for Expertiza Server ====&lt;br /&gt;
Video demonstration of manual testing: [https://www.screencast.com/t/0rSg1zDW here]&lt;br /&gt;
&lt;br /&gt;
=== ''Automatic/PyTest Testing '' ===&lt;br /&gt;
Pytest tests are written for the webservice to test a well formed and a malformed request.&lt;br /&gt;
&lt;br /&gt;
===   ''Automatic/RSpec Testing ''   ===&lt;br /&gt;
RSpec tests will need to be refactored according to the changes that we make in the expertiza repository. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== RSpec Testing Plan ====&lt;br /&gt;
These RSpec tests will need to:&lt;br /&gt;
* test basic functionality of review bids controller&lt;br /&gt;
* test basic functionality of review bid model&lt;br /&gt;
&lt;br /&gt;
==== Directions for RSpec Testing ====&lt;br /&gt;
:# on personal device using [https://github.com/ncsu-ngw/expertiza forked repo]&lt;br /&gt;
:# Run the following commands:&lt;br /&gt;
&lt;br /&gt;
 # review bids controller: &lt;br /&gt;
 bundle exec rspec spec/controllers/review_bids_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
 # review bid model: &lt;br /&gt;
 bundle exec rspec spec/models/review_bid_spec.rb&lt;br /&gt;
 &lt;br /&gt;
 # review bidding algorithm service:&lt;br /&gt;
 bundle exec rspec spec/services/review_bidding_algorithm_service_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Test Coverage==&lt;br /&gt;
Code Climate: [https://codeclimate.com/github/expertiza/expertiza/pull/2931 here]&lt;br /&gt;
&lt;br /&gt;
[[File:code-climate.png|700px]]&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
&lt;br /&gt;
'''Mentor:''' Janice Uwujaren (juwujar) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ashwin Muniswamy (akumarm) &amp;lt;br&amp;gt;&lt;br /&gt;
Arturo Serdan (aaserdan) &amp;lt;br&amp;gt;&lt;br /&gt;
Nicholas Winsen (nwinsen) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
''Previous Implementations'': &lt;br /&gt;
[[https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Objectives]],&amp;lt;br&amp;gt;&lt;br /&gt;
[[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review 1]],&amp;lt;br&amp;gt;[[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review 2]]&amp;lt;br&amp;gt;&lt;br /&gt;
''Bidding Interface Implementation Pull Request'': [[https://github.com/expertiza/expertiza/pull/778 3]]&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'':  &amp;lt;br&amp;gt;&lt;br /&gt;
''Expertiza Server'': &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
''Video Demo'': https://app.screencast.com/vaiJnWpHf0r07&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Code-climate.png&amp;diff=162635</id>
		<title>File:Code-climate.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Code-climate.png&amp;diff=162635"/>
		<updated>2025-03-25T01:47:39Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162632</id>
		<title>CSC/ECE 517 Spring 2025 - E2508. Reimplement bidding-algorithm web service</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162632"/>
		<updated>2025-03-25T01:45:37Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Project Overview==&lt;br /&gt;
===   ''Background''   ===&lt;br /&gt;
The previous implementation of the bidding service was hosted on peerlogic by a former student. The University no longer has access to this hosting service, and  is requiring a new solution. It is also asked that the webservice accept a better and cleaner json format which is easier to interpret and read.&lt;br /&gt;
&lt;br /&gt;
===   ''Objectives''   ===&lt;br /&gt;
# Reimplement trading cycles on a webservice&lt;br /&gt;
# Figure out a new hosting solution for the BiddingService web service. (VCL)&lt;br /&gt;
# Host the webservice on VCL&lt;br /&gt;
# Using tmux, figure out a way to keep the process running with a production wsgi service compatible with Flask.&lt;br /&gt;
# Create new tests for the repository&lt;br /&gt;
# Create a list of required packages that future maintainers can install easily&lt;br /&gt;
# Create a tests directory that users can test the functionality of the code with&lt;br /&gt;
# Modularize the code further, eliminate code smells.&lt;br /&gt;
# Refactor existing backend logic to account for the new json format&lt;br /&gt;
# Refactor existing backend code to send HTTP requests to the correct IP address&lt;br /&gt;
# Refactor existing frontend code to provide a list for users to select multiple topics on the frontend&lt;br /&gt;
# Allow users to prioritize their topic selection on the frontend&lt;br /&gt;
# Users should not be allowed to bid on their review topics on the frontend&lt;br /&gt;
# Display the results of the matched topics on the frontend&lt;br /&gt;
&lt;br /&gt;
===   ''Previous Work''   ===&lt;br /&gt;
There have been three previous implementations: &amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2019 [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Spring 2020 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2020 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2024 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2508._Reimplement_bidding-algorithm_web_service here]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/2931 &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Files Modified''   ===&lt;br /&gt;
This is a list of all the files added or changed in completing this project. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Changed'': &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/app.py - accomodated for changes in JsonParser&lt;br /&gt;
*app/json_parser.py - moved functions out due to SRP&lt;br /&gt;
*app/topics_matcher.py&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Added'': &amp;lt;br&amp;gt;&lt;br /&gt;
*app/tests/sample.json &amp;lt;br&amp;gt; - Sample input for the tests.&lt;br /&gt;
&lt;br /&gt;
*app/tests/test_assignment.py &amp;lt;br&amp;gt; Test File to test forms of input - tests both a successful and unsuccessful input&lt;br /&gt;
&lt;br /&gt;
*app/utils/popular_topics.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/student_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/topic_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
&lt;br /&gt;
*setup.py - required for wsgi&lt;br /&gt;
*wsgi.py - for hosting the server via gunicorn on VCL.&lt;br /&gt;
*.gitignore - to ignore anything that we may not want pushed (mostly for venv)&lt;br /&gt;
*requirements.txt - a list of requirements made easy for future maintainers&lt;br /&gt;
&lt;br /&gt;
=== ''Webservice'' ===&lt;br /&gt;
===== ''app'' =====&lt;br /&gt;
&lt;br /&gt;
The entry point to the Web service is the app.py file where we have the POST Method match_topics.&lt;br /&gt;
This receives the input in a json format from Expertiza. The input will contain a list of task ids, and then an Object of users, which each contain their student id and correlated bids that they made. Each bid contains a task id, a priority, and a timestamp. The input format was reworked to align to this style since it made more sense to have each student have a list of bids instead of the previous implementation which did not have this case. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:App2508.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''json parser'' =====&lt;br /&gt;
The json parser converts the json into a Dictionary. The previous implementation also had the parser create a preferences dictionary for the Student to store their topic preferences and one for Topics to store list of topics which have been selected by students and also the priority for the selection using the Timestamps. However, this was removed due to the Single Responsibility Principle. We felt the json parser was doing too much and should only be parsing the json!&lt;br /&gt;
&lt;br /&gt;
[[File:init_parser.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The student priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:student_prio.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The topic priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:topic_priorities.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== ''Test Input'' =====&lt;br /&gt;
&lt;br /&gt;
Sample Test case:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Case:&amp;lt;/b&amp;gt; There are a few very popular topics and the students who bid for them and bid early should receive it.&lt;br /&gt;
Popular Topics: 3969, 3971, 3972&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;tid&amp;quot;: [4427, 4428, 4429, 4430],&lt;br /&gt;
    &amp;quot;users&amp;quot;: {&lt;br /&gt;
      &amp;quot;40763&amp;quot;: {&lt;br /&gt;
          &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4429&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40764&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4427&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40765&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:15 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:16 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:17 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4428&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;max_accepted_proposals&amp;quot;: 3&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''Output'' =====&lt;br /&gt;
&lt;br /&gt;
 Since there is competition for these topics, the algorithm recognizes this and makes sure to assign them only to the students who bid for it.&lt;br /&gt;
		Other students who picked other topics or did not pick anything are assigned different topics.&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
    &amp;quot;40763&amp;quot;: [&lt;br /&gt;
        4427,&lt;br /&gt;
        4428,&lt;br /&gt;
        4430&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40764&amp;quot;: [&lt;br /&gt;
        4428,&lt;br /&gt;
        4430,&lt;br /&gt;
        4429&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40765&amp;quot;: [&lt;br /&gt;
        4429,&lt;br /&gt;
        4427,&lt;br /&gt;
        4430&lt;br /&gt;
    ]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== ''Controller'' ===&lt;br /&gt;
&lt;br /&gt;
The controller includes 8 methods that handle the review bidding process. The public methods cover authorization, rendering views, saving user bids, and coordinating review assignment. The private methods support these functions by abstracting data gathering and algorithm coordination logic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Method: action_allowed? ======&lt;br /&gt;
&lt;br /&gt;
This method controls user access to controller actions. It allows 'Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator', and 'Student' roles to access show, set_priority, and index. Other actions are restricted to non-student roles. It ensures proper permissions for accessing review bidding features.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_action_allowed.JPG]]&lt;br /&gt;
&lt;br /&gt;
====== Method: index ======&lt;br /&gt;
&lt;br /&gt;
This method gathers information for the &amp;quot;Your Work&amp;quot; page, where users can view their assigned reviews. It checks user identity, retrieves associated reviews, and counts completed reviews. The view rendered is sign_up_sheet/review_bids_others_work.View: others_work.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_index.JPG]]&lt;br /&gt;
&lt;br /&gt;
====== Method: show ======&lt;br /&gt;
&lt;br /&gt;
This method renders the bidding page where users select topics they'd prefer to review. It fetches the assignment, available topics, and any existing bids. Already assigned or signed-up topics are excluded. The page also lists any assigned reviews.View: show.html.erb&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_show.JPG]]&lt;br /&gt;
&lt;br /&gt;
====== Method: set_priority ======&lt;br /&gt;
&lt;br /&gt;
This method stores or updates a participant's topic preferences. It removes old bids not in the current selection and creates or updates the remaining bids with new priorities. This method is triggered when users submit their topic rankings on the bidding page.&lt;br /&gt;
&lt;br /&gt;
[[File:Updated_controller_set_priority.JPG]]&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_bidding ======&lt;br /&gt;
&lt;br /&gt;
This method coordinates the assignment of review topics. It gathers reviewer IDs and invokes the bidding algorithm using a service. It validates the output and uses ReviewBid.assign_review_topics to perform the actual assignment. Bidding is then disabled.&lt;br /&gt;
&lt;br /&gt;
[[File:Assign_bidding.JPG]]&lt;br /&gt;
&lt;br /&gt;
====== Method: fetch_reviewer_ids (Private) ======&lt;br /&gt;
&lt;br /&gt;
This helper method retrieves all AssignmentParticipant IDs for a given assignment. These IDs represent the reviewers participating in the bidding process.&lt;br /&gt;
&lt;br /&gt;
====== Method: process_bidding (Private) ======&lt;br /&gt;
This helper method delegates the logic for running the bidding algorithm to the service class ReviewBiddingAlgorithmService. It takes the assignment ID and list of reviewers as input and returns matched topic assignments.&lt;br /&gt;
&lt;br /&gt;
====== Method: ensure_valid_topics (Private) ======&lt;br /&gt;
This method ensures that all reviewers have valid topic assignment entries, even if the algorithm returns nothing (e.g., due to web service failure). It initializes empty topic arrays for any missing reviewers.&lt;br /&gt;
&lt;br /&gt;
[[File:Controller_private_methods.JPG]]&lt;br /&gt;
&lt;br /&gt;
=== ''Service'' ===&lt;br /&gt;
&lt;br /&gt;
The ReviewBiddingAlgorithmService is a service object responsible for handling communication between the application and the external web service that executes the review bidding algorithm. It prepares bidding data, sends it to the web service, processes the response, and provides a fallback mechanism in case of failure.&lt;br /&gt;
&lt;br /&gt;
This service allows to encapsulate all logic required to interact with the external topic-matching web service. It separates the algorithm execution concerns from the controller, improving modularity, testability, and maintainability of the code.&lt;br /&gt;
&lt;br /&gt;
====== Method: self.process_bidding ======&lt;br /&gt;
&lt;br /&gt;
This is the primary entry point for the controller. It accepts the assignment_id and a list of reviewer_ids, then prepares the bidding data by calling ReviewBid.bidding_data(...). It passes the data to the web service by calling run_bidding_algorithm. If the web service is unavailable or fails, the method logs an error and falls back to an internal method: ReviewBid.fallback_algorithm. The result is returned as a hash mapping reviewer IDs to arrays of assigned topic IDs.&lt;br /&gt;
&lt;br /&gt;
====== Method: self.run_bidding_algorithm ======&lt;br /&gt;
&lt;br /&gt;
This method retrieves the review bidding web service URL from the app configuration (config/webservices.yml) and calls the internal send_bidding_request method to make the actual request.It logs the outgoing URL for debugging and delegates the response parsing.&lt;br /&gt;
&lt;br /&gt;
====== Private Method: send_bidding_request ======&lt;br /&gt;
&lt;br /&gt;
This private class method handles the HTTP POST request using RestClient. It sends the bidding data as JSON and expects a JSON response. If the request fails due to a connection error, server error, or timeout, the method logs the exception and returns false, allowing the caller to trigger a fallback.&lt;br /&gt;
&lt;br /&gt;
[[File:Review_bidding_algorithm_service.JPG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Fallback Algorithm ===&lt;br /&gt;
=====   ''Introduction''   =====&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm in Expertiza is designed to ensure automatic topic assignment when the primary Bidding Algorithm fails due to Web Service unavailability.  &lt;br /&gt;
&lt;br /&gt;
Normally, Expertiza allows reviewers to bid on topics, and the ''ReviewBiddingAlgorithmService'' processes these bids to assign topics. However, when this web service ''fails'' (due to API downtime, server issues, or unexpected errors), the system must switch to fallback and automatically assign topics to reviewers.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Solution''   =====&lt;br /&gt;
It is triggered when the web service is unavailable. It ensures fair topic assignment by:  &lt;br /&gt;
* Prioritizing topics with the largest teams.  &lt;br /&gt;
* Using a round-robin approach to distribute topics among reviewers.  &lt;br /&gt;
* Ensuring reviewers do not get their own team’s topic.  &lt;br /&gt;
&lt;br /&gt;
=====   ''When is this Used?''  ===== &lt;br /&gt;
* The ReviewBiddingAlgorithmService fails due to an API issue.  &lt;br /&gt;
* The web service times out or returns an error.  &lt;br /&gt;
* Unexpected exceptions occur in the bidding process.  &lt;br /&gt;
&lt;br /&gt;
Instead of stopping the review process, the system automatically falls-back to an internal algorithm to distribute topics.  &lt;br /&gt;
&lt;br /&gt;
=====   ''How Does the Fallback Algorithm Work?''   ===== &lt;br /&gt;
The algorithm follows these **four main steps:  &lt;br /&gt;
* Fetch available topics – Retrieves all topics for the given assignment.  &lt;br /&gt;
* Sort topics by team size – Topics with more members are given priority.  &lt;br /&gt;
* Create a topic queue – Topics are arranged in descending order of team size.  &lt;br /&gt;
* Assign topics in a round-robin manner – Reviewers are assigned topics while avoiding their own team's topic.  &lt;br /&gt;
&lt;br /&gt;
This ensures ''fair and balanced'' distribution of topics.&lt;br /&gt;
  &lt;br /&gt;
=====   ''Implementation - Controller Code (Triggering the Fallback)''   =====&lt;br /&gt;
If the primary bidding service fails, the system catches the error and calls the Fallback Algorithm.&lt;br /&gt;
&lt;br /&gt;
[[File:Controller-code.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: If ''ReviewBiddingAlgorithmService'' fails, the system automatically calls fallback_algorithm.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Implementation - Model Code (Fallback Algorithm)''   =====&lt;br /&gt;
This method ensures fair topic assignment when the bidding system fails.&lt;br /&gt;
&lt;br /&gt;
[[File:Model-code.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: This function ensures every reviewer receives a topic without requiring manual intervention.&lt;br /&gt;
&lt;br /&gt;
=====   ''RSpec Testing of Fallback Algorithm''   =====&lt;br /&gt;
To verify correctness, we use unit tests in ''review_bid_spec.rb''&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm ensures that ''topics are assigned fairly'' even when the primary bidding service fails. By prioritizing ''larger teams'', ''avoiding self-review'', and using a ''round-robin strategy'', the fallback mechanism keeps the review process smooth and automatic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
This section outlines the test plan for this project including testing scenarios/edge cases, the manual testing plan, and the automatic/RSpec testing plan.&lt;br /&gt;
&lt;br /&gt;
=== ''Testing Scenarios'' ===&lt;br /&gt;
This section outlines the various bidding scenarios that could occur. These scenarios should be tested in either '''Manual Testing''' or '''Automatic Testing'''.&lt;br /&gt;
&lt;br /&gt;
==== Basic Bidding Scenario ====&lt;br /&gt;
*Reviewers bid on multiple projects at different times&lt;br /&gt;
** Bidding algorithm should give priority to reviewers that bid first and should assign based on reviewers ranking&lt;br /&gt;
&lt;br /&gt;
====   Edge Cases   ====&lt;br /&gt;
* All reviewers bid on the same project&lt;br /&gt;
** If different time stamps: bidding algorithm should give priority to reviewers that bid first&lt;br /&gt;
** If same time stamps: bidding algorithm should assign reviews randomly&lt;br /&gt;
* None of the reviews bid on any projects&lt;br /&gt;
** Bidding algorithm should assign reviews randomly&lt;br /&gt;
* Reviewer bids on their own project&lt;br /&gt;
** Bidding algorithm should not allow a reviewer to bid on their own project and should have validation to prevent assigning a reviewer their own project&lt;br /&gt;
* None of the reviewers bid on a specific project&lt;br /&gt;
** Bidding algorithm should still assign reviewers to this project&lt;br /&gt;
&lt;br /&gt;
===   ''Manual Testing''   ===&lt;br /&gt;
Manual testing should be preformed on an Expertiza server and webserver platform &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Plan for Expertiza Server ====&lt;br /&gt;
* test that an instructor can allow review bidding for an assignment&lt;br /&gt;
* test that server routes correctly when review bidding is allowed&lt;br /&gt;
** test that task box links to bidding page before algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to bidding page before algorithm is run&lt;br /&gt;
** test that task box links to review page with bidding information after algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to review page with bidding information after algorithm is run&lt;br /&gt;
* test that the bidding UI is implemented as expected&lt;br /&gt;
* test that a participant can bid on projects to review&lt;br /&gt;
** test that a participant can move projects into the bidding column&lt;br /&gt;
** test that a participant can reorder projects in the bidding column&lt;br /&gt;
** test that a participant's bidding preferences save&lt;br /&gt;
** test that a participant can't bid for their own topic&lt;br /&gt;
* test that run algorithm button calls webserver with correct information and returns review assignments for each user&lt;br /&gt;
&lt;br /&gt;
==== Directions for Manual Testing of Expertiza Server ====&lt;br /&gt;
1. Go to [http://152.7.99.70:8081/ testing server] &amp;lt;br&amp;gt;&lt;br /&gt;
2. Log in as username: '''instructor6''' password: '''password''' &amp;lt;br&amp;gt;&lt;br /&gt;
3. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''General''' tab make sure '''Has teams?''' and '''Has topics?''' are checked&lt;br /&gt;
:# In the '''Topics''' tab check '''Allow review to choose which topic to review?''' then click '''save'''&lt;br /&gt;
:# In the '''Topics''' tab select '''Bidding''' then click '''save'''&lt;br /&gt;
4. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# This UI is based on '''instructor6''' being a '''participant''' assigned to topic '''Topic4'''&lt;br /&gt;
::# The UI blocks user from bidding on their own project &lt;br /&gt;
::# Check that user can bid on topics and reorder bids&lt;br /&gt;
::# Check that users topic preferences save on page refresh&lt;br /&gt;
::# Impersonate other participants and repeat bidding UI tests ('''student7601''', '''student7602''', '''student7603''', '''student7604''', '''student7605''', '''student7606''', '''student7607''', '''student7608''', '''student7609'')&lt;br /&gt;
5. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''Topics''' tab click '''Run Review Algorithm''' button&lt;br /&gt;
6. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# '''E2085 Manual Testing review''' should now link to the reviewing page&lt;br /&gt;
::# The number of required reviews should already be displayed&lt;br /&gt;
::# A '''Request Another Review''' button should be present unless reviews listed is equal to the number of reviews allowed&lt;br /&gt;
::# '''Begin''' a review and test '''save''' and '''submit'''&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Demo Video for Expertiza Server ====&lt;br /&gt;
Video demonstration of manual testing: [https://www.screencast.com/t/0rSg1zDW here]&lt;br /&gt;
&lt;br /&gt;
=== ''Automatic/PyTest Testing '' ===&lt;br /&gt;
Pytest tests are written for the webservice to test a well formed and a malformed request.&lt;br /&gt;
&lt;br /&gt;
===   ''Automatic/RSpec Testing ''   ===&lt;br /&gt;
RSpec tests will need to be refactored according to the changes that we make in the expertiza repository. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== RSpec Testing Plan ====&lt;br /&gt;
These RSpec tests will need to:&lt;br /&gt;
* test basic functionality of review bids controller&lt;br /&gt;
* test basic functionality of review bid model&lt;br /&gt;
&lt;br /&gt;
==== Directions for RSpec Testing ====&lt;br /&gt;
:# on personal device using [https://github.com/ncsu-ngw/expertiza forked repo]&lt;br /&gt;
:# Run the following commands:&lt;br /&gt;
&lt;br /&gt;
 # review bids controller: &lt;br /&gt;
 bundle exec rspec spec/controllers/review_bids_controller_spec.rb&lt;br /&gt;
 &lt;br /&gt;
 # review bidding algorithm service:&lt;br /&gt;
 bundle exec rspec spec/services/review_bidding_algorithm_service_spec.rb&lt;br /&gt;
&lt;br /&gt;
 # review bid model: &lt;br /&gt;
 bundle exec rspec spec/models/review_bid_spec.rb&lt;br /&gt;
&lt;br /&gt;
==== RSpec Testing Demo Video ====&lt;br /&gt;
Video demonstration of RSpec tests passing: [https://www.screencast.com/t/uSWZHSX8s here]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Coverage==&lt;br /&gt;
Code Climate: [https://codeclimate.com/github/expertiza/expertiza/pull/2931 here]&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
&lt;br /&gt;
'''Mentor:''' Janice Uwujaren (juwujar) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ashwin Muniswamy (akumarm) &amp;lt;br&amp;gt;&lt;br /&gt;
Arturo Serdan (aaserdan) &amp;lt;br&amp;gt;&lt;br /&gt;
Nicholas Winsen (nwinsen) &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
''Previous Implementations'': &lt;br /&gt;
[[https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Objectives]],&amp;lt;br&amp;gt;&lt;br /&gt;
[[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review 1]],&amp;lt;br&amp;gt;[[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review 2]]&amp;lt;br&amp;gt;&lt;br /&gt;
''Bidding Interface Implementation Pull Request'': [[https://github.com/expertiza/expertiza/pull/778 3]]&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'':  &amp;lt;br&amp;gt;&lt;br /&gt;
''Expertiza Server'': &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
''Video Demo'': https://app.screencast.com/vaiJnWpHf0r07&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162426</id>
		<title>CSC/ECE 517 Spring 2025 - E2508. Reimplement bidding-algorithm web service</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162426"/>
		<updated>2025-03-24T22:30:13Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Project Overview==&lt;br /&gt;
===   ''Background''   ===&lt;br /&gt;
The previous implementation of the bidding service was hosted on peerlogic by a former student. The University no longer has access to this hosting service, and  is requiring a new solution. It is also asked that the webservice accept a better and cleaner json format which is easier to interpret and read.&lt;br /&gt;
&lt;br /&gt;
===   ''Objectives''   ===&lt;br /&gt;
# Reimplement trading cycles on a webservice&lt;br /&gt;
# Figure out a new hosting solution for the BiddingService web service. (VCL)&lt;br /&gt;
# Host the webservice on VCL&lt;br /&gt;
# Using tmux, figure out a way to keep the process running with a production wsgi service compatible with Flask.&lt;br /&gt;
# Create new tests for the repository&lt;br /&gt;
# Create a list of required packages that future maintainers can install easily&lt;br /&gt;
# Create a tests directory that users can test the functionality of the code with&lt;br /&gt;
# Modularize the code further, eliminate code smells.&lt;br /&gt;
# Refactor existing backend logic to account for the new json format&lt;br /&gt;
# Refactor existing backend code to send HTTP requests to the correct IP address&lt;br /&gt;
# Refactor existing frontend code to provide a list for users to select multiple topics on the frontend&lt;br /&gt;
# Allow users to prioritize their topic selection on the frontend&lt;br /&gt;
# Users should not be allowed to bid on their review topics on the frontend&lt;br /&gt;
# Display the results of the matched topics on the frontend&lt;br /&gt;
&lt;br /&gt;
===   ''Previous Work''   ===&lt;br /&gt;
There have been three previous implementations: &amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2019 [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Spring 2020 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2020 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2024 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2508._Reimplement_bidding-algorithm_web_service here]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/2931 &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Files Modified''   ===&lt;br /&gt;
This is a list of all the files added or changed in completing this project. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Changed'': &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/app.py - accomodated for changes in JsonParser&lt;br /&gt;
*app/json_parser.py - moved functions out due to SRP&lt;br /&gt;
*app/topics_matcher.py&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Added'': &amp;lt;br&amp;gt;&lt;br /&gt;
*app/tests/sample.json &amp;lt;br&amp;gt; - Sample input for the tests.&lt;br /&gt;
&lt;br /&gt;
*app/tests/test_assignment.py &amp;lt;br&amp;gt; Test File to test forms of input - tests both a successful and unsuccessful input&lt;br /&gt;
&lt;br /&gt;
*app/utils/popular_topics.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/student_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/topic_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
&lt;br /&gt;
*setup.py - required for wsgi&lt;br /&gt;
*wsgi.py - for hosting the server via gunicorn on VCL.&lt;br /&gt;
*.gitignore - to ignore anything that we may not want pushed (mostly for venv)&lt;br /&gt;
*requirements.txt - a list of requirements made easy for future maintainers&lt;br /&gt;
&lt;br /&gt;
=== ''Webservice'' ===&lt;br /&gt;
===== ''app'' =====&lt;br /&gt;
&lt;br /&gt;
The entry point to the Web service is the app.py file where we have the POST Method match_topics.&lt;br /&gt;
This receives the input in a json format from Expertiza. The input will contain a list of task ids, and then an Object of users, which each contain their student id and correlated bids that they made. Each bid contains a task id, a priority, and a timestamp. The input format was reworked to align to this style since it made more sense to have each student have a list of bids instead of the previous implementation which did not have this case. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:App2508.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''json parser'' =====&lt;br /&gt;
The json parser converts the json into a Dictionary. The previous implementation also had the parser create a preferences dictionary for the Student to store their topic preferences and one for Topics to store list of topics which have been selected by students and also the priority for the selection using the Timestamps. However, this was removed due to the Single Responsibility Principle. We felt the json parser was doing too much and should only be parsing the json!&lt;br /&gt;
&lt;br /&gt;
[[File:init_parser.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The student priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:student_prio.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The topic priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:topic_priorities.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== ''Test Input'' =====&lt;br /&gt;
&lt;br /&gt;
Sample Test case:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Case:&amp;lt;/b&amp;gt; There are a few very popular topics and the students who bid for them and bid early should receive it.&lt;br /&gt;
Popular Topics: 3969, 3971, 3972&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;tid&amp;quot;: [4427, 4428, 4429, 4430],&lt;br /&gt;
    &amp;quot;users&amp;quot;: {&lt;br /&gt;
      &amp;quot;40763&amp;quot;: {&lt;br /&gt;
          &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4429&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40764&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4427&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40765&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:15 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:16 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:17 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4428&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;max_accepted_proposals&amp;quot;: 3&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''Output'' =====&lt;br /&gt;
&lt;br /&gt;
 Since there is competition for these topics, the algorithm recognizes this and makes sure to assign them only to the students who bid for it.&lt;br /&gt;
		Other students who picked other topics or did not pick anything are assigned different topics.&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
    &amp;quot;40763&amp;quot;: [&lt;br /&gt;
        4427,&lt;br /&gt;
        4428,&lt;br /&gt;
        4430&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40764&amp;quot;: [&lt;br /&gt;
        4428,&lt;br /&gt;
        4430,&lt;br /&gt;
        4429&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40765&amp;quot;: [&lt;br /&gt;
        4429,&lt;br /&gt;
        4427,&lt;br /&gt;
        4430&lt;br /&gt;
    ]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Fallback Algorithm ===&lt;br /&gt;
=====   ''Introduction''   =====&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm in Expertiza is designed to ensure automatic topic assignment when the primary Bidding Algorithm fails due to Web Service unavailability.  &lt;br /&gt;
&lt;br /&gt;
Normally, Expertiza allows reviewers to bid on topics, and the ''ReviewBiddingAlgorithmService'' processes these bids to assign topics. However, when this web service ''fails'' (due to API downtime, server issues, or unexpected errors), the system must switch to fallback and automatically assign topics to reviewers.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Solution''   =====&lt;br /&gt;
It is triggered when the web service is unavailable. It ensures fair topic assignment by:  &lt;br /&gt;
* Prioritizing topics with the largest teams.  &lt;br /&gt;
* Using a round-robin approach to distribute topics among reviewers.  &lt;br /&gt;
* Ensuring reviewers do not get their own team’s topic.  &lt;br /&gt;
&lt;br /&gt;
=====   ''When is this Used?''  ===== &lt;br /&gt;
* The ReviewBiddingAlgorithmService fails due to an API issue.  &lt;br /&gt;
* The web service times out or returns an error.  &lt;br /&gt;
* Unexpected exceptions occur in the bidding process.  &lt;br /&gt;
&lt;br /&gt;
Instead of stopping the review process, the system automatically falls-back to an internal algorithm to distribute topics.  &lt;br /&gt;
&lt;br /&gt;
=====   ''How Does the Fallback Algorithm Work?''   ===== &lt;br /&gt;
The algorithm follows these **four main steps:  &lt;br /&gt;
* Fetch available topics – Retrieves all topics for the given assignment.  &lt;br /&gt;
* Sort topics by team size – Topics with more members are given priority.  &lt;br /&gt;
* Create a topic queue – Topics are arranged in descending order of team size.  &lt;br /&gt;
* Assign topics in a round-robin manner – Reviewers are assigned topics while avoiding their own team's topic.  &lt;br /&gt;
&lt;br /&gt;
This ensures ''fair and balanced'' distribution of topics.&lt;br /&gt;
  &lt;br /&gt;
=====   ''Implementation - Controller Code (Triggering the Fallback)''   =====&lt;br /&gt;
If the primary bidding service fails, the system catches the error and calls the Fallback Algorithm.&lt;br /&gt;
&lt;br /&gt;
[[File:Controller-code.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: If ''ReviewBiddingAlgorithmService'' fails, the system automatically calls fallback_algorithm.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Implementation - Model Code (Fallback Algorithm)''   =====&lt;br /&gt;
This method ensures fair topic assignment when the bidding system fails.&lt;br /&gt;
&lt;br /&gt;
[[File:Model-code.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: This function ensures every reviewer receives a topic without requiring manual intervention.&lt;br /&gt;
&lt;br /&gt;
=====   ''RSpec Testing of Fallback Algorithm''   =====&lt;br /&gt;
To verify correctness, we use unit tests in ''review_bid_spec.rb''&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm ensures that ''topics are assigned fairly'' even when the primary bidding service fails. By prioritizing ''larger teams'', ''avoiding self-review'', and using a ''round-robin strategy'', the fallback mechanism keeps the review process smooth and automatic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
This section outlines the test plan for this project including testing scenarios/edge cases, the manual testing plan, and the automatic/RSpec testing plan.&lt;br /&gt;
&lt;br /&gt;
=== ''Testing Scenarios'' ===&lt;br /&gt;
This section outlines the various bidding scenarios that could occur. These scenarios should be tested in either '''Manual Testing''' or '''Automatic Testing'''.&lt;br /&gt;
&lt;br /&gt;
==== Basic Bidding Scenario ====&lt;br /&gt;
*Reviewers bid on multiple projects at different times&lt;br /&gt;
** Bidding algorithm should give priority to reviewers that bid first and should assign based on reviewers ranking&lt;br /&gt;
&lt;br /&gt;
====   Edge Cases   ====&lt;br /&gt;
* All reviewers bid on the same project&lt;br /&gt;
** If different time stamps: bidding algorithm should give priority to reviewers that bid first&lt;br /&gt;
** If same time stamps: bidding algorithm should assign reviews randomly&lt;br /&gt;
* None of the reviews bid on any projects&lt;br /&gt;
** Bidding algorithm should assign reviews randomly&lt;br /&gt;
* Reviewer bids on their own project&lt;br /&gt;
** Bidding algorithm should not allow a reviewer to bid on their own project and should have validation to prevent assigning a reviewer their own project&lt;br /&gt;
* None of the reviewers bid on a specific project&lt;br /&gt;
** Bidding algorithm should still assign reviewers to this project&lt;br /&gt;
&lt;br /&gt;
===   ''Manual Testing''   ===&lt;br /&gt;
Manual testing should be preformed on an Expertiza server and webserver platform &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Plan for Expertiza Server ====&lt;br /&gt;
* test that an instructor can allow review bidding for an assignment&lt;br /&gt;
* test that server routes correctly when review bidding is allowed&lt;br /&gt;
** test that task box links to bidding page before algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to bidding page before algorithm is run&lt;br /&gt;
** test that task box links to review page with bidding information after algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to review page with bidding information after algorithm is run&lt;br /&gt;
* test that the bidding UI is implemented as expected&lt;br /&gt;
* test that a participant can bid on projects to review&lt;br /&gt;
** test that a participant can move projects into the bidding column&lt;br /&gt;
** test that a participant can reorder projects in the bidding column&lt;br /&gt;
** test that a participant's bidding preferences save&lt;br /&gt;
** test that a participant can't bid for their own topic&lt;br /&gt;
* test that run algorithm button calls webserver with correct information and returns review assignments for each user&lt;br /&gt;
&lt;br /&gt;
==== Directions for Manual Testing of Expertiza Server ====&lt;br /&gt;
1. Go to [http://152.7.99.70:8081/ testing server] &amp;lt;br&amp;gt;&lt;br /&gt;
2. Log in as username: '''instructor6''' password: '''password''' &amp;lt;br&amp;gt;&lt;br /&gt;
3. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''General''' tab make sure '''Has teams?''' and '''Has topics?''' are checked&lt;br /&gt;
:# In the '''Topics''' tab check '''Allow review to choose which topic to review?''' then click '''save'''&lt;br /&gt;
:# In the '''Topics''' tab select '''Bidding''' then click '''save'''&lt;br /&gt;
4. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# This UI is based on '''instructor6''' being a '''participant''' assigned to topic '''Topic4'''&lt;br /&gt;
::# The UI blocks user from bidding on their own project &lt;br /&gt;
::# Check that user can bid on topics and reorder bids&lt;br /&gt;
::# Check that users topic preferences save on page refresh&lt;br /&gt;
::# Impersonate other participants and repeat bidding UI tests ('''student7601''', '''student7602''', '''student7603''', '''student7604''', '''student7605''', '''student7606''', '''student7607''', '''student7608''', '''student7609'')&lt;br /&gt;
5. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''Topics''' tab click '''Run Review Algorithm''' button&lt;br /&gt;
6. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# '''E2085 Manual Testing review''' should now link to the reviewing page&lt;br /&gt;
::# The number of required reviews should already be displayed&lt;br /&gt;
::# A '''Request Another Review''' button should be present unless reviews listed is equal to the number of reviews allowed&lt;br /&gt;
::# '''Begin''' a review and test '''save''' and '''submit'''&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Demo Video for Expertiza Server ====&lt;br /&gt;
Video demonstration of manual testing: [https://www.screencast.com/t/0rSg1zDW here]&lt;br /&gt;
&lt;br /&gt;
=== ''Automatic/PyTest Testing '' ===&lt;br /&gt;
Pytest tests are written for the webservice to test a well formed and a malformed request.&lt;br /&gt;
&lt;br /&gt;
===   ''Automatic/RSpec Testing ''   ===&lt;br /&gt;
RSpec tests will need to be refactored according to the changes that we make in the expertiza repository. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== RSpec Testing Plan ====&lt;br /&gt;
These RSpec tests will need to:&lt;br /&gt;
* test basic functionality of review bids controller&lt;br /&gt;
* test basic functionality of review bid model&lt;br /&gt;
&lt;br /&gt;
==== Directions for RSpec Testing ====&lt;br /&gt;
:# on personal device using [https://github.com/ncsu-ngw/expertiza forked repo]&lt;br /&gt;
:# Run the following commands:&lt;br /&gt;
&lt;br /&gt;
 # review bids controller: &lt;br /&gt;
 bundle exec rspec spec/controllers/review_bids_controller_spec.rb&lt;br /&gt;
 &lt;br /&gt;
 # review bid model: &lt;br /&gt;
 bundle exec rspec spec/models/review_bid_spec.rb&lt;br /&gt;
&lt;br /&gt;
==== RSpec Testing Demo Video ====&lt;br /&gt;
Video demonstration of RSpec tests passing: [https://www.screencast.com/t/uSWZHSX8s here]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Coverage==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
Nicholas Winsen (nwinsen) &amp;lt;br&amp;gt;&lt;br /&gt;
Arturo Serdan (aaserdan) &amp;lt;br&amp;gt;&lt;br /&gt;
Ashwin Muniswamy (akumarm) &amp;lt;br&amp;gt;&lt;br /&gt;
'''Mentor:''' Janice Uwujaren (juwujar)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
''Previous Implementations'': &lt;br /&gt;
[[https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Objectives]],&amp;lt;br&amp;gt;&lt;br /&gt;
[[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review 1]],&amp;lt;br&amp;gt;[[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review 2]]&amp;lt;br&amp;gt;&lt;br /&gt;
''Bidding Interface Implementation Pull Request'': [[https://github.com/expertiza/expertiza/pull/778 3]]&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'':  &amp;lt;br&amp;gt;&lt;br /&gt;
''Expertiza Server'': &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
''Video Demo'': https://app.screencast.com/vaiJnWpHf0r07&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:Akumarm&amp;diff=162425</id>
		<title>User:Akumarm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:Akumarm&amp;diff=162425"/>
		<updated>2025-03-24T22:29:12Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Fallback Algorithm ==&lt;br /&gt;
===   ''Introduction''   ===&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm in Expertiza is designed to ensure automatic topic assignment when the primary Bidding Algorithm fails due to Web Service unavailability.  &lt;br /&gt;
&lt;br /&gt;
Normally, Expertiza allows reviewers to bid on topics, and the ''ReviewBiddingAlgorithmService'' processes these bids to assign topics. However, when this web service ''fails'' (due to API downtime, server issues, or unexpected errors), the system must switch to fallback and automatically assign topics to reviewers.  &lt;br /&gt;
&lt;br /&gt;
===   ''Solution''   ===&lt;br /&gt;
It is triggered when the web service is unavailable. It ensures fair topic assignment by:  &lt;br /&gt;
* Prioritizing topics with the largest teams.  &lt;br /&gt;
* Using a round-robin approach to distribute topics among reviewers.  &lt;br /&gt;
* Ensuring reviewers do not get their own team’s topic.  &lt;br /&gt;
&lt;br /&gt;
===   ''When is this Used?''   === &lt;br /&gt;
* The ReviewBiddingAlgorithmService fails due to an API issue.  &lt;br /&gt;
* The web service times out or returns an error.  &lt;br /&gt;
* Unexpected exceptions occur in the bidding process.  &lt;br /&gt;
&lt;br /&gt;
Instead of stopping the review process, the system automatically falls-back to an internal algorithm to distribute topics.  &lt;br /&gt;
&lt;br /&gt;
===   ''How Does the Fallback Algorithm Work?''   === &lt;br /&gt;
The algorithm follows these **four main steps:  &lt;br /&gt;
* Fetch available topics – Retrieves all topics for the given assignment.  &lt;br /&gt;
* Sort topics by team size – Topics with more members are given priority.  &lt;br /&gt;
* Create a topic queue – Topics are arranged in descending order of team size.  &lt;br /&gt;
* Assign topics in a round-robin manner – Reviewers are assigned topics while avoiding their own team's topic.  &lt;br /&gt;
&lt;br /&gt;
This ensures ''fair and balanced'' distribution of topics.  &lt;br /&gt;
&lt;br /&gt;
===   ''Implementation - Controller Code (Triggering the Fallback)''   ===&lt;br /&gt;
If the primary bidding service fails, the system catches the error and calls the Fallback Algorithm.&lt;br /&gt;
&lt;br /&gt;
[[File:Controller-code.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: If ''ReviewBiddingAlgorithmService'' fails, the system automatically calls fallback_algorithm.  &lt;br /&gt;
&lt;br /&gt;
===   ''Implementation - Model Code (Fallback Algorithm)''   ===&lt;br /&gt;
This method ensures fair topic assignment when the bidding system fails.&lt;br /&gt;
&lt;br /&gt;
[[File:Model-code.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Key Takeaway: This function ensures every reviewer receives a topic without requiring manual intervention.&lt;br /&gt;
&lt;br /&gt;
===   ''RSpec Testing of Fallback Algorithm''   === &lt;br /&gt;
To verify correctness, we use unit tests in ''review_bid_spec.rb''&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm ensures that ''topics are assigned fairly'' even when the primary bidding service fails. By prioritizing ''larger teams'', ''avoiding self-review'', and using a ''round-robin strategy'', the fallback mechanism keeps the review process smooth and automatic.&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162424</id>
		<title>CSC/ECE 517 Spring 2025 - E2508. Reimplement bidding-algorithm web service</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162424"/>
		<updated>2025-03-24T22:28:13Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Project Overview==&lt;br /&gt;
===   ''Background''   ===&lt;br /&gt;
The previous implementation of the bidding service was hosted on peerlogic by a former student. The University no longer has access to this hosting service, and  is requiring a new solution. It is also asked that the webservice accept a better and cleaner json format which is easier to interpret and read.&lt;br /&gt;
&lt;br /&gt;
===   ''Objectives''   ===&lt;br /&gt;
# Reimplement trading cycles on a webservice&lt;br /&gt;
# Figure out a new hosting solution for the BiddingService web service. (VCL)&lt;br /&gt;
# Host the webservice on VCL&lt;br /&gt;
# Using tmux, figure out a way to keep the process running with a production wsgi service compatible with Flask.&lt;br /&gt;
# Create new tests for the repository&lt;br /&gt;
# Create a list of required packages that future maintainers can install easily&lt;br /&gt;
# Create a tests directory that users can test the functionality of the code with&lt;br /&gt;
# Modularize the code further, eliminate code smells.&lt;br /&gt;
# Refactor existing backend logic to account for the new json format&lt;br /&gt;
# Refactor existing backend code to send HTTP requests to the correct IP address&lt;br /&gt;
# Refactor existing frontend code to provide a list for users to select multiple topics on the frontend&lt;br /&gt;
# Allow users to prioritize their topic selection on the frontend&lt;br /&gt;
# Users should not be allowed to bid on their review topics on the frontend&lt;br /&gt;
# Display the results of the matched topics on the frontend&lt;br /&gt;
&lt;br /&gt;
===   ''Previous Work''   ===&lt;br /&gt;
There have been three previous implementations: &amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2019 [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Spring 2020 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2020 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2024 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2508._Reimplement_bidding-algorithm_web_service here]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/2931 &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Files Modified''   ===&lt;br /&gt;
This is a list of all the files added or changed in completing this project. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Changed'': &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/app.py - accomodated for changes in JsonParser&lt;br /&gt;
*app/json_parser.py - moved functions out due to SRP&lt;br /&gt;
*app/topics_matcher.py&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Added'': &amp;lt;br&amp;gt;&lt;br /&gt;
*app/tests/sample.json &amp;lt;br&amp;gt; - Sample input for the tests.&lt;br /&gt;
&lt;br /&gt;
*app/tests/test_assignment.py &amp;lt;br&amp;gt; Test File to test forms of input - tests both a successful and unsuccessful input&lt;br /&gt;
&lt;br /&gt;
*app/utils/popular_topics.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/student_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/topic_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
&lt;br /&gt;
*setup.py - required for wsgi&lt;br /&gt;
*wsgi.py - for hosting the server via gunicorn on VCL.&lt;br /&gt;
*.gitignore - to ignore anything that we may not want pushed (mostly for venv)&lt;br /&gt;
*requirements.txt - a list of requirements made easy for future maintainers&lt;br /&gt;
&lt;br /&gt;
=== ''Webservice'' ===&lt;br /&gt;
===== ''app'' =====&lt;br /&gt;
&lt;br /&gt;
The entry point to the Web service is the app.py file where we have the POST Method match_topics.&lt;br /&gt;
This receives the input in a json format from Expertiza. The input will contain a list of task ids, and then an Object of users, which each contain their student id and correlated bids that they made. Each bid contains a task id, a priority, and a timestamp. The input format was reworked to align to this style since it made more sense to have each student have a list of bids instead of the previous implementation which did not have this case. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:App2508.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''json parser'' =====&lt;br /&gt;
The json parser converts the json into a Dictionary. The previous implementation also had the parser create a preferences dictionary for the Student to store their topic preferences and one for Topics to store list of topics which have been selected by students and also the priority for the selection using the Timestamps. However, this was removed due to the Single Responsibility Principle. We felt the json parser was doing too much and should only be parsing the json!&lt;br /&gt;
&lt;br /&gt;
[[File:init_parser.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The student priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:student_prio.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The topic priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:topic_priorities.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== ''Test Input'' =====&lt;br /&gt;
&lt;br /&gt;
Sample Test case:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Case:&amp;lt;/b&amp;gt; There are a few very popular topics and the students who bid for them and bid early should receive it.&lt;br /&gt;
Popular Topics: 3969, 3971, 3972&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;tid&amp;quot;: [4427, 4428, 4429, 4430],&lt;br /&gt;
    &amp;quot;users&amp;quot;: {&lt;br /&gt;
      &amp;quot;40763&amp;quot;: {&lt;br /&gt;
          &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4429&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40764&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4427&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40765&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:15 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:16 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:17 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4428&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;max_accepted_proposals&amp;quot;: 3&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''Output'' =====&lt;br /&gt;
&lt;br /&gt;
 Since there is competition for these topics, the algorithm recognizes this and makes sure to assign them only to the students who bid for it.&lt;br /&gt;
		Other students who picked other topics or did not pick anything are assigned different topics.&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
    &amp;quot;40763&amp;quot;: [&lt;br /&gt;
        4427,&lt;br /&gt;
        4428,&lt;br /&gt;
        4430&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40764&amp;quot;: [&lt;br /&gt;
        4428,&lt;br /&gt;
        4430,&lt;br /&gt;
        4429&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40765&amp;quot;: [&lt;br /&gt;
        4429,&lt;br /&gt;
        4427,&lt;br /&gt;
        4430&lt;br /&gt;
    ]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Fallback Algorithm ===&lt;br /&gt;
=====   ''Introduction''   =====&lt;br /&gt;
&lt;br /&gt;
The Fallback Algorithm in Expertiza is designed to ensure automatic topic assignment when the primary Bidding Algorithm fails due to Web Service unavailability.  &lt;br /&gt;
&lt;br /&gt;
Normally, Expertiza allows reviewers to bid on topics, and the ''ReviewBiddingAlgorithmService'' processes these bids to assign topics. However, when this web service ''fails'' (due to API downtime, server issues, or unexpected errors), the system must switch to fallback and automatically assign topics to reviewers.  &lt;br /&gt;
&lt;br /&gt;
=====   ''Solution''   =====&lt;br /&gt;
It is triggered when the web service is unavailable. It ensures fair topic assignment by:  &lt;br /&gt;
* Prioritizing topics with the largest teams.  &lt;br /&gt;
* Using a round-robin approach to distribute topics among reviewers.  &lt;br /&gt;
* Ensuring reviewers do not get their own team’s topic.  &lt;br /&gt;
&lt;br /&gt;
=====   ''When is this Used?''  ===== &lt;br /&gt;
* The ReviewBiddingAlgorithmService fails due to an API issue.  &lt;br /&gt;
* The web service times out or returns an error.  &lt;br /&gt;
* Unexpected exceptions occur in the bidding process.  &lt;br /&gt;
&lt;br /&gt;
Instead of stopping the review process, the system automatically falls-back to an internal algorithm to distribute topics.  &lt;br /&gt;
&lt;br /&gt;
=====   ''How Does the Fallback Algorithm Work?''   ===== &lt;br /&gt;
The algorithm follows these **four main steps:  &lt;br /&gt;
* Fetch available topics – Retrieves all topics for the given assignment.  &lt;br /&gt;
* Sort topics by team size – Topics with more members are given priority.  &lt;br /&gt;
* Create a topic queue – Topics are arranged in descending order of team size.  &lt;br /&gt;
* Assign topics in a round-robin manner – Reviewers are assigned topics while avoiding their own team's topic.  &lt;br /&gt;
&lt;br /&gt;
This ensures ''fair and balanced'' distribution of topics.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
This section outlines the test plan for this project including testing scenarios/edge cases, the manual testing plan, and the automatic/RSpec testing plan.&lt;br /&gt;
&lt;br /&gt;
=== ''Testing Scenarios'' ===&lt;br /&gt;
This section outlines the various bidding scenarios that could occur. These scenarios should be tested in either '''Manual Testing''' or '''Automatic Testing'''.&lt;br /&gt;
&lt;br /&gt;
==== Basic Bidding Scenario ====&lt;br /&gt;
*Reviewers bid on multiple projects at different times&lt;br /&gt;
** Bidding algorithm should give priority to reviewers that bid first and should assign based on reviewers ranking&lt;br /&gt;
&lt;br /&gt;
====   Edge Cases   ====&lt;br /&gt;
* All reviewers bid on the same project&lt;br /&gt;
** If different time stamps: bidding algorithm should give priority to reviewers that bid first&lt;br /&gt;
** If same time stamps: bidding algorithm should assign reviews randomly&lt;br /&gt;
* None of the reviews bid on any projects&lt;br /&gt;
** Bidding algorithm should assign reviews randomly&lt;br /&gt;
* Reviewer bids on their own project&lt;br /&gt;
** Bidding algorithm should not allow a reviewer to bid on their own project and should have validation to prevent assigning a reviewer their own project&lt;br /&gt;
* None of the reviewers bid on a specific project&lt;br /&gt;
** Bidding algorithm should still assign reviewers to this project&lt;br /&gt;
&lt;br /&gt;
===   ''Manual Testing''   ===&lt;br /&gt;
Manual testing should be preformed on an Expertiza server and webserver platform &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Plan for Expertiza Server ====&lt;br /&gt;
* test that an instructor can allow review bidding for an assignment&lt;br /&gt;
* test that server routes correctly when review bidding is allowed&lt;br /&gt;
** test that task box links to bidding page before algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to bidding page before algorithm is run&lt;br /&gt;
** test that task box links to review page with bidding information after algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to review page with bidding information after algorithm is run&lt;br /&gt;
* test that the bidding UI is implemented as expected&lt;br /&gt;
* test that a participant can bid on projects to review&lt;br /&gt;
** test that a participant can move projects into the bidding column&lt;br /&gt;
** test that a participant can reorder projects in the bidding column&lt;br /&gt;
** test that a participant's bidding preferences save&lt;br /&gt;
** test that a participant can't bid for their own topic&lt;br /&gt;
* test that run algorithm button calls webserver with correct information and returns review assignments for each user&lt;br /&gt;
&lt;br /&gt;
==== Directions for Manual Testing of Expertiza Server ====&lt;br /&gt;
1. Go to [http://152.7.99.70:8081/ testing server] &amp;lt;br&amp;gt;&lt;br /&gt;
2. Log in as username: '''instructor6''' password: '''password''' &amp;lt;br&amp;gt;&lt;br /&gt;
3. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''General''' tab make sure '''Has teams?''' and '''Has topics?''' are checked&lt;br /&gt;
:# In the '''Topics''' tab check '''Allow review to choose which topic to review?''' then click '''save'''&lt;br /&gt;
:# In the '''Topics''' tab select '''Bidding''' then click '''save'''&lt;br /&gt;
4. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# This UI is based on '''instructor6''' being a '''participant''' assigned to topic '''Topic4'''&lt;br /&gt;
::# The UI blocks user from bidding on their own project &lt;br /&gt;
::# Check that user can bid on topics and reorder bids&lt;br /&gt;
::# Check that users topic preferences save on page refresh&lt;br /&gt;
::# Impersonate other participants and repeat bidding UI tests ('''student7601''', '''student7602''', '''student7603''', '''student7604''', '''student7605''', '''student7606''', '''student7607''', '''student7608''', '''student7609'')&lt;br /&gt;
5. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''Topics''' tab click '''Run Review Algorithm''' button&lt;br /&gt;
6. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# '''E2085 Manual Testing review''' should now link to the reviewing page&lt;br /&gt;
::# The number of required reviews should already be displayed&lt;br /&gt;
::# A '''Request Another Review''' button should be present unless reviews listed is equal to the number of reviews allowed&lt;br /&gt;
::# '''Begin''' a review and test '''save''' and '''submit'''&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Demo Video for Expertiza Server ====&lt;br /&gt;
Video demonstration of manual testing: [https://www.screencast.com/t/0rSg1zDW here]&lt;br /&gt;
&lt;br /&gt;
=== ''Automatic/PyTest Testing '' ===&lt;br /&gt;
Pytest tests are written for the webservice to test a well formed and a malformed request.&lt;br /&gt;
&lt;br /&gt;
===   ''Automatic/RSpec Testing ''   ===&lt;br /&gt;
RSpec tests will need to be refactored according to the changes that we make in the expertiza repository. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== RSpec Testing Plan ====&lt;br /&gt;
These RSpec tests will need to:&lt;br /&gt;
* test basic functionality of review bids controller&lt;br /&gt;
* test basic functionality of review bid model&lt;br /&gt;
&lt;br /&gt;
==== Directions for RSpec Testing ====&lt;br /&gt;
:# on personal device using [https://github.com/ncsu-ngw/expertiza forked repo]&lt;br /&gt;
:# Run the following commands:&lt;br /&gt;
&lt;br /&gt;
 # review bids controller: &lt;br /&gt;
 bundle exec rspec spec/controllers/review_bids_controller_spec.rb&lt;br /&gt;
 &lt;br /&gt;
 # review bid model: &lt;br /&gt;
 bundle exec rspec spec/models/review_bid_spec.rb&lt;br /&gt;
&lt;br /&gt;
==== RSpec Testing Demo Video ====&lt;br /&gt;
Video demonstration of RSpec tests passing: [https://www.screencast.com/t/uSWZHSX8s here]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Coverage==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
Nicholas Winsen (nwinsen) &amp;lt;br&amp;gt;&lt;br /&gt;
Arturo Serdan (aaserdan) &amp;lt;br&amp;gt;&lt;br /&gt;
Ashwin Muniswamy (akumarm) &amp;lt;br&amp;gt;&lt;br /&gt;
'''Mentor:''' Janice Uwujaren (juwujar)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
''Previous Implementations'': &lt;br /&gt;
[[https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Objectives]],&amp;lt;br&amp;gt;&lt;br /&gt;
[[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review 1]],&amp;lt;br&amp;gt;[[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review 2]]&amp;lt;br&amp;gt;&lt;br /&gt;
''Bidding Interface Implementation Pull Request'': [[https://github.com/expertiza/expertiza/pull/778 3]]&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'':  &amp;lt;br&amp;gt;&lt;br /&gt;
''Expertiza Server'': &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
''Video Demo'': https://app.screencast.com/vaiJnWpHf0r07&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162422</id>
		<title>CSC/ECE 517 Spring 2025 - E2508. Reimplement bidding-algorithm web service</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2508._Reimplement_bidding-algorithm_web_service&amp;diff=162422"/>
		<updated>2025-03-24T22:24:53Z</updated>

		<summary type="html">&lt;p&gt;Akumarm: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Project Overview==&lt;br /&gt;
===   ''Background''   ===&lt;br /&gt;
The previous implementation of the bidding service was hosted on peerlogic by a former student. The University no longer has access to this hosting service, and  is requiring a new solution. It is also asked that the webservice accept a better and cleaner json format which is easier to interpret and read.&lt;br /&gt;
&lt;br /&gt;
===   ''Objectives''   ===&lt;br /&gt;
# Reimplement trading cycles on a webservice&lt;br /&gt;
# Figure out a new hosting solution for the BiddingService web service. (VCL)&lt;br /&gt;
# Host the webservice on VCL&lt;br /&gt;
# Using tmux, figure out a way to keep the process running with a production wsgi service compatible with Flask.&lt;br /&gt;
# Create new tests for the repository&lt;br /&gt;
# Create a list of required packages that future maintainers can install easily&lt;br /&gt;
# Create a tests directory that users can test the functionality of the code with&lt;br /&gt;
# Modularize the code further, eliminate code smells.&lt;br /&gt;
# Refactor existing backend logic to account for the new json format&lt;br /&gt;
# Refactor existing backend code to send HTTP requests to the correct IP address&lt;br /&gt;
# Refactor existing frontend code to provide a list for users to select multiple topics on the frontend&lt;br /&gt;
# Allow users to prioritize their topic selection on the frontend&lt;br /&gt;
# Users should not be allowed to bid on their review topics on the frontend&lt;br /&gt;
# Display the results of the matched topics on the frontend&lt;br /&gt;
&lt;br /&gt;
===   ''Previous Work''   ===&lt;br /&gt;
There have been three previous implementations: &amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2019 [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Spring 2020 [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2020 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review here]&amp;lt;br&amp;gt;&lt;br /&gt;
Fall 2024 [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2508._Reimplement_bidding-algorithm_web_service here]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/2931 &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===   ''Files Modified''   ===&lt;br /&gt;
This is a list of all the files added or changed in completing this project. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Changed'': &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/app.py - accomodated for changes in JsonParser&lt;br /&gt;
*app/json_parser.py - moved functions out due to SRP&lt;br /&gt;
*app/topics_matcher.py&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''Added'': &amp;lt;br&amp;gt;&lt;br /&gt;
*app/tests/sample.json &amp;lt;br&amp;gt; - Sample input for the tests.&lt;br /&gt;
&lt;br /&gt;
*app/tests/test_assignment.py &amp;lt;br&amp;gt; Test File to test forms of input - tests both a successful and unsuccessful input&lt;br /&gt;
&lt;br /&gt;
*app/utils/popular_topics.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/student_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
*app/utils/topic_priorities.py &amp;lt;br&amp;gt; - Json Parser SRP violation - moved to own file&lt;br /&gt;
&lt;br /&gt;
*setup.py - required for wsgi&lt;br /&gt;
*wsgi.py - for hosting the server via gunicorn on VCL.&lt;br /&gt;
*.gitignore - to ignore anything that we may not want pushed (mostly for venv)&lt;br /&gt;
*requirements.txt - a list of requirements made easy for future maintainers&lt;br /&gt;
&lt;br /&gt;
=== ''Webservice'' ===&lt;br /&gt;
===== ''app'' =====&lt;br /&gt;
&lt;br /&gt;
The entry point to the Web service is the app.py file where we have the POST Method match_topics.&lt;br /&gt;
This receives the input in a json format from Expertiza. The input will contain a list of task ids, and then an Object of users, which each contain their student id and correlated bids that they made. Each bid contains a task id, a priority, and a timestamp. The input format was reworked to align to this style since it made more sense to have each student have a list of bids instead of the previous implementation which did not have this case. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:App2508.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''json parser'' =====&lt;br /&gt;
The json parser converts the json into a Dictionary. The previous implementation also had the parser create a preferences dictionary for the Student to store their topic preferences and one for Topics to store list of topics which have been selected by students and also the priority for the selection using the Timestamps. However, this was removed due to the Single Responsibility Principle. We felt the json parser was doing too much and should only be parsing the json!&lt;br /&gt;
&lt;br /&gt;
[[File:init_parser.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The student priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:student_prio.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The topic priorities function in its own file, moved due to SRP.&lt;br /&gt;
&lt;br /&gt;
[[File:topic_priorities.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== ''Test Input'' =====&lt;br /&gt;
&lt;br /&gt;
Sample Test case:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Case:&amp;lt;/b&amp;gt; There are a few very popular topics and the students who bid for them and bid early should receive it.&lt;br /&gt;
Popular Topics: 3969, 3971, 3972&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;tid&amp;quot;: [4427, 4428, 4429, 4430],&lt;br /&gt;
    &amp;quot;users&amp;quot;: {&lt;br /&gt;
      &amp;quot;40763&amp;quot;: {&lt;br /&gt;
          &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4429&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40764&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:34 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4430, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:35 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:16:37 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4427&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;40765&amp;quot;: {&lt;br /&gt;
        &amp;quot;bids&amp;quot;: [&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4427, &amp;quot;priority&amp;quot;: 3, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:15 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4428, &amp;quot;priority&amp;quot;: 1, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:16 EST -05:00&amp;quot; },&lt;br /&gt;
          { &amp;quot;tid&amp;quot;: 4429, &amp;quot;priority&amp;quot;: 2, &amp;quot;timestamp&amp;quot;: &amp;quot;Sun, 15 Nov 2020 17:17:17 EST -05:00&amp;quot; }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;otid&amp;quot;: 4428&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;max_accepted_proposals&amp;quot;: 3&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''Output'' =====&lt;br /&gt;
&lt;br /&gt;
 Since there is competition for these topics, the algorithm recognizes this and makes sure to assign them only to the students who bid for it.&lt;br /&gt;
		Other students who picked other topics or did not pick anything are assigned different topics.&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
    &amp;quot;40763&amp;quot;: [&lt;br /&gt;
        4427,&lt;br /&gt;
        4428,&lt;br /&gt;
        4430&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40764&amp;quot;: [&lt;br /&gt;
        4428,&lt;br /&gt;
        4430,&lt;br /&gt;
        4429&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;40765&amp;quot;: [&lt;br /&gt;
        4429,&lt;br /&gt;
        4427,&lt;br /&gt;
        4430&lt;br /&gt;
    ]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
This section outlines the test plan for this project including testing scenarios/edge cases, the manual testing plan, and the automatic/RSpec testing plan.&lt;br /&gt;
&lt;br /&gt;
=== ''Testing Scenarios'' ===&lt;br /&gt;
This section outlines the various bidding scenarios that could occur. These scenarios should be tested in either '''Manual Testing''' or '''Automatic Testing'''.&lt;br /&gt;
&lt;br /&gt;
==== Basic Bidding Scenario ====&lt;br /&gt;
*Reviewers bid on multiple projects at different times&lt;br /&gt;
** Bidding algorithm should give priority to reviewers that bid first and should assign based on reviewers ranking&lt;br /&gt;
&lt;br /&gt;
====   Edge Cases   ====&lt;br /&gt;
* All reviewers bid on the same project&lt;br /&gt;
** If different time stamps: bidding algorithm should give priority to reviewers that bid first&lt;br /&gt;
** If same time stamps: bidding algorithm should assign reviews randomly&lt;br /&gt;
* None of the reviews bid on any projects&lt;br /&gt;
** Bidding algorithm should assign reviews randomly&lt;br /&gt;
* Reviewer bids on their own project&lt;br /&gt;
** Bidding algorithm should not allow a reviewer to bid on their own project and should have validation to prevent assigning a reviewer their own project&lt;br /&gt;
* None of the reviewers bid on a specific project&lt;br /&gt;
** Bidding algorithm should still assign reviewers to this project&lt;br /&gt;
&lt;br /&gt;
===   ''Manual Testing''   ===&lt;br /&gt;
Manual testing should be preformed on an Expertiza server and webserver platform &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Plan for Expertiza Server ====&lt;br /&gt;
* test that an instructor can allow review bidding for an assignment&lt;br /&gt;
* test that server routes correctly when review bidding is allowed&lt;br /&gt;
** test that task box links to bidding page before algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to bidding page before algorithm is run&lt;br /&gt;
** test that task box links to review page with bidding information after algorithm is run&lt;br /&gt;
** test that assignment-&amp;gt;others work links to review page with bidding information after algorithm is run&lt;br /&gt;
* test that the bidding UI is implemented as expected&lt;br /&gt;
* test that a participant can bid on projects to review&lt;br /&gt;
** test that a participant can move projects into the bidding column&lt;br /&gt;
** test that a participant can reorder projects in the bidding column&lt;br /&gt;
** test that a participant's bidding preferences save&lt;br /&gt;
** test that a participant can't bid for their own topic&lt;br /&gt;
* test that run algorithm button calls webserver with correct information and returns review assignments for each user&lt;br /&gt;
&lt;br /&gt;
==== Directions for Manual Testing of Expertiza Server ====&lt;br /&gt;
1. Go to [http://152.7.99.70:8081/ testing server] &amp;lt;br&amp;gt;&lt;br /&gt;
2. Log in as username: '''instructor6''' password: '''password''' &amp;lt;br&amp;gt;&lt;br /&gt;
3. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''General''' tab make sure '''Has teams?''' and '''Has topics?''' are checked&lt;br /&gt;
:# In the '''Topics''' tab check '''Allow review to choose which topic to review?''' then click '''save'''&lt;br /&gt;
:# In the '''Topics''' tab select '''Bidding''' then click '''save'''&lt;br /&gt;
4. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# This UI is based on '''instructor6''' being a '''participant''' assigned to topic '''Topic4'''&lt;br /&gt;
::# The UI blocks user from bidding on their own project &lt;br /&gt;
::# Check that user can bid on topics and reorder bids&lt;br /&gt;
::# Check that users topic preferences save on page refresh&lt;br /&gt;
::# Impersonate other participants and repeat bidding UI tests ('''student7601''', '''student7602''', '''student7603''', '''student7604''', '''student7605''', '''student7606''', '''student7607''', '''student7608''', '''student7609'')&lt;br /&gt;
5. Go to '''Manage''' -&amp;gt; '''Assignments''' -&amp;gt; '''E2085 Manual Testing''' -&amp;gt; '''edit''' (pencil symbol)&lt;br /&gt;
:# In the '''Topics''' tab click '''Run Review Algorithm''' button&lt;br /&gt;
6. Go to '''Assignments''' &lt;br /&gt;
:# '''E2085 Manual Testing review''' task should be listed in the main assignments box&lt;br /&gt;
::# '''E2085 Manual Testing review''' should now link to the reviewing page&lt;br /&gt;
::# The number of required reviews should already be displayed&lt;br /&gt;
::# A '''Request Another Review''' button should be present unless reviews listed is equal to the number of reviews allowed&lt;br /&gt;
::# '''Begin''' a review and test '''save''' and '''submit'''&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing Demo Video for Expertiza Server ====&lt;br /&gt;
Video demonstration of manual testing: [https://www.screencast.com/t/0rSg1zDW here]&lt;br /&gt;
&lt;br /&gt;
=== ''Automatic/PyTest Testing '' ===&lt;br /&gt;
Pytest tests are written for the webservice to test a well formed and a malformed request.&lt;br /&gt;
&lt;br /&gt;
===   ''Automatic/RSpec Testing ''   ===&lt;br /&gt;
RSpec tests will need to be refactored according to the changes that we make in the expertiza repository. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== RSpec Testing Plan ====&lt;br /&gt;
These RSpec tests will need to:&lt;br /&gt;
* test basic functionality of review bids controller&lt;br /&gt;
* test basic functionality of review bid model&lt;br /&gt;
&lt;br /&gt;
==== Directions for RSpec Testing ====&lt;br /&gt;
:# on personal device using [https://github.com/ncsu-ngw/expertiza forked repo]&lt;br /&gt;
:# Run the following commands:&lt;br /&gt;
&lt;br /&gt;
 # review bids controller: &lt;br /&gt;
 bundle exec rspec spec/controllers/review_bids_controller_spec.rb&lt;br /&gt;
 &lt;br /&gt;
 # review bid model: &lt;br /&gt;
 bundle exec rspec spec/models/review_bid_spec.rb&lt;br /&gt;
&lt;br /&gt;
==== RSpec Testing Demo Video ====&lt;br /&gt;
Video demonstration of RSpec tests passing: [https://www.screencast.com/t/uSWZHSX8s here]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Coverage==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
Nicholas Winsen (nwinsen) &amp;lt;br&amp;gt;&lt;br /&gt;
Arturo Serdan (aaserdan) &amp;lt;br&amp;gt;&lt;br /&gt;
Ashwin Muniswamy (akumarm) &amp;lt;br&amp;gt;&lt;br /&gt;
'''Mentor:''' Janice Uwujaren (juwujar)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
''Previous Implementations'': &lt;br /&gt;
[[https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Objectives]],&amp;lt;br&amp;gt;&lt;br /&gt;
[[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review 1]],&amp;lt;br&amp;gt;[[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2021._Allow_reviewers_to_bid_on_what_to_review 2]]&amp;lt;br&amp;gt;&lt;br /&gt;
''Bidding Interface Implementation Pull Request'': [[https://github.com/expertiza/expertiza/pull/778 3]]&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/ncsu-ngw/expertiza/tree/e2508-reimplement-bidding-algorithm-web-service &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/ncsu-ngw/BiddingService &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'':  &amp;lt;br&amp;gt;&lt;br /&gt;
''Expertiza Server'': &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': 152.7.178.10:8080/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
''Video Demo'': https://app.screencast.com/vaiJnWpHf0r07&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Akumarm</name></author>
	</entry>
</feed>