<?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=Aluthra</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=Aluthra"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Aluthra"/>
	<updated>2026-05-30T14:51:49Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=142217</id>
		<title>CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=142217"/>
		<updated>2021-11-30T02:05:19Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: /* review_bid.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic Overview==&lt;br /&gt;
===Statement of Problem===&lt;br /&gt;
Reviewing is an important stage of learning and improving, both as a reviewer and a reviewee, and so allowing reviewers more freedom and choice in what they review would result in better reviews and more engaged reviewers. However, currently the only way to choose a topic to review is a first-come-first-served basis, penalizing students who do not sign up quickly by not allowing them to review the topics they would be most interesting in engaging with.&lt;br /&gt;
&lt;br /&gt;
A better alternative would be to implement a bidding system, similar to that used for topics, which would allow students to establish preferences for which topics they would most like to review. A good bidding algorithm implementing with this idea would ensure that all students (who care enough to bid) receive a topic to review that they actively want.&lt;br /&gt;
&lt;br /&gt;
A prior project group created a prototype for this function, allowing students to bid on what topics they wanted to review. While the functionality was as desired, the feature was not able to be merged due to having too many DRY violations. Thus, the goal of this topic was to bring this prior implementation into the current version of the expertiza beta branch, and remove these DRY violations, so that it may be merged.&lt;br /&gt;
&lt;br /&gt;
As development continued, it became clear this prototype also had several bugs and issues that made it unable to work under several conditions. Thus, a secondary goal was to fix any issues which existed such that the feature would generally work with the functionality the prior implementation demonstrated.&lt;br /&gt;
&lt;br /&gt;
===Prior Work===&lt;br /&gt;
The prior work which is the basis for this topic is linked here [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review is linked here]. This work was done in Fall of 2020, and as previously mentioned, achieved much of the desired functionality for this task. This prior work will be referenced several times within this documentation, as it has a more comprehensive explanation of the underlying design principles behind the views, controller, model, algorithm, and RSpec tests implemented. These details will only be briefly summarized here. &lt;br /&gt;
&lt;br /&gt;
As previously noted, this prior implementation was rejected due to DRY violations, and so correcting these violations--and explaining how those corrections were done--will be the major focus of this project documentation.&lt;br /&gt;
&lt;br /&gt;
==Explanation of Feature==&lt;br /&gt;
&lt;br /&gt;
===Existing Bidding Functionality for Topics===&lt;br /&gt;
Currently in expertiza, students may bid on which topics they would like to work on. An image showcasing this functionality is given below:&lt;br /&gt;
&lt;br /&gt;
[[File:expected_review_UI.PNG]]&lt;br /&gt;
&lt;br /&gt;
Students may choose a number of topics to bid on, in order of priority, and once the deadline is reached, all students are given a topic.&lt;br /&gt;
&lt;br /&gt;
Behind the scenes, this works by utilizing a modified version of the Gale-Shapely Algorithm. This algorithm seeks to find a 'stable' matching of each student to each topic, such that in the end, all students have a topic they wanted (at least to some degree), and that the preferences of students is respected as well as possible. To help break situations where there are ties in preferences, each topic assigns a Priority to each student. This Priority is determined by A. whether the student is part of a group bidding for this topic (groups getting higher priority), and B. the time at which the bid for the topic was made (earlier bidders are given Priority). Once this has been determined and the deadline for bidding has ended, the following steps occur:&lt;br /&gt;
# Each student is matched with each topic they most prefer.&lt;br /&gt;
# If the number of students assigned to a topic is above the maximum allowed for that topic, the students with the highest Priority are assigned the topic&lt;br /&gt;
# All maximally filled topics are removed from the pool of available topics&lt;br /&gt;
# All unmatched students begin this cycle again, now choosing the most preferred topic remaining&lt;br /&gt;
# Repeat until all students are assigned a topic&lt;br /&gt;
# If any matches are 'unstable' (two students would have their preferences better met if they were swapped), perform any swaps until matches are as stable as possible.&lt;br /&gt;
&lt;br /&gt;
This algorithm has a time complexity of O(n^2). For more details on this algorithm and its implementation, refer to the previous year's work, where this algorithm was implemented.&lt;br /&gt;
&lt;br /&gt;
===Desired Functionality for Reviews===&lt;br /&gt;
&lt;br /&gt;
The desired feature for reviews should have an almost identical structure to this, with reviews instead of topics. Students should be shown a list of the topics that were worked on, and may bid on which of those topics they would like to review the most. The Priority system could be handled in the same way, with the only caveat being that a student should not be able to review their own work.&lt;br /&gt;
&lt;br /&gt;
In terms of what this feature looks like, it can be enabled as an option when editing/creating a new assignment, under the &amp;quot;Topics&amp;quot; section, using interface drop down show below.&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_interface.png|center|800px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once this option is enabled, during the review phase of an assignment, students will be able to access a new view listing all the topics of all the submitted assignments (except for their own). They will then be able to bid on as many topics as they like, assigning them a preference, in a manner similar to the interface for topic bidding. The table that allows for this drag-and-drop priorities is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_options.png|center|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Whenever the instructor decides they would like to close the window for review bidding, they may return to the options for the given assignment and navigate to &amp;quot;Topics&amp;quot;, where they will see a button marked &amp;quot;Run Review Algorithm&amp;quot;. This will make a call to the external webservice to determine which students are assigned what reviews, and will then assign those reviews to all students. Once this button is pressed, it locks out the ability for students to perform any more bidding, and cannot be pressed again. The button allowing this option is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_run_algorithm.png|center|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After this point, students may navigate to the &amp;quot;Others Work&amp;quot; option under their assignment and see all of their assigned reviews. They will see up to the maximum number of allowed reviews, but will be informed of how many they are required to do (for example, a student may see 4 reviews, but will be told they are only required to complete 2).&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
The following Use Case Diagram demonstrates the primary functionality explained in the previous section for different types of users.&lt;br /&gt;
&lt;br /&gt;
[[File:Use_Case_Diagram_Rev1_E2151.jpg|center]]&lt;br /&gt;
&lt;br /&gt;
==Plan and List of Work Done==&lt;br /&gt;
&lt;br /&gt;
===General Design Goals===&lt;br /&gt;
&lt;br /&gt;
* Move all prior work for this topic into a new version of the expertiza beta branch, without loss in functionality.&lt;br /&gt;
* Ensure all prior/expected functionality is working correctly, and if not, make any repairs or changes necessary.&lt;br /&gt;
* DRY out prior implementation's controller and model methods which have functionality that already exists within the expertiza system.&lt;br /&gt;
* Remove repetitive views and partials that exist by merging views for review bids into the set of views for sign up sheets, from which it uses partials.&lt;br /&gt;
* Ensure all present test cases still work properly after making the above changes.&lt;br /&gt;
&lt;br /&gt;
===Specific Tasks Completed===&lt;br /&gt;
&lt;br /&gt;
* Transferred over all code files relevant to the review bidding feature&lt;br /&gt;
* Re-deployed the external website which handles the review bidding algorithm&lt;br /&gt;
* Added that website's url to the webservices url's within expertiza&lt;br /&gt;
* Enhanced the stability of the webservice for the bidding algorithm by testing with edge cases and optimize the endpoint by restoring the original access endpoint reference&lt;br /&gt;
* Analyzed the necessity of the phase finding related logic code section&lt;br /&gt;
* Optimized phase finding related logic by removing unused code segment&lt;br /&gt;
* Removed an instance variable within the ''review_bids_controller'' which would have made any practical deployment fail, removing the unnecessary functionality it was created for&lt;br /&gt;
* Updated method calls to ''assignment.find_current_stage'' to their new form ''assignment.current_stage''&lt;br /&gt;
* Removed the review_bid model method ''self.reviewer_self_topic'' and replaced its usage with the already-existing ''SignedUpTeam.topic_id'' method&lt;br /&gt;
* Removed DRY-violating code used to calculate the current assignment phase which was never utilized by the controller or views&lt;br /&gt;
* Moved several view files from the ''review_bids'' view directory into the ''sign_up_sheet'' view directory. Partials which were duplicates in the two directories (''_all_actions.html.erb'' and ''_topic_names.html.erb'' were no longer necessary and deleted&lt;br /&gt;
* Refactored the naming of the variable that represents the id of the reviewer object from 'reviewer' to 'reviewer_id' for clarity&lt;br /&gt;
* Removed the unnecessary 'create' function within the review_bids_controller&lt;br /&gt;
* Removed the sparse testing files under the 'test' directory in keeping with typical expertiza structure&lt;br /&gt;
* Removed a test case from the unit tests which relied upon the removed 'create' method of the review_bids_controller&lt;br /&gt;
&lt;br /&gt;
==Initial Implementation==&lt;br /&gt;
&lt;br /&gt;
A considerable amount of time and effort was necessary to review, understand, and re-implement the previous implementation of the Review Bidding feature. While the feature was only created a year ago, several underlying functions and methods have since been refactored, and so needed to be changed in the implementation. Additionally, certain parts of how the implementation was designed did not seem to be properly implemented, and so had to be revised.&lt;br /&gt;
&lt;br /&gt;
===Code Transfer===&lt;br /&gt;
First, all files that were added in the original pull request were copied and moved to the new version of the expertiza beta branch. This includes the following files:&lt;br /&gt;
&lt;br /&gt;
*'''controllers/review_bids_controller.rb''': the primary controller that handles calls to review bids functionality from views, managing them itself or directing them to the appropriate model&lt;br /&gt;
*'''helpers/review_bids_helper.rb''': contains helper methods for rendering the rows of topics available to choose a review for&lt;br /&gt;
*'''models/review_bid.rb''': contains the methods that each individual review bid knows and manages, including assigning a review to a student, getting info on the topic it applies to, etc.&lt;br /&gt;
*'''views/review_bids/_all_actions.html.erb''': a view partial used to render the actions available to a student on the review bidding view. Nearly identical to the _all_actions file for topic bidding.&lt;br /&gt;
*'''views/review_bids/_table_header.html.erb''': a view partial used to render the head of the table for review bids. Though structurally similar to that of topics reviews, contains significantly less information, as less needs to be known by a student for particular topics to review.&lt;br /&gt;
*'''views/review_bids/_table_line.html.erb''': a view partial used to render individual rows of the review bids table. Like the table header, is structurally similar to that of topic bidding, but functions differently.&lt;br /&gt;
*'''views/review_bids/show.html.erb''': the view which displays all the available topics to bid on reviewing. Uses the aforementioned partials to render this bidding table.&lt;br /&gt;
*'''views/review_bids/others_work.html.erb''': displays the available review work which has the user has bid for.&lt;br /&gt;
*'''db/migrate/20201107203204_create_review_bids.rb''': the migration which creates the review bid objects within the expertiza database.&lt;br /&gt;
*'''spec/controllers/review_bids_controller_spec.rb''': the unit tests for the review bids controller&lt;br /&gt;
*'''spec/models/review_bid_spec.rb''': the unit tests for the review bids model&lt;br /&gt;
*'''test/controllers/review_bids_controller_test.rb''': a more elaborate feature test for the review bids functionality&lt;br /&gt;
*'''test/fixtures/review_bids.yml''': fixtures that are utilized for the review_bids_controller_test&lt;br /&gt;
*'''test/models/review_bid_test.rb''': A more elaborate feature test of the review bid model.&lt;br /&gt;
&lt;br /&gt;
In addition to adding the previous files, the following files were also added to existing pages as modifications:&lt;br /&gt;
&lt;br /&gt;
*'''controllers/student_review_controller.rb''': the student review controller's &amp;quot;list&amp;quot; method now redirects to the review_bid_controller's &amp;quot;index&amp;quot; method if the assignment in question has a review_choosing_algorithm set to &amp;quot;Bidding&amp;quot; (the option an instructor sets when they wish to allow students to bid on reviews).&lt;br /&gt;
*'''student_task/view.html.erb''': Instead of simply linking directly to the student_review controller's &amp;quot;list&amp;quot; method, the view instead checks if the assignment this view pertains to has their review_choosing_algorithm set to Bidding. If it does, and the assignment allows students to choose the topic to review (meaning the algorithm to assign bids has not yet been run), they are redirected to the 'show' method of the review_bids_controller. Otherwise, they are redirected to the 'index' method (showing them the info on their currently available topics to review).&lt;br /&gt;
*'''config/webservices.yml''': added a new url for the website that is called to run the review bidding algorithm&lt;br /&gt;
*'''config/routes.rb''': routes added for review_bids.&lt;br /&gt;
*'''views/assignments/edit/_topics.html.erb''': Added a new option box which allows an instructor to choose to allow bidding to occur using the review bidding algorithm, rather than the default 'Simple Choose.' Once this option is selected, it also offers a button that, when clicked, runs the review bidding algorithm on all currently bid upon reviews.&lt;br /&gt;
&lt;br /&gt;
===Website Reimplementation===&lt;br /&gt;
In the previous implementation, the algorithm which handles the assigning of reviews was hosted on an external website. This was done for the sake of improved performance. Thus, to get the feature in working condition, we pulled the code necessary to run the algorithm and hosted it on our own website (linked at the end of this documentation). We also made a note in the pull request that the place where this website is referenced (in the &amp;quot;assign_reviews_algorithm&amp;quot; method of the review_bids_controller) should be replaced by a proper external web tool, as is done for similar web tools in other parts of expertiza.&lt;br /&gt;
&lt;br /&gt;
===Modifications to Methods===&lt;br /&gt;
Certain methods utilized in the original version of the webpages were changed or renamed in later versions, and so, needed to be modified. The primary example of this is the method that assignments use to determine what stage of assignment completion they are in. The previous year's implementation called this method as &amp;quot;assignment.find_current_stage(topic_id),&amp;quot; but this failed when trying to execute. After comparing how this page worked to how normal review pages work, we determined the new call to this method is &amp;quot;assignment.current_stage(topic_id).&amp;quot; All calls to this method were replaced in all files.&lt;br /&gt;
&lt;br /&gt;
Another change to methods was the removal of a method from the review_bids_controller named 'create'. This method primarily served as a redirect for an aspect of the feature that was unnecessary and so removed (see the following section), that being the button to show another review. With this feature removed, this method was no longer used, and so it was removed from the controller.&lt;br /&gt;
&lt;br /&gt;
===Errors Corrected===&lt;br /&gt;
A notable period of time was also spent on determining the purpose of a particular local area that caused issues when trying to view the bids, that being a variable named &amp;quot;@number_of_reviews_to_show&amp;quot;. This variable apparently kept track of how many reviews a student needed to be shown, so that they could request another. The issue was that this was created as a local variable within the review_bids_controller, and therefore would never work outside of a manual testing environment, as the variable would need to be different from every student and every assignment. After some investigation, we realized that all this variable did was limit the number of already-assigned reviews the student was able to see (as the review bidding algorithm already assigned all possible reviews). Thus, rather than try to recreate this functionality, we simply removed it.&lt;br /&gt;
&lt;br /&gt;
This means that, when the review bidding algorithm runs, a student is able to see all of the reviews assigned to them, up to the maximum number of reviews for the assignment, and therefore have no reason to ask for any more. It may be the case that this feature could be improved by adding a possibility for students to request any reviews not assigned to any other student, or that still have available slots, using the &amp;quot;normal&amp;quot; review assignment scheme. For the time being, we did not consider this part of the baseline necessary functionality, and so did not implement it.&lt;br /&gt;
&lt;br /&gt;
==Final Implementation==&lt;br /&gt;
&lt;br /&gt;
===DRY Principle and Code Duplication Refactoring===&lt;br /&gt;
Per comments and feedbacks on the previous implementation [https://github.com/expertiza/expertiza/pull/1822 E2085], there were 3 sections of the code that potentially were DRY violations. For each of those violations, we have had made appropriate and provided the justification on the results.&lt;br /&gt;
&lt;br /&gt;
====review_bids_controller.rb====&lt;br /&gt;
For the refactoring of review bids controller.eb, the original issue is the DRY principle violation on the internal logic of finding the phase of assignments.&lt;br /&gt;
The original implementation to be refactored and optimized are shown as follow.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # Finding the current phase that we are in&lt;br /&gt;
    due_dates = AssignmentDueDate.where(parent_id: @assignment.id)&lt;br /&gt;
    @very_last_due_date = AssignmentDueDate.where(parent_id: @assignment.id).order(&amp;quot;due_at DESC&amp;quot;).limit(1)&lt;br /&gt;
    next_due_date = @very_last_due_date[0]&lt;br /&gt;
    for due_date in due_dates&lt;br /&gt;
      if due_date.due_at &amp;gt; Time.now&lt;br /&gt;
        next_due_date = due_date if due_date.due_at &amp;lt; next_due_date.due_at&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    @review_phase = next_due_date.deadline_type_id&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Through some discovery process, we have found some related logics that is already implemented from the system which enable the refactoring and reuse of the method. Some code snippets are demonstrated as follow.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.current_due_date(due_dates)&lt;br /&gt;
    #Get the current due date from list of due dates&lt;br /&gt;
    due_dates.each do |due_date|&lt;br /&gt;
      if due_date.due_at &amp;gt; Time.now&lt;br /&gt;
        current_due_date = due_date&lt;br /&gt;
        return current_due_date&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    #in case current due date not found&lt;br /&gt;
    return nil &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.teammate_review_allowed(student)&lt;br /&gt;
    # time when teammate review is allowed&lt;br /&gt;
    due_date = current_due_date(student.assignment.due_dates)&lt;br /&gt;
    student.assignment.find_current_stage == 'Finished' ||&lt;br /&gt;
    due_date &amp;amp;&amp;amp;&lt;br /&gt;
    (due_date.teammate_review_allowed_id == 3 ||&lt;br /&gt;
    due_date.teammate_review_allowed_id == 2) # late(2) or yes(3)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As we can observed above, both methods of &amp;lt;code&amp;gt;current_due_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;teammate_review_allowed&amp;lt;/code&amp;gt; provides the capability of getting the &amp;lt;code&amp;gt;review_phase&amp;lt;/code&amp;gt; without the repetition. Additionally, we can see that those existing implementation still have some difference in implementation and purpose to be fully reusable by the logic that find current phase of a topic because the methods provided are helper methods for broader abstraction.&lt;br /&gt;
&lt;br /&gt;
Furthermore, the section that we attempted to refactoring out have a similar logic that is used to get the current stage as shown below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def find_current_stage(topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(self.id, topic_id)&lt;br /&gt;
    return 'Finished' if next_due_date.nil?&lt;br /&gt;
    next_due_date&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
However, it is worth pointing out that the method is not fully substitutable, particularly the internal functionality that finds the &amp;lt;code&amp;gt;@very_last_due_date&amp;lt;/code&amp;gt;. A similar logic does exist that is meant to use to acquire current due date and assist with finding current stage.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def current_stage_name(topic_id = nil)&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      return (topic_id.nil? ? 'Unknown' : current_stage(topic_id))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    due_date = find_current_stage(topic_id)&lt;br /&gt;
    unless due_date == 'Finished' || due_date.nil? || due_date.deadline_name.nil?&lt;br /&gt;
      return due_date.deadline_name&lt;br /&gt;
    end&lt;br /&gt;
    current_stage(topic_id)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
With all the findings, we have come to conclusion that the portion of the code to be dry is in similar, but required full restructure, form of existing methods. The internal logic flow itself is not fully matching the reusable methods consists across the controllers. Because of the clarity of limited reusability of existing methods, we have come to conclusion that the portions to be refactored are not duplication of any existing methods. Additionally, after a more detailed discovery, it has come to realization that the code portion of getting the current phase of the next due date was, in fact, meant to find the last due date. After further analysis of the purpose of the code, the portion has been deleted from &amp;lt;code&amp;gt;review_bids_controller.rb&amp;lt;/code&amp;gt; because there was no usage observed with the result of the execution.&lt;br /&gt;
&lt;br /&gt;
====review_bid.rb====&lt;br /&gt;
Per the previous iteration's feedback, the review_bid.rb model file presented some DRY violations. These violations are highlighted in the method below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def self.reviewer_self_topic(reviewer_id)&lt;br /&gt;
      participant = AssignmentParticipant.find_by(id: reviewer_id)&lt;br /&gt;
      team_id = participant.team.try(:id)&lt;br /&gt;
      self_topic = SignedUpTeam.where(team_id: team_id).pluck(:topic_id).first&lt;br /&gt;
&lt;br /&gt;
      return self_topic&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This method returns the topic corresponding to the reviewer that is passed into the method. Line 1 gets the participant from the reviewer_id parameter. Line 2 extracts the team that the participant is in. Line 3 will get the topic which is assigned to the participant's team. This topic is returned. Our goal while refactoring was to find a similar method that can replace this method. &lt;br /&gt;
&lt;br /&gt;
While searching through the project for similar methods which perform the same action, we came across this method in the signed_up_team.rb model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def self.topic_id(assignment_id, user_id)&lt;br /&gt;
      # team_id variable represents the team_id for this user in this assignment&lt;br /&gt;
      team_id = TeamsUser.team_id(assignment_id, user_id)&lt;br /&gt;
      topic_id_by_team_id(team_id) if team_id&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This method gets the team_id from the user_id and isolates the topic from said team_id. This method performs a similar function to reviewer_self_topic. We decided to replace all uses of reviewer_self_topic with topic_id. By reusing an existing method, we are DRYing out this code. By removing reviewer_self_topic from the code base and using an existing method, less code is being reused.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The previous uses of reviewer_self_topic such as:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def self.reviewer_bidding_data(reviewer,assignment_id)&lt;br /&gt;
      self_topic = self.reviewer_self_topic(reviewer)&lt;br /&gt;
      bidding_data = {'tid'=&amp;gt; [], 'otid' =&amp;gt; self_topic, 'priority' =&amp;gt; [], 'time'=&amp;gt;[]}&lt;br /&gt;
      bids = ReviewBid.where(participant_id: reviewer)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
were instead rewritten to adapt the existing topic_id method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def self.reviewer_bidding_data(reviewer_id,assignment_id)&lt;br /&gt;
      reviewer_user_id = AssignmentParticipant.find(reviewer_id).user_id&lt;br /&gt;
      self_topic = SignedUpTeam.topic_id(assignment_id, reviewer_user_id)&lt;br /&gt;
      bidding_data = {'tid'=&amp;gt; [], 'otid' =&amp;gt; self_topic, 'priority' =&amp;gt; [], 'time'=&amp;gt;[]}&lt;br /&gt;
      bids = ReviewBid.where(participant_id: reviewer_id)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The use of existing methods has lead to less DRY violations in the review_bid.rb file.&lt;br /&gt;
&lt;br /&gt;
====Refactoring Views (_all_actions.html.erb and _topic_names.html.erb)====&lt;br /&gt;
The last element of the prior implementation that caused DRY violations had to do with its implementation of views. Two primary views are necessary for the review bids functionality: one which shows a table where students can bid on which topic they wish to review (rendered by a file called 'show.html.erb'), and a list of assigned reviews which a student must select from (rendered by a file called 'others_work.html.erb'). &lt;br /&gt;
&lt;br /&gt;
In order to render the elements in 'show.html.erb' in particular, a number of partials must be utilized:&lt;br /&gt;
*a partial for the table's header (_table_header.html.erb)&lt;br /&gt;
*a partial for rendering each of the table's rows, describing a topic to bid on (_table_line.html.erb)&lt;br /&gt;
*a partial to contain information related to what actions are available for a student to do for a review, like edit or view (_all_actions.html.erb)&lt;br /&gt;
*a partial for finding and rendering the name of each topic one must review (_topic_names.html.erb)&lt;br /&gt;
&lt;br /&gt;
Both of these views and all four of these partials were contained within the &amp;quot;review_bids&amp;quot; directory within the views directory. The DRY violation incurred by these views has to do with these partials: in particular, '_topic_names.html.erb' and '_all_actions.html.erb' are near identical code copies to those within the sign_up_sheet views, used for rendering and displaying information for topic bidding and normal reviews.&lt;br /&gt;
&lt;br /&gt;
In order to DRY out this portion of the code, we decided that having a separate set of views for the results related to review bids were unnecessary. Within expertiza's structure, most of the views related to students choosing which topics or reviews to work on are all contained within the sign_up_sheet views. The review_vids views were copying the partials within the sign_up_sheet views because they were using the same fundamental components. Thus, we thought the best solution would be to move the two primary views for review_bids ('show.html.erb' and 'others_work.html.erb') into the sign_up_sheet views, and leave behind all redundant partials. In doing so, the redundancy of '_all_actions.html.erb' and '_topic_names.html.erb' were eliminated.&lt;br /&gt;
&lt;br /&gt;
It could be argued that this implementation could be further DRY-ed by leaving behind the other two partials, '_table_header.html.erb' and '_table_line.html.erb', as they are structurally similar to those used for topic bidding. However, this is not actually permissible, as the header and lines for topics when bidding on them for reviews are significantly different than when bidding on them for assignments. More information needs to be available when bidding on topics for an assignment, such as the number of slots and number on the waitlist, but such an idea is not applicable for bids on reviews. While it would be possible to have a single file which produces one view or another depending upon if it's bidding for topics or reviews, we believed this violated the Expert Pattern, by attempting to create a single view for two distinct purposes. Instead, we thought it better to simply have two separate partials, each which precisely gave the desired functionality. Thus, the other two partials were brought over, being renamed '_review_bids_table_header.html.erb' and '_review_bids_table_line.html.erb'.&lt;br /&gt;
&lt;br /&gt;
==Tests==&lt;br /&gt;
&lt;br /&gt;
Throughout the refactoring and merging of [https://github.com/expertiza/expertiza/pull/1822 E2085] to [https://github.com/expertiza/expertiza/pull/2150 E2151], there were some updates that has been made to the test suits to maintain corrosponding testing automation. Since our implementations and changes are focusing on DRY principal optimization, most of the test are based on the previous test that interact with the system and observe the behavior of the user views.&lt;br /&gt;
&lt;br /&gt;
===Video Demonstration===&lt;br /&gt;
 Visit [https://www.youtube.com/watch?v=wxXALQNWFcc Feature Demo] to see a video demonstrating the functionality of the review bidding feature that is working properly after our DRY principle optimization.&lt;br /&gt;
&lt;br /&gt;
===RSpec Testing===&lt;br /&gt;
One of the primary design goals when doing this refactoring was to ensure that all test cases still passed after all changes were made.&lt;br /&gt;
&lt;br /&gt;
There was a single change that needed to be made to the RSpec files for the review bidding algorithm, which was the removal of a test relying on the 'create' method of the review_bids_controller. As previously mentioned, this function was removed because it had become obsolete. Thus, the test case for this function (which simply checked if it redirected to the right page) was no longer necessary, and thus was deleted.&lt;br /&gt;
&lt;br /&gt;
Otherwise, the test cases for both the review_bids_controller and the review_bids model were manually run and found to have no errors, as shown below.&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_test_results.png|800px]]&lt;br /&gt;
&lt;br /&gt;
For details on what these specific tests were, please refer to the previous work referenced before.&lt;br /&gt;
&lt;br /&gt;
==Conclusions and Future Work==&lt;br /&gt;
While the current state of the review bidding code is operational, and is certainly more DRY and stable than the previous incarnation of this work, there are still several issues with the current state of this feature that make it difficult to recommend an immediate merge into expertiza.&lt;br /&gt;
&lt;br /&gt;
===Enhancement of Algorithm Service Stability===&lt;br /&gt;
&lt;br /&gt;
Across the process of refining the refactored front end page view along with more robust edge cases testing towards the algorithm service, we have discovered an underlying issue that could impact the availability of the review bidding algorithm service. Through cause isolation, we have observed a high correlation to flask application crash with the edge case scenario input where the algorithm service is trying to match a student who was not signed up with any topic with other students.&lt;br /&gt;
&lt;br /&gt;
Because the scope of our project was focused on refactoring, we did not have the time or prior warning to need to address these edge cases. However, we will provide the error log for the reference of any future teams who may work on the stability improvement of the algorithm service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;POST /match_topics HTTP/1.1&amp;quot; 500 -&lt;br /&gt;
{'tid': [5133, 5134, 5135, None], 'users': {'45514': {'otid': 5135, 'tid': [5133, 5134], 'time': ['2021-11-30T17:57:20.000-05:00', '2021-11-30T17:57:24.000-05:00'], 'priority': [2, 1]}, '45513': {'otid': 5134, 'tid': [5133, 5135], 'time': ['2021-11-30T17:57:41.000-05:00', '2021-11-30T17:57:43.000-05:00'], 'priority': [2, 1]}, '45512': {'otid': 5133, 'tid': [5134, 5135], 'time': ['2021-11-30T17:57:58.000-05:00', '2021-11-30T17:58:00.000-05:00'], 'priority': [2, 1]}, '45515': {'otid': None, 'tid': [], 'time': [0], 'priority': [3, 1, 4, 2]}}, 'max_accepted_proposals': 3}&lt;br /&gt;
[2021-11-28 18:10:40,576] ERROR in app: Exception on /match_topics [POST]&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 2447, in wsgi_app&lt;br /&gt;
    response = self.full_dispatch_request()&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1952, in full_dispatch_request&lt;br /&gt;
    rv = self.handle_user_exception(e)&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1821, in handle_user_exception&lt;br /&gt;
    reraise(exc_type, exc_value, tb)&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/_compat.py&amp;quot;, line 39, in reraise&lt;br /&gt;
    raise value&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1950, in full_dispatch_request&lt;br /&gt;
    rv = self.dispatch_request()&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1936, in dispatch_request&lt;br /&gt;
    return self.view_functions[rule.endpoint](**req.view_args)&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/app.py&amp;quot;, line 19, in topic_matching&lt;br /&gt;
    return jsonify(assigned_topics_model.get_student_topic_matches())&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/topics_matcher.py&amp;quot;, line 57, in get_student_topic_matches&lt;br /&gt;
    student.accept_proposal()&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/student.py&amp;quot;, line 24, in accept_proposal&lt;br /&gt;
    self.proposals.sort(key=lambda proposal: self.choices.index(proposal))&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/student.py&amp;quot;, line 24, in &amp;lt;lambda&amp;gt;&lt;br /&gt;
    self.proposals.sort(key=lambda proposal: self.choices.index(proposal))&lt;br /&gt;
ValueError: None is not in list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As we can see from the additional information provided above, the error is due to an unhandled edge case of attempting to access missing value. Our further observation also concluded that such missing value is due to the fact that one or more to-be-matched students did not have any topic signed up at the time of algorithm execution. To address the issue, a general enhancement can be implemented on the algorithm service side with Flask to increase the crash recovery stability. Further refinement of interaction flow with user in the front end can also reduce the possibility of algorithm service error.&lt;br /&gt;
&lt;br /&gt;
Additional to the unhandled cases from the algorithm service, we also noticed an inconsistency of the system due to the performance limitation of the Heroku deployment.&lt;br /&gt;
&lt;br /&gt;
[[File:Out_of_scope_External-Issue_E2151.gif|frameless|x1000px]]&lt;br /&gt;
&lt;br /&gt;
As we can see from the above recorded screen capture animation, with the exact same input, the output and algorithm service result are unstable. Because of the performance limitation of the Heroku, sometime the Flask app that deployed were overloaded. Furthermore, we have also attempted to deploy on VCL, however, we notice the limitation of VCL deployment that will become offline once the VCL reservation expired. After all, because of the focus of our tasks is on the DRY principal optimization, the external algorithm service can be improved in the future. To access and deploy the algorithm on local environment or another environment, setup guide and resource are available on [https://github.com/uahamedncsu/IntelligentAssignment IntelligentAssignment] repository.&lt;br /&gt;
&lt;br /&gt;
===Lack of Comprehensive Testing===&lt;br /&gt;
&lt;br /&gt;
A notable contradiction that was noticed when working with this project was that the previously-mentioned failed edge cases existed, yet all tests for this feature passed. This is illustrative of the fact that this feature requires better and more exhaustive testing. With the scope limitation of our tasks that focusing on the DRY principal enhancement of the Expertiza internally, the external algorithm service module was not within our focus. However, with our experience of deployment with the algorithm service, we can offer some suggestions for the future team who will address those edge cases of the algorithm service.&lt;br /&gt;
&lt;br /&gt;
When dealing with an issue with so many factors as how students bid on reviews, an extensive suite of edge cases should be considered. Any future project group working on this function should consider the following edge cases to cover:&lt;br /&gt;
* Does a student who does not bid on any reviews still get reviews?&lt;br /&gt;
* Does a student who did not submit anything for their assignment still have a review to bid on?&lt;br /&gt;
* What if there are less assignments to have reviews for than the minimum number required for all students to have the minimum number of reviews?&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
While we believe the current state of this feature is greatly improved, with many of its DRY violations removed and several noteworthy bugs corrected, we believe the feature of allowing students to bid on what to review still needs further development before it is deployed. While the basic functionality is working under ideal situations, the issues mentioned above should be addressed before this feature is put in the hands of actual instructors, as if this feature fails, it could ruin the entire reviewing process for an assignment.&lt;br /&gt;
&lt;br /&gt;
Still, we think there is notable promise to this feature, and it would be a very engaging and interesting feature if deployed successfully, so we believe develop on it should continue until it is ready for deployment.&lt;br /&gt;
&lt;br /&gt;
==Github and Related Link==&lt;br /&gt;
Github repository corresponding to this task is publicly available at [https://github.com/WeiRui-Wang/expertiza E2151 GitHub].&lt;br /&gt;
&lt;br /&gt;
Github pull request and file changes can be viewed at [https://github.com/expertiza/expertiza/pull/2150/files E2151 Pull Request].&lt;br /&gt;
&lt;br /&gt;
Github of source code of externally hosted bidding algorithm service deployment manual and files can be access at [https://github.com/uahamedncsu/IntelligentAssignment IntelligentAssignment].&lt;br /&gt;
&lt;br /&gt;
==Contributors==&lt;br /&gt;
This feature was created as part of Dr. Edward Gehringer's &amp;quot;CSC/ECE 517: Object-Oriented Design and Development&amp;quot; class, Fall 2021. The contributors were: Geoff Garrido, Ayush Luthra, and WeiRui Wang. Our project mentor was Luis Delossantos (lgdeloss@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=142211</id>
		<title>CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=142211"/>
		<updated>2021-11-30T01:59:51Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: /* review_bid.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic Overview==&lt;br /&gt;
===Statement of Problem===&lt;br /&gt;
Reviewing is an important stage of learning and improving, both as a reviewer and a reviewee, and so allowing reviewers more freedom and choice in what they review would result in better reviews and more engaged reviewers. However, currently the only way to choose a topic to review is a first-come-first-served basis, penalizing students who do not sign up quickly by not allowing them to review the topics they would be most interesting in engaging with.&lt;br /&gt;
&lt;br /&gt;
A better alternative would be to implement a bidding system, similar to that used for topics, which would allow students to establish preferences for which topics they would most like to review. A good bidding algorithm implementing with this idea would ensure that all students (who care enough to bid) receive a topic to review that they actively want.&lt;br /&gt;
&lt;br /&gt;
A prior project group created a prototype for this function, allowing students to bid on what topics they wanted to review. While the functionality was as desired, the feature was not able to be merged due to having too many DRY violations. Thus, the goal of this topic was to bring this prior implementation into the current version of the expertiza beta branch, and remove these DRY violations, so that it may be merged.&lt;br /&gt;
&lt;br /&gt;
As development continued, it became clear this prototype also had several bugs and issues that made it unable to work under several conditions. Thus, a secondary goal was to fix any issues which existed such that the feature would generally work with the functionality the prior implementation demonstrated.&lt;br /&gt;
&lt;br /&gt;
===Prior Work===&lt;br /&gt;
The prior work which is the basis for this topic is linked here [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review is linked here]. This work was done in Fall of 2020, and as previously mentioned, achieved much of the desired functionality for this task. This prior work will be referenced several times within this documentation, as it has a more comprehensive explanation of the underlying design principles behind the views, controller, model, algorithm, and RSpec tests implemented. These details will only be briefly summarized here. &lt;br /&gt;
&lt;br /&gt;
As previously noted, this prior implementation was rejected due to DRY violations, and so correcting these violations--and explaining how those corrections were done--will be the major focus of this project documentation.&lt;br /&gt;
&lt;br /&gt;
==Explanation of Feature==&lt;br /&gt;
&lt;br /&gt;
===Existing Bidding Functionality for Topics===&lt;br /&gt;
Currently in expertiza, students may bid on which topics they would like to work on. An image showcasing this functionality is given below:&lt;br /&gt;
&lt;br /&gt;
[[File:expected_review_UI.PNG]]&lt;br /&gt;
&lt;br /&gt;
Students may choose a number of topics to bid on, in order of priority, and once the deadline is reached, all students are given a topic.&lt;br /&gt;
&lt;br /&gt;
Behind the scenes, this works by utilizing a modified version of the Gale-Shapely Algorithm. This algorithm seeks to find a 'stable' matching of each student to each topic, such that in the end, all students have a topic they wanted (at least to some degree), and that the preferences of students is respected as well as possible. To help break situations where there are ties in preferences, each topic assigns a Priority to each student. This Priority is determined by A. whether the student is part of a group bidding for this topic (groups getting higher priority), and B. the time at which the bid for the topic was made (earlier bidders are given Priority). Once this has been determined and the deadline for bidding has ended, the following steps occur:&lt;br /&gt;
# Each student is matched with each topic they most prefer.&lt;br /&gt;
# If the number of students assigned to a topic is above the maximum allowed for that topic, the students with the highest Priority are assigned the topic&lt;br /&gt;
# All maximally filled topics are removed from the pool of available topics&lt;br /&gt;
# All unmatched students begin this cycle again, now choosing the most preferred topic remaining&lt;br /&gt;
# Repeat until all students are assigned a topic&lt;br /&gt;
# If any matches are 'unstable' (two students would have their preferences better met if they were swapped), perform any swaps until matches are as stable as possible.&lt;br /&gt;
&lt;br /&gt;
This algorithm has a time complexity of O(n^2). For more details on this algorithm and its implementation, refer to the previous year's work, where this algorithm was implemented.&lt;br /&gt;
&lt;br /&gt;
===Desired Functionality for Reviews===&lt;br /&gt;
&lt;br /&gt;
The desired feature for reviews should have an almost identical structure to this, with reviews instead of topics. Students should be shown a list of the topics that were worked on, and may bid on which of those topics they would like to review the most. The Priority system could be handled in the same way, with the only caveat being that a student should not be able to review their own work.&lt;br /&gt;
&lt;br /&gt;
In terms of what this feature looks like, it can be enabled as an option when editing/creating a new assignment, under the &amp;quot;Topics&amp;quot; section, using interface drop down show below.&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_interface.png|center|800px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once this option is enabled, during the review phase of an assignment, students will be able to access a new view listing all the topics of all the submitted assignments (except for their own). They will then be able to bid on as many topics as they like, assigning them a preference, in a manner similar to the interface for topic bidding. The table that allows for this drag-and-drop priorities is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_options.png|center|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Whenever the instructor decides they would like to close the window for review bidding, they may return to the options for the given assignment and navigate to &amp;quot;Topics&amp;quot;, where they will see a button marked &amp;quot;Run Review Algorithm&amp;quot;. This will make a call to the external webservice to determine which students are assigned what reviews, and will then assign those reviews to all students. Once this button is pressed, it locks out the ability for students to perform any more bidding, and cannot be pressed again. The button allowing this option is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_run_algorithm.png|center|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After this point, students may navigate to the &amp;quot;Others Work&amp;quot; option under their assignment and see all of their assigned reviews. They will see up to the maximum number of allowed reviews, but will be informed of how many they are required to do (for example, a student may see 4 reviews, but will be told they are only required to complete 2).&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
The following Use Case Diagram demonstrates the primary functionality explained in the previous section for different types of users.&lt;br /&gt;
&lt;br /&gt;
[[File:Use_Case_Diagram_Rev1_E2151.jpg|center]]&lt;br /&gt;
&lt;br /&gt;
==Plan and List of Work Done==&lt;br /&gt;
&lt;br /&gt;
===General Design Goals===&lt;br /&gt;
&lt;br /&gt;
* Move all prior work for this topic into a new version of the expertiza beta branch, without loss in functionality.&lt;br /&gt;
* Ensure all prior/expected functionality is working correctly, and if not, make any repairs or changes necessary.&lt;br /&gt;
* DRY out prior implementation's controller and model methods which have functionality that already exists within the expertiza system.&lt;br /&gt;
* Remove repetitive views and partials that exist by merging views for review bids into the set of views for sign up sheets, from which it uses partials.&lt;br /&gt;
* Ensure all present test cases still work properly after making the above changes.&lt;br /&gt;
&lt;br /&gt;
===Specific Tasks Completed===&lt;br /&gt;
&lt;br /&gt;
* Transferred over all code files relevant to the review bidding feature&lt;br /&gt;
* Re-deployed the external website which handles the review bidding algorithm&lt;br /&gt;
* Added that website's url to the webservices url's within expertiza&lt;br /&gt;
* Enhanced the stability of the webservice for the bidding algorithm by testing with edge cases and optimize the endpoint by restoring the original access endpoint reference&lt;br /&gt;
* Analyzed the necessity of the phase finding related logic code section&lt;br /&gt;
* Optimized phase finding related logic by removing unused code segment&lt;br /&gt;
* Removed an instance variable within the ''review_bids_controller'' which would have made any practical deployment fail, removing the unnecessary functionality it was created for&lt;br /&gt;
* Updated method calls to ''assignment.find_current_stage'' to their new form ''assignment.current_stage''&lt;br /&gt;
* Removed the review_bid model method ''self.reviewer_self_topic'' and replaced its usage with the already-existing ''SignedUpTeam.topic_id'' method&lt;br /&gt;
* Removed DRY-violating code used to calculate the current assignment phase which was never utilized by the controller or views&lt;br /&gt;
* Moved several view files from the ''review_bids'' view directory into the ''sign_up_sheet'' view directory. Partials which were duplicates in the two directories (''_all_actions.html.erb'' and ''_topic_names.html.erb'' were no longer necessary and deleted&lt;br /&gt;
* Refactored the naming of the variable that represents the id of the reviewer object from 'reviewer' to 'reviewer_id' for clarity&lt;br /&gt;
* Removed the unnecessary 'create' function within the review_bids_controller&lt;br /&gt;
* Removed the sparse testing files under the 'test' directory in keeping with typical expertiza structure&lt;br /&gt;
* Removed a test case from the unit tests which relied upon the removed 'create' method of the review_bids_controller&lt;br /&gt;
&lt;br /&gt;
==Initial Implementation==&lt;br /&gt;
&lt;br /&gt;
A considerable amount of time and effort was necessary to review, understand, and re-implement the previous implementation of the Review Bidding feature. While the feature was only created a year ago, several underlying functions and methods have since been refactored, and so needed to be changed in the implementation. Additionally, certain parts of how the implementation was designed did not seem to be properly implemented, and so had to be revised.&lt;br /&gt;
&lt;br /&gt;
===Code Transfer===&lt;br /&gt;
First, all files that were added in the original pull request were copied and moved to the new version of the expertiza beta branch. This includes the following files:&lt;br /&gt;
&lt;br /&gt;
*'''controllers/review_bids_controller.rb''': the primary controller that handles calls to review bids functionality from views, managing them itself or directing them to the appropriate model&lt;br /&gt;
*'''helpers/review_bids_helper.rb''': contains helper methods for rendering the rows of topics available to choose a review for&lt;br /&gt;
*'''models/review_bid.rb''': contains the methods that each individual review bid knows and manages, including assigning a review to a student, getting info on the topic it applies to, etc.&lt;br /&gt;
*'''views/review_bids/_all_actions.html.erb''': a view partial used to render the actions available to a student on the review bidding view. Nearly identical to the _all_actions file for topic bidding.&lt;br /&gt;
*'''views/review_bids/_table_header.html.erb''': a view partial used to render the head of the table for review bids. Though structurally similar to that of topics reviews, contains significantly less information, as less needs to be known by a student for particular topics to review.&lt;br /&gt;
*'''views/review_bids/_table_line.html.erb''': a view partial used to render individual rows of the review bids table. Like the table header, is structurally similar to that of topic bidding, but functions differently.&lt;br /&gt;
*'''views/review_bids/show.html.erb''': the view which displays all the available topics to bid on reviewing. Uses the aforementioned partials to render this bidding table.&lt;br /&gt;
*'''views/review_bids/others_work.html.erb''': displays the available review work which has the user has bid for.&lt;br /&gt;
*'''db/migrate/20201107203204_create_review_bids.rb''': the migration which creates the review bid objects within the expertiza database.&lt;br /&gt;
*'''spec/controllers/review_bids_controller_spec.rb''': the unit tests for the review bids controller&lt;br /&gt;
*'''spec/models/review_bid_spec.rb''': the unit tests for the review bids model&lt;br /&gt;
*'''test/controllers/review_bids_controller_test.rb''': a more elaborate feature test for the review bids functionality&lt;br /&gt;
*'''test/fixtures/review_bids.yml''': fixtures that are utilized for the review_bids_controller_test&lt;br /&gt;
*'''test/models/review_bid_test.rb''': A more elaborate feature test of the review bid model.&lt;br /&gt;
&lt;br /&gt;
In addition to adding the previous files, the following files were also added to existing pages as modifications:&lt;br /&gt;
&lt;br /&gt;
*'''controllers/student_review_controller.rb''': the student review controller's &amp;quot;list&amp;quot; method now redirects to the review_bid_controller's &amp;quot;index&amp;quot; method if the assignment in question has a review_choosing_algorithm set to &amp;quot;Bidding&amp;quot; (the option an instructor sets when they wish to allow students to bid on reviews).&lt;br /&gt;
*'''student_task/view.html.erb''': Instead of simply linking directly to the student_review controller's &amp;quot;list&amp;quot; method, the view instead checks if the assignment this view pertains to has their review_choosing_algorithm set to Bidding. If it does, and the assignment allows students to choose the topic to review (meaning the algorithm to assign bids has not yet been run), they are redirected to the 'show' method of the review_bids_controller. Otherwise, they are redirected to the 'index' method (showing them the info on their currently available topics to review).&lt;br /&gt;
*'''config/webservices.yml''': added a new url for the website that is called to run the review bidding algorithm&lt;br /&gt;
*'''config/routes.rb''': routes added for review_bids.&lt;br /&gt;
*'''views/assignments/edit/_topics.html.erb''': Added a new option box which allows an instructor to choose to allow bidding to occur using the review bidding algorithm, rather than the default 'Simple Choose.' Once this option is selected, it also offers a button that, when clicked, runs the review bidding algorithm on all currently bid upon reviews.&lt;br /&gt;
&lt;br /&gt;
===Website Reimplementation===&lt;br /&gt;
In the previous implementation, the algorithm which handles the assigning of reviews was hosted on an external website. This was done for the sake of improved performance. Thus, to get the feature in working condition, we pulled the code necessary to run the algorithm and hosted it on our own website (linked at the end of this documentation). We also made a note in the pull request that the place where this website is referenced (in the &amp;quot;assign_reviews_algorithm&amp;quot; method of the review_bids_controller) should be replaced by a proper external web tool, as is done for similar web tools in other parts of expertiza.&lt;br /&gt;
&lt;br /&gt;
===Modifications to Methods===&lt;br /&gt;
Certain methods utilized in the original version of the webpages were changed or renamed in later versions, and so, needed to be modified. The primary example of this is the method that assignments use to determine what stage of assignment completion they are in. The previous year's implementation called this method as &amp;quot;assignment.find_current_stage(topic_id),&amp;quot; but this failed when trying to execute. After comparing how this page worked to how normal review pages work, we determined the new call to this method is &amp;quot;assignment.current_stage(topic_id).&amp;quot; All calls to this method were replaced in all files.&lt;br /&gt;
&lt;br /&gt;
Another change to methods was the removal of a method from the review_bids_controller named 'create'. This method primarily served as a redirect for an aspect of the feature that was unnecessary and so removed (see the following section), that being the button to show another review. With this feature removed, this method was no longer used, and so it was removed from the controller.&lt;br /&gt;
&lt;br /&gt;
===Errors Corrected===&lt;br /&gt;
A notable period of time was also spent on determining the purpose of a particular local area that caused issues when trying to view the bids, that being a variable named &amp;quot;@number_of_reviews_to_show&amp;quot;. This variable apparently kept track of how many reviews a student needed to be shown, so that they could request another. The issue was that this was created as a local variable within the review_bids_controller, and therefore would never work outside of a manual testing environment, as the variable would need to be different from every student and every assignment. After some investigation, we realized that all this variable did was limit the number of already-assigned reviews the student was able to see (as the review bidding algorithm already assigned all possible reviews). Thus, rather than try to recreate this functionality, we simply removed it.&lt;br /&gt;
&lt;br /&gt;
This means that, when the review bidding algorithm runs, a student is able to see all of the reviews assigned to them, up to the maximum number of reviews for the assignment, and therefore have no reason to ask for any more. It may be the case that this feature could be improved by adding a possibility for students to request any reviews not assigned to any other student, or that still have available slots, using the &amp;quot;normal&amp;quot; review assignment scheme. For the time being, we did not consider this part of the baseline necessary functionality, and so did not implement it.&lt;br /&gt;
&lt;br /&gt;
==Final Implementation==&lt;br /&gt;
&lt;br /&gt;
===DRY Principle and Code Duplication Refactoring===&lt;br /&gt;
Per comments and feedbacks on the previous implementation [https://github.com/expertiza/expertiza/pull/1822 E2085], there were 3 sections of the code that potentially were DRY violations. For each of those violations, we have had made appropriate and provided the justification on the results.&lt;br /&gt;
&lt;br /&gt;
====review_bids_controller.rb====&lt;br /&gt;
For the refactoring of review bids controller.eb, the original issue is the DRY principle violation on the internal logic of finding the phase of assignments.&lt;br /&gt;
The original implementation to be refactored and optimized are shown as follow.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # Finding the current phase that we are in&lt;br /&gt;
    due_dates = AssignmentDueDate.where(parent_id: @assignment.id)&lt;br /&gt;
    @very_last_due_date = AssignmentDueDate.where(parent_id: @assignment.id).order(&amp;quot;due_at DESC&amp;quot;).limit(1)&lt;br /&gt;
    next_due_date = @very_last_due_date[0]&lt;br /&gt;
    for due_date in due_dates&lt;br /&gt;
      if due_date.due_at &amp;gt; Time.now&lt;br /&gt;
        next_due_date = due_date if due_date.due_at &amp;lt; next_due_date.due_at&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    @review_phase = next_due_date.deadline_type_id&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Through some discovery process, we have found some related logics that is already implemented from the system which enable the refactoring and reuse of the method. Some code snippets are demonstrated as follow.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.current_due_date(due_dates)&lt;br /&gt;
    #Get the current due date from list of due dates&lt;br /&gt;
    due_dates.each do |due_date|&lt;br /&gt;
      if due_date.due_at &amp;gt; Time.now&lt;br /&gt;
        current_due_date = due_date&lt;br /&gt;
        return current_due_date&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    #in case current due date not found&lt;br /&gt;
    return nil &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.teammate_review_allowed(student)&lt;br /&gt;
    # time when teammate review is allowed&lt;br /&gt;
    due_date = current_due_date(student.assignment.due_dates)&lt;br /&gt;
    student.assignment.find_current_stage == 'Finished' ||&lt;br /&gt;
    due_date &amp;amp;&amp;amp;&lt;br /&gt;
    (due_date.teammate_review_allowed_id == 3 ||&lt;br /&gt;
    due_date.teammate_review_allowed_id == 2) # late(2) or yes(3)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As we can observed above, both methods of &amp;lt;code&amp;gt;current_due_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;teammate_review_allowed&amp;lt;/code&amp;gt; provides the capability of getting the &amp;lt;code&amp;gt;review_phase&amp;lt;/code&amp;gt; without the repetition. Additionally, we can see that those existing implementation still have some difference in implementation and purpose to be fully reusable by the logic that find current phase of a topic because the methods provided are helper methods for broader abstraction.&lt;br /&gt;
&lt;br /&gt;
Furthermore, the section that we attempted to refactoring out have a similar logic that is used to get the current stage as shown below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def find_current_stage(topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(self.id, topic_id)&lt;br /&gt;
    return 'Finished' if next_due_date.nil?&lt;br /&gt;
    next_due_date&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
However, it is worth pointing out that the method is not fully substitutable, particularly the internal functionality that finds the &amp;lt;code&amp;gt;@very_last_due_date&amp;lt;/code&amp;gt;. A similar logic does exist that is meant to use to acquire current due date and assist with finding current stage.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def current_stage_name(topic_id = nil)&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      return (topic_id.nil? ? 'Unknown' : current_stage(topic_id))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    due_date = find_current_stage(topic_id)&lt;br /&gt;
    unless due_date == 'Finished' || due_date.nil? || due_date.deadline_name.nil?&lt;br /&gt;
      return due_date.deadline_name&lt;br /&gt;
    end&lt;br /&gt;
    current_stage(topic_id)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
With all the findings, we have come to conclusion that the portion of the code to be dry is in similar, but required full restructure, form of existing methods. The internal logic flow itself is not fully matching the reusable methods consists across the controllers. Because of the clarity of limited reusability of existing methods, we have come to conclusion that the portions to be refactored are not duplication of any existing methods. Additionally, after a more detailed discovery, it has come to realization that the code portion of getting the current phase of the next due date was, in fact, meant to find the last due date. After further analysis of the purpose of the code, the portion has been deleted from &amp;lt;code&amp;gt;review_bids_controller.rb&amp;lt;/code&amp;gt; because there was no usage observed with the result of the execution.&lt;br /&gt;
&lt;br /&gt;
====review_bid.rb====&lt;br /&gt;
Per the previous iteration's feedback, the review_bid.rb model file presented some DRY violations. These violations are highlighted in the method below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def self.reviewer_self_topic(reviewer_id)&lt;br /&gt;
      participant = AssignmentParticipant.find_by(id: reviewer_id)&lt;br /&gt;
      team_id = participant.team.try(:id)&lt;br /&gt;
      self_topic = SignedUpTeam.where(team_id: team_id).pluck(:topic_id).first&lt;br /&gt;
&lt;br /&gt;
      return self_topic&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This method returns the topic corresponding to the reviewer that is passed into the method. Line 1 gets the participant from the reviewer_id parameter. Line 2 extracts the team that the participant is in. Line 3 will get the topic which is assigned to the participant's team. This topic is returned. Our goal while refactoring was to find a similar method that can replace this method. &lt;br /&gt;
&lt;br /&gt;
While searching through the project for similar methods which perform the same action, we came across this method in the signed_up_team.rb model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def self.topic_id(assignment_id, user_id)&lt;br /&gt;
      # team_id variable represents the team_id for this user in this assignment&lt;br /&gt;
      team_id = TeamsUser.team_id(assignment_id, user_id)&lt;br /&gt;
      topic_id_by_team_id(team_id) if team_id&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This method gets the team_id from the user_id and isolates the topic from said team_id. This method performs a similar function to reviewer_self_topic. We decided to replace all uses of reviewer_self_topic with topic_id. By reusing an existing method, we are DRYing out this code. By removing reviewer_self_topic from the code base and using an existing method, less code is being reused.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The previous uses of reviewer_self_topic such as:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def self.reviewer_bidding_data(reviewer,assignment_id)&lt;br /&gt;
      self_topic = self.reviewer_self_topic(reviewer)&lt;br /&gt;
      bidding_data = {'tid'=&amp;gt; [], 'otid' =&amp;gt; self_topic, 'priority' =&amp;gt; [], 'time'=&amp;gt;[]}&lt;br /&gt;
      bids = ReviewBid.where(participant_id: reviewer)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
were instead rewritten to adapt the existing topic_id method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def self.reviewer_bidding_data(reviewer_id,assignment_id)&lt;br /&gt;
      reviewer_user_id = AssignmentParticipant.find(reviewer_id).user_id&lt;br /&gt;
      self_topic = SignedUpTeam.topic_id(assignment_id, reviewer_user_id)&lt;br /&gt;
      bidding_data = {'tid'=&amp;gt; [], 'otid' =&amp;gt; self_topic, 'priority' =&amp;gt; [], 'time'=&amp;gt;[]}&lt;br /&gt;
      bids = ReviewBid.where(participant_id: reviewer_id)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Refactoring Views (_all_actions.html.erb and _topic_names.html.erb)====&lt;br /&gt;
The last element of the prior implementation that caused DRY violations had to do with its implementation of views. Two primary views are necessary for the review bids functionality: one which shows a table where students can bid on which topic they wish to review (rendered by a file called 'show.html.erb'), and a list of assigned reviews which a student must select from (rendered by a file called 'others_work.html.erb'). &lt;br /&gt;
&lt;br /&gt;
In order to render the elements in 'show.html.erb' in particular, a number of partials must be utilized:&lt;br /&gt;
*a partial for the table's header (_table_header.html.erb)&lt;br /&gt;
*a partial for rendering each of the table's rows, describing a topic to bid on (_table_line.html.erb)&lt;br /&gt;
*a partial to contain information related to what actions are available for a student to do for a review, like edit or view (_all_actions.html.erb)&lt;br /&gt;
*a partial for finding and rendering the name of each topic one must review (_topic_names.html.erb)&lt;br /&gt;
&lt;br /&gt;
Both of these views and all four of these partials were contained within the &amp;quot;review_bids&amp;quot; directory within the views directory. The DRY violation incurred by these views has to do with these partials: in particular, '_topic_names.html.erb' and '_all_actions.html.erb' are near identical code copies to those within the sign_up_sheet views, used for rendering and displaying information for topic bidding and normal reviews.&lt;br /&gt;
&lt;br /&gt;
In order to DRY out this portion of the code, we decided that having a separate set of views for the results related to review bids were unnecessary. Within expertiza's structure, most of the views related to students choosing which topics or reviews to work on are all contained within the sign_up_sheet views. The review_vids views were copying the partials within the sign_up_sheet views because they were using the same fundamental components. Thus, we thought the best solution would be to move the two primary views for review_bids ('show.html.erb' and 'others_work.html.erb') into the sign_up_sheet views, and leave behind all redundant partials. In doing so, the redundancy of '_all_actions.html.erb' and '_topic_names.html.erb' were eliminated.&lt;br /&gt;
&lt;br /&gt;
It could be argued that this implementation could be further DRY-ed by leaving behind the other two partials, '_table_header.html.erb' and '_table_line.html.erb', as they are structurally similar to those used for topic bidding. However, this is not actually permissible, as the header and lines for topics when bidding on them for reviews are significantly different than when bidding on them for assignments. More information needs to be available when bidding on topics for an assignment, such as the number of slots and number on the waitlist, but such an idea is not applicable for bids on reviews. While it would be possible to have a single file which produces one view or another depending upon if it's bidding for topics or reviews, we believed this violated the Expert Pattern, by attempting to create a single view for two distinct purposes. Instead, we thought it better to simply have two separate partials, each which precisely gave the desired functionality. Thus, the other two partials were brought over, being renamed '_review_bids_table_header.html.erb' and '_review_bids_table_line.html.erb'.&lt;br /&gt;
&lt;br /&gt;
==Tests==&lt;br /&gt;
&lt;br /&gt;
Throughout the refactoring and merging of [https://github.com/expertiza/expertiza/pull/1822 E2085] to [https://github.com/expertiza/expertiza/pull/2150 E2151], there were some updates that has been made to the test suits to maintain corrosponding testing automation. Since our implementations and changes are focusing on DRY principal optimization, most of the test are based on the previous test that interact with the system and observe the behavior of the user views.&lt;br /&gt;
&lt;br /&gt;
===Video Demonstration===&lt;br /&gt;
 Visit [https://www.youtube.com/watch?v=wxXALQNWFcc Feature Demo] to see a video demonstrating the functionality of the review bidding feature that is working properly after our DRY principle optimization.&lt;br /&gt;
&lt;br /&gt;
===RSpec Testing===&lt;br /&gt;
One of the primary design goals when doing this refactoring was to ensure that all test cases still passed after all changes were made.&lt;br /&gt;
&lt;br /&gt;
There was a single change that needed to be made to the RSpec files for the review bidding algorithm, which was the removal of a test relying on the 'create' method of the review_bids_controller. As previously mentioned, this function was removed because it had become obsolete. Thus, the test case for this function (which simply checked if it redirected to the right page) was no longer necessary, and thus was deleted.&lt;br /&gt;
&lt;br /&gt;
Otherwise, the test cases for both the review_bids_controller and the review_bids model were manually run and found to have no errors, as shown below.&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_test_results.png|800px]]&lt;br /&gt;
&lt;br /&gt;
For details on what these specific tests were, please refer to the previous work referenced before.&lt;br /&gt;
&lt;br /&gt;
==Conclusions and Future Work==&lt;br /&gt;
While the current state of the review bidding code is operational, and is certainly more DRY and stable than the previous incarnation of this work, there are still several issues with the current state of this feature that make it difficult to recommend an immediate merge into expertiza.&lt;br /&gt;
&lt;br /&gt;
===Enhancement of Algorithm Service Stability===&lt;br /&gt;
&lt;br /&gt;
Across the process of refining the refactored front end page view along with more robust edge cases testing towards the algorithm service, we have discovered an underlying issue that could impact the availability of the review bidding algorithm service. Through cause isolation, we have observed a high correlation to flask application crash with the edge case scenario input where the algorithm service is trying to match a student who was not signed up with any topic with other students.&lt;br /&gt;
&lt;br /&gt;
Because the scope of our project was focused on refactoring, we did not have the time or prior warning to need to address these edge cases. However, we will provide the error log for the reference of any future teams who may work on the stability improvement of the algorithm service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;POST /match_topics HTTP/1.1&amp;quot; 500 -&lt;br /&gt;
{'tid': [5133, 5134, 5135, None], 'users': {'45514': {'otid': 5135, 'tid': [5133, 5134], 'time': ['2021-11-30T17:57:20.000-05:00', '2021-11-30T17:57:24.000-05:00'], 'priority': [2, 1]}, '45513': {'otid': 5134, 'tid': [5133, 5135], 'time': ['2021-11-30T17:57:41.000-05:00', '2021-11-30T17:57:43.000-05:00'], 'priority': [2, 1]}, '45512': {'otid': 5133, 'tid': [5134, 5135], 'time': ['2021-11-30T17:57:58.000-05:00', '2021-11-30T17:58:00.000-05:00'], 'priority': [2, 1]}, '45515': {'otid': None, 'tid': [], 'time': [0], 'priority': [3, 1, 4, 2]}}, 'max_accepted_proposals': 3}&lt;br /&gt;
[2021-11-28 18:10:40,576] ERROR in app: Exception on /match_topics [POST]&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 2447, in wsgi_app&lt;br /&gt;
    response = self.full_dispatch_request()&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1952, in full_dispatch_request&lt;br /&gt;
    rv = self.handle_user_exception(e)&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1821, in handle_user_exception&lt;br /&gt;
    reraise(exc_type, exc_value, tb)&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/_compat.py&amp;quot;, line 39, in reraise&lt;br /&gt;
    raise value&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1950, in full_dispatch_request&lt;br /&gt;
    rv = self.dispatch_request()&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1936, in dispatch_request&lt;br /&gt;
    return self.view_functions[rule.endpoint](**req.view_args)&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/app.py&amp;quot;, line 19, in topic_matching&lt;br /&gt;
    return jsonify(assigned_topics_model.get_student_topic_matches())&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/topics_matcher.py&amp;quot;, line 57, in get_student_topic_matches&lt;br /&gt;
    student.accept_proposal()&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/student.py&amp;quot;, line 24, in accept_proposal&lt;br /&gt;
    self.proposals.sort(key=lambda proposal: self.choices.index(proposal))&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/student.py&amp;quot;, line 24, in &amp;lt;lambda&amp;gt;&lt;br /&gt;
    self.proposals.sort(key=lambda proposal: self.choices.index(proposal))&lt;br /&gt;
ValueError: None is not in list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As we can see from the additional information provided above, the error is due to an unhandled edge case of attempting to access missing value. Our further observation also concluded that such missing value is due to the fact that one or more to-be-matched students did not have any topic signed up at the time of algorithm execution. To address the issue, a general enhancement can be implemented on the algorithm service side with Flask to increase the crash recovery stability. Further refinement of interaction flow with user in the front end can also reduce the possibility of algorithm service error.&lt;br /&gt;
&lt;br /&gt;
Additional to the unhandled cases from the algorithm service, we also noticed an inconsistency of the system due to the performance limitation of the Heroku deployment.&lt;br /&gt;
&lt;br /&gt;
[[File:Out_of_scope_External-Issue_E2151.gif|frameless|x1000px]]&lt;br /&gt;
&lt;br /&gt;
As we can see from the above recorded screen capture animation, with the exact same input, the output and algorithm service result are unstable. Because of the performance limitation of the Heroku, sometime the Flask app that deployed were overloaded. Furthermore, we have also attempted to deploy on VCL, however, we notice the limitation of VCL deployment that will become offline once the VCL reservation expired. After all, because of the focus of our tasks is on the DRY principal optimization, the external algorithm service can be improved in the future. To access and deploy the algorithm on local environment or another environment, setup guide and resource are available on [https://github.com/uahamedncsu/IntelligentAssignment IntelligentAssignment] repository.&lt;br /&gt;
&lt;br /&gt;
===Lack of Comprehensive Testing===&lt;br /&gt;
&lt;br /&gt;
A notable contradiction that was noticed when working with this project was that the previously-mentioned failed edge cases existed, yet all tests for this feature passed. This is illustrative of the fact that this feature requires better and more exhaustive testing. With the scope limitation of our tasks that focusing on the DRY principal enhancement of the Expertiza internally, the external algorithm service module was not within our focus. However, with our experience of deployment with the algorithm service, we can offer some suggestions for the future team who will address those edge cases of the algorithm service.&lt;br /&gt;
&lt;br /&gt;
When dealing with an issue with so many factors as how students bid on reviews, an extensive suite of edge cases should be considered. Any future project group working on this function should consider the following edge cases to cover:&lt;br /&gt;
* Does a student who does not bid on any reviews still get reviews?&lt;br /&gt;
* Does a student who did not submit anything for their assignment still have a review to bid on?&lt;br /&gt;
* What if there are less assignments to have reviews for than the minimum number required for all students to have the minimum number of reviews?&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
While we believe the current state of this feature is greatly improved, with many of its DRY violations removed and several noteworthy bugs corrected, we believe the feature of allowing students to bid on what to review still needs further development before it is deployed. While the basic functionality is working under ideal situations, the issues mentioned above should be addressed before this feature is put in the hands of actual instructors, as if this feature fails, it could ruin the entire reviewing process for an assignment.&lt;br /&gt;
&lt;br /&gt;
Still, we think there is notable promise to this feature, and it would be a very engaging and interesting feature if deployed successfully, so we believe develop on it should continue until it is ready for deployment.&lt;br /&gt;
&lt;br /&gt;
==Github and Related Link==&lt;br /&gt;
Github repository corresponding to this task is publicly available at [https://github.com/WeiRui-Wang/expertiza E2151 GitHub].&lt;br /&gt;
&lt;br /&gt;
Github pull request and file changes can be viewed at [https://github.com/expertiza/expertiza/pull/2150/files E2151 Pull Request].&lt;br /&gt;
&lt;br /&gt;
Github of source code of externally hosted bidding algorithm service deployment manual and files can be access at [https://github.com/uahamedncsu/IntelligentAssignment IntelligentAssignment].&lt;br /&gt;
&lt;br /&gt;
==Contributors==&lt;br /&gt;
This feature was created as part of Dr. Edward Gehringer's &amp;quot;CSC/ECE 517: Object-Oriented Design and Development&amp;quot; class, Fall 2021. The contributors were: Geoff Garrido, Ayush Luthra, and WeiRui Wang. Our project mentor was Luis Delossantos (lgdeloss@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=142203</id>
		<title>CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=142203"/>
		<updated>2021-11-30T01:54:34Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: /* review_bid.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic Overview==&lt;br /&gt;
===Statement of Problem===&lt;br /&gt;
Reviewing is an important stage of learning and improving, both as a reviewer and a reviewee, and so allowing reviewers more freedom and choice in what they review would result in better reviews and more engaged reviewers. However, currently the only way to choose a topic to review is a first-come-first-served basis, penalizing students who do not sign up quickly by not allowing them to review the topics they would be most interesting in engaging with.&lt;br /&gt;
&lt;br /&gt;
A better alternative would be to implement a bidding system, similar to that used for topics, which would allow students to establish preferences for which topics they would most like to review. A good bidding algorithm implementing with this idea would ensure that all students (who care enough to bid) receive a topic to review that they actively want.&lt;br /&gt;
&lt;br /&gt;
A prior project group created a prototype for this function, allowing students to bid on what topics they wanted to review. While the functionality was as desired, the feature was not able to be merged due to having too many DRY violations. Thus, the goal of this topic was to bring this prior implementation into the current version of the expertiza beta branch, and remove these DRY violations, so that it may be merged.&lt;br /&gt;
&lt;br /&gt;
As development continued, it became clear this prototype also had several bugs and issues that made it unable to work under several conditions. Thus, a secondary goal was to fix any issues which existed such that the feature would generally work with the functionality the prior implementation demonstrated.&lt;br /&gt;
&lt;br /&gt;
===Prior Work===&lt;br /&gt;
The prior work which is the basis for this topic is linked here [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review is linked here]. This work was done in Fall of 2020, and as previously mentioned, achieved much of the desired functionality for this task. This prior work will be referenced several times within this documentation, as it has a more comprehensive explanation of the underlying design principles behind the views, controller, model, algorithm, and RSpec tests implemented. These details will only be briefly summarized here. &lt;br /&gt;
&lt;br /&gt;
As previously noted, this prior implementation was rejected due to DRY violations, and so correcting these violations--and explaining how those corrections were done--will be the major focus of this project documentation.&lt;br /&gt;
&lt;br /&gt;
==Explanation of Feature==&lt;br /&gt;
&lt;br /&gt;
===Existing Bidding Functionality for Topics===&lt;br /&gt;
Currently in expertiza, students may bid on which topics they would like to work on. An image showcasing this functionality is given below:&lt;br /&gt;
&lt;br /&gt;
[[File:expected_review_UI.PNG]]&lt;br /&gt;
&lt;br /&gt;
Students may choose a number of topics to bid on, in order of priority, and once the deadline is reached, all students are given a topic.&lt;br /&gt;
&lt;br /&gt;
Behind the scenes, this works by utilizing a modified version of the Gale-Shapely Algorithm. This algorithm seeks to find a 'stable' matching of each student to each topic, such that in the end, all students have a topic they wanted (at least to some degree), and that the preferences of students is respected as well as possible. To help break situations where there are ties in preferences, each topic assigns a Priority to each student. This Priority is determined by A. whether the student is part of a group bidding for this topic (groups getting higher priority), and B. the time at which the bid for the topic was made (earlier bidders are given Priority). Once this has been determined and the deadline for bidding has ended, the following steps occur:&lt;br /&gt;
# Each student is matched with each topic they most prefer.&lt;br /&gt;
# If the number of students assigned to a topic is above the maximum allowed for that topic, the students with the highest Priority are assigned the topic&lt;br /&gt;
# All maximally filled topics are removed from the pool of available topics&lt;br /&gt;
# All unmatched students begin this cycle again, now choosing the most preferred topic remaining&lt;br /&gt;
# Repeat until all students are assigned a topic&lt;br /&gt;
# If any matches are 'unstable' (two students would have their preferences better met if they were swapped), perform any swaps until matches are as stable as possible.&lt;br /&gt;
&lt;br /&gt;
This algorithm has a time complexity of O(n^2). For more details on this algorithm and its implementation, refer to the previous year's work, where this algorithm was implemented.&lt;br /&gt;
&lt;br /&gt;
===Desired Functionality for Reviews===&lt;br /&gt;
&lt;br /&gt;
The desired feature for reviews should have an almost identical structure to this, with reviews instead of topics. Students should be shown a list of the topics that were worked on, and may bid on which of those topics they would like to review the most. The Priority system could be handled in the same way, with the only caveat being that a student should not be able to review their own work.&lt;br /&gt;
&lt;br /&gt;
In terms of what this feature looks like, it can be enabled as an option when editing/creating a new assignment, under the &amp;quot;Topics&amp;quot; section, using interface drop down show below.&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_interface.png|center|800px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once this option is enabled, during the review phase of an assignment, students will be able to access a new view listing all the topics of all the submitted assignments (except for their own). They will then be able to bid on as many topics as they like, assigning them a preference, in a manner similar to the interface for topic bidding. The table that allows for this drag-and-drop priorities is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_options.png|center|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Whenever the instructor decides they would like to close the window for review bidding, they may return to the options for the given assignment and navigate to &amp;quot;Topics&amp;quot;, where they will see a button marked &amp;quot;Run Review Algorithm&amp;quot;. This will make a call to the external webservice to determine which students are assigned what reviews, and will then assign those reviews to all students. Once this button is pressed, it locks out the ability for students to perform any more bidding, and cannot be pressed again. The button allowing this option is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_run_algorithm.png|center|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After this point, students may navigate to the &amp;quot;Others Work&amp;quot; option under their assignment and see all of their assigned reviews. They will see up to the maximum number of allowed reviews, but will be informed of how many they are required to do (for example, a student may see 4 reviews, but will be told they are only required to complete 2).&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
The following Use Case Diagram demonstrates the primary functionality explained in the previous section for different types of users.&lt;br /&gt;
&lt;br /&gt;
[[File:Use_Case_Diagram_Rev1_E2151.jpg|center]]&lt;br /&gt;
&lt;br /&gt;
==Plan and List of Work Done==&lt;br /&gt;
&lt;br /&gt;
===General Design Goals===&lt;br /&gt;
&lt;br /&gt;
* Move all prior work for this topic into a new version of the expertiza beta branch, without loss in functionality.&lt;br /&gt;
* Ensure all prior/expected functionality is working correctly, and if not, make any repairs or changes necessary.&lt;br /&gt;
* DRY out prior implementation's controller and model methods which have functionality that already exists within the expertiza system.&lt;br /&gt;
* Remove repetitive views and partials that exist by merging views for review bids into the set of views for sign up sheets, from which it uses partials.&lt;br /&gt;
* Ensure all present test cases still work properly after making the above changes.&lt;br /&gt;
&lt;br /&gt;
===Specific Tasks Completed===&lt;br /&gt;
&lt;br /&gt;
* Transferred over all code files relevant to the review bidding feature&lt;br /&gt;
* Re-deployed the external website which handles the review bidding algorithm&lt;br /&gt;
* Added that website's url to the webservices url's within expertiza&lt;br /&gt;
* Enhanced the stability of the webservice for the bidding algorithm by testing with edge cases and optimize the endpoint by restoring the original access endpoint reference&lt;br /&gt;
* Analyzed the necessity of the phase finding related logic code section&lt;br /&gt;
* Optimized phase finding related logic by removing unused code segment&lt;br /&gt;
* Removed an instance variable within the ''review_bids_controller'' which would have made any practical deployment fail, removing the unnecessary functionality it was created for&lt;br /&gt;
* Updated method calls to ''assignment.find_current_stage'' to their new form ''assignment.current_stage''&lt;br /&gt;
* Removed the review_bid model method ''self.reviewer_self_topic'' and replaced its usage with the already-existing ''SignedUpTeam.topic_id'' method&lt;br /&gt;
* Removed DRY-violating code used to calculate the current assignment phase which was never utilized by the controller or views&lt;br /&gt;
* Moved several view files from the ''review_bids'' view directory into the ''sign_up_sheet'' view directory. Partials which were duplicates in the two directories (''_all_actions.html.erb'' and ''_topic_names.html.erb'' were no longer necessary and deleted&lt;br /&gt;
* Refactored the naming of the variable that represents the id of the reviewer object from 'reviewer' to 'reviewer_id' for clarity&lt;br /&gt;
* Removed the unnecessary 'create' function within the review_bids_controller&lt;br /&gt;
* Removed the sparse testing files under the 'test' directory in keeping with typical expertiza structure&lt;br /&gt;
* Removed a test case from the unit tests which relied upon the removed 'create' method of the review_bids_controller&lt;br /&gt;
&lt;br /&gt;
==Initial Implementation==&lt;br /&gt;
&lt;br /&gt;
A considerable amount of time and effort was necessary to review, understand, and re-implement the previous implementation of the Review Bidding feature. While the feature was only created a year ago, several underlying functions and methods have since been refactored, and so needed to be changed in the implementation. Additionally, certain parts of how the implementation was designed did not seem to be properly implemented, and so had to be revised.&lt;br /&gt;
&lt;br /&gt;
===Code Transfer===&lt;br /&gt;
First, all files that were added in the original pull request were copied and moved to the new version of the expertiza beta branch. This includes the following files:&lt;br /&gt;
&lt;br /&gt;
*'''controllers/review_bids_controller.rb''': the primary controller that handles calls to review bids functionality from views, managing them itself or directing them to the appropriate model&lt;br /&gt;
*'''helpers/review_bids_helper.rb''': contains helper methods for rendering the rows of topics available to choose a review for&lt;br /&gt;
*'''models/review_bid.rb''': contains the methods that each individual review bid knows and manages, including assigning a review to a student, getting info on the topic it applies to, etc.&lt;br /&gt;
*'''views/review_bids/_all_actions.html.erb''': a view partial used to render the actions available to a student on the review bidding view. Nearly identical to the _all_actions file for topic bidding.&lt;br /&gt;
*'''views/review_bids/_table_header.html.erb''': a view partial used to render the head of the table for review bids. Though structurally similar to that of topics reviews, contains significantly less information, as less needs to be known by a student for particular topics to review.&lt;br /&gt;
*'''views/review_bids/_table_line.html.erb''': a view partial used to render individual rows of the review bids table. Like the table header, is structurally similar to that of topic bidding, but functions differently.&lt;br /&gt;
*'''views/review_bids/show.html.erb''': the view which displays all the available topics to bid on reviewing. Uses the aforementioned partials to render this bidding table.&lt;br /&gt;
*'''views/review_bids/others_work.html.erb''': displays the available review work which has the user has bid for.&lt;br /&gt;
*'''db/migrate/20201107203204_create_review_bids.rb''': the migration which creates the review bid objects within the expertiza database.&lt;br /&gt;
*'''spec/controllers/review_bids_controller_spec.rb''': the unit tests for the review bids controller&lt;br /&gt;
*'''spec/models/review_bid_spec.rb''': the unit tests for the review bids model&lt;br /&gt;
*'''test/controllers/review_bids_controller_test.rb''': a more elaborate feature test for the review bids functionality&lt;br /&gt;
*'''test/fixtures/review_bids.yml''': fixtures that are utilized for the review_bids_controller_test&lt;br /&gt;
*'''test/models/review_bid_test.rb''': A more elaborate feature test of the review bid model.&lt;br /&gt;
&lt;br /&gt;
In addition to adding the previous files, the following files were also added to existing pages as modifications:&lt;br /&gt;
&lt;br /&gt;
*'''controllers/student_review_controller.rb''': the student review controller's &amp;quot;list&amp;quot; method now redirects to the review_bid_controller's &amp;quot;index&amp;quot; method if the assignment in question has a review_choosing_algorithm set to &amp;quot;Bidding&amp;quot; (the option an instructor sets when they wish to allow students to bid on reviews).&lt;br /&gt;
*'''student_task/view.html.erb''': Instead of simply linking directly to the student_review controller's &amp;quot;list&amp;quot; method, the view instead checks if the assignment this view pertains to has their review_choosing_algorithm set to Bidding. If it does, and the assignment allows students to choose the topic to review (meaning the algorithm to assign bids has not yet been run), they are redirected to the 'show' method of the review_bids_controller. Otherwise, they are redirected to the 'index' method (showing them the info on their currently available topics to review).&lt;br /&gt;
*'''config/webservices.yml''': added a new url for the website that is called to run the review bidding algorithm&lt;br /&gt;
*'''config/routes.rb''': routes added for review_bids.&lt;br /&gt;
*'''views/assignments/edit/_topics.html.erb''': Added a new option box which allows an instructor to choose to allow bidding to occur using the review bidding algorithm, rather than the default 'Simple Choose.' Once this option is selected, it also offers a button that, when clicked, runs the review bidding algorithm on all currently bid upon reviews.&lt;br /&gt;
&lt;br /&gt;
===Website Reimplementation===&lt;br /&gt;
In the previous implementation, the algorithm which handles the assigning of reviews was hosted on an external website. This was done for the sake of improved performance. Thus, to get the feature in working condition, we pulled the code necessary to run the algorithm and hosted it on our own website (linked at the end of this documentation). We also made a note in the pull request that the place where this website is referenced (in the &amp;quot;assign_reviews_algorithm&amp;quot; method of the review_bids_controller) should be replaced by a proper external web tool, as is done for similar web tools in other parts of expertiza.&lt;br /&gt;
&lt;br /&gt;
===Modifications to Methods===&lt;br /&gt;
Certain methods utilized in the original version of the webpages were changed or renamed in later versions, and so, needed to be modified. The primary example of this is the method that assignments use to determine what stage of assignment completion they are in. The previous year's implementation called this method as &amp;quot;assignment.find_current_stage(topic_id),&amp;quot; but this failed when trying to execute. After comparing how this page worked to how normal review pages work, we determined the new call to this method is &amp;quot;assignment.current_stage(topic_id).&amp;quot; All calls to this method were replaced in all files.&lt;br /&gt;
&lt;br /&gt;
Another change to methods was the removal of a method from the review_bids_controller named 'create'. This method primarily served as a redirect for an aspect of the feature that was unnecessary and so removed (see the following section), that being the button to show another review. With this feature removed, this method was no longer used, and so it was removed from the controller.&lt;br /&gt;
&lt;br /&gt;
===Errors Corrected===&lt;br /&gt;
A notable period of time was also spent on determining the purpose of a particular local area that caused issues when trying to view the bids, that being a variable named &amp;quot;@number_of_reviews_to_show&amp;quot;. This variable apparently kept track of how many reviews a student needed to be shown, so that they could request another. The issue was that this was created as a local variable within the review_bids_controller, and therefore would never work outside of a manual testing environment, as the variable would need to be different from every student and every assignment. After some investigation, we realized that all this variable did was limit the number of already-assigned reviews the student was able to see (as the review bidding algorithm already assigned all possible reviews). Thus, rather than try to recreate this functionality, we simply removed it.&lt;br /&gt;
&lt;br /&gt;
This means that, when the review bidding algorithm runs, a student is able to see all of the reviews assigned to them, up to the maximum number of reviews for the assignment, and therefore have no reason to ask for any more. It may be the case that this feature could be improved by adding a possibility for students to request any reviews not assigned to any other student, or that still have available slots, using the &amp;quot;normal&amp;quot; review assignment scheme. For the time being, we did not consider this part of the baseline necessary functionality, and so did not implement it.&lt;br /&gt;
&lt;br /&gt;
==Final Implementation==&lt;br /&gt;
&lt;br /&gt;
===DRY Principle and Code Duplication Refactoring===&lt;br /&gt;
Per comments and feedbacks on the previous implementation [https://github.com/expertiza/expertiza/pull/1822 E2085], there were 3 sections of the code that potentially were DRY violations. For each of those violations, we have had made appropriate and provided the justification on the results.&lt;br /&gt;
&lt;br /&gt;
====review_bids_controller.rb====&lt;br /&gt;
For the refactoring of review bids controller.eb, the original issue is the DRY principle violation on the internal logic of finding the phase of assignments.&lt;br /&gt;
The original implementation to be refactored and optimized are shown as follow.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # Finding the current phase that we are in&lt;br /&gt;
    due_dates = AssignmentDueDate.where(parent_id: @assignment.id)&lt;br /&gt;
    @very_last_due_date = AssignmentDueDate.where(parent_id: @assignment.id).order(&amp;quot;due_at DESC&amp;quot;).limit(1)&lt;br /&gt;
    next_due_date = @very_last_due_date[0]&lt;br /&gt;
    for due_date in due_dates&lt;br /&gt;
      if due_date.due_at &amp;gt; Time.now&lt;br /&gt;
        next_due_date = due_date if due_date.due_at &amp;lt; next_due_date.due_at&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    @review_phase = next_due_date.deadline_type_id&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Through some discovery process, we have found some related logics that is already implemented from the system which enable the refactoring and reuse of the method. Some code snippets are demonstrated as follow.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.current_due_date(due_dates)&lt;br /&gt;
    #Get the current due date from list of due dates&lt;br /&gt;
    due_dates.each do |due_date|&lt;br /&gt;
      if due_date.due_at &amp;gt; Time.now&lt;br /&gt;
        current_due_date = due_date&lt;br /&gt;
        return current_due_date&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    #in case current due date not found&lt;br /&gt;
    return nil &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.teammate_review_allowed(student)&lt;br /&gt;
    # time when teammate review is allowed&lt;br /&gt;
    due_date = current_due_date(student.assignment.due_dates)&lt;br /&gt;
    student.assignment.find_current_stage == 'Finished' ||&lt;br /&gt;
    due_date &amp;amp;&amp;amp;&lt;br /&gt;
    (due_date.teammate_review_allowed_id == 3 ||&lt;br /&gt;
    due_date.teammate_review_allowed_id == 2) # late(2) or yes(3)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As we can observed above, both methods of &amp;lt;code&amp;gt;current_due_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;teammate_review_allowed&amp;lt;/code&amp;gt; provides the capability of getting the &amp;lt;code&amp;gt;review_phase&amp;lt;/code&amp;gt; without the repetition. Additionally, we can see that those existing implementation still have some difference in implementation and purpose to be fully reusable by the logic that find current phase of a topic because the methods provided are helper methods for broader abstraction.&lt;br /&gt;
&lt;br /&gt;
Furthermore, the section that we attempted to refactoring out have a similar logic that is used to get the current stage as shown below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def find_current_stage(topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(self.id, topic_id)&lt;br /&gt;
    return 'Finished' if next_due_date.nil?&lt;br /&gt;
    next_due_date&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
However, it is worth pointing out that the method is not fully substitutable, particularly the internal functionality that finds the &amp;lt;code&amp;gt;@very_last_due_date&amp;lt;/code&amp;gt;. A similar logic does exist that is meant to use to acquire current due date and assist with finding current stage.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def current_stage_name(topic_id = nil)&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      return (topic_id.nil? ? 'Unknown' : current_stage(topic_id))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    due_date = find_current_stage(topic_id)&lt;br /&gt;
    unless due_date == 'Finished' || due_date.nil? || due_date.deadline_name.nil?&lt;br /&gt;
      return due_date.deadline_name&lt;br /&gt;
    end&lt;br /&gt;
    current_stage(topic_id)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
With all the findings, we have come to conclusion that the portion of the code to be dry is in similar, but required full restructure, form of existing methods. The internal logic flow itself is not fully matching the reusable methods consists across the controllers. Because of the clarity of limited reusability of existing methods, we have come to conclusion that the portions to be refactored are not duplication of any existing methods. Additionally, after a more detailed discovery, it has come to realization that the code portion of getting the current phase of the next due date was, in fact, meant to find the last due date. After further analysis of the purpose of the code, the portion has been deleted from &amp;lt;code&amp;gt;review_bids_controller.rb&amp;lt;/code&amp;gt; because there was no usage observed with the result of the execution.&lt;br /&gt;
&lt;br /&gt;
====review_bid.rb====&lt;br /&gt;
Per the previous iteration's feedback, the review_bid.rb model file presented some DRY violations. These violations are highlighted in the method below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def self.reviewer_self_topic(reviewer_id)&lt;br /&gt;
      participant = AssignmentParticipant.find_by(id: reviewer_id)&lt;br /&gt;
      team_id = participant.team.try(:id)&lt;br /&gt;
      self_topic = SignedUpTeam.where(team_id: team_id).pluck(:topic_id).first&lt;br /&gt;
&lt;br /&gt;
      return self_topic&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This method returns the topic corresponding to the reviewer that is passed into the method. Line 1 gets the participant from the reviewer_id parameter. Line 2 extracts the team that the participant is in. Line 3 will get the topic which is assigned to the participant's team. This topic is returned. Our goal while refactoring was to find a similar method that can replace this method. &lt;br /&gt;
&lt;br /&gt;
While searching through the project for similar methods which perform the same action, we came across this method in the signed_up_team.rb model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def self.topic_id(assignment_id, user_id)&lt;br /&gt;
      # team_id variable represents the team_id for this user in this assignment&lt;br /&gt;
      team_id = TeamsUser.team_id(assignment_id, user_id)&lt;br /&gt;
      topic_id_by_team_id(team_id) if team_id&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This method gets the team_id from the user_id and isolates the topic from said team_id. This method performs a similar function to reviewer_self_topic. We decided to replace all uses of reviewer_self_topic with topic_id. By reusing an existing method, we are DRYing out this code. By removing reviewer_self_topic from the code base and using an existing method, less code is being reused.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The previous uses of reviewer_self_topic such as:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def self.reviewer_bidding_data(reviewer,assignment_id)&lt;br /&gt;
      self_topic = self.reviewer_self_topic(reviewer)&lt;br /&gt;
      bidding_data = {'tid'=&amp;gt; [], 'otid' =&amp;gt; self_topic, 'priority' =&amp;gt; [], 'time'=&amp;gt;[]}&lt;br /&gt;
      bids = ReviewBid.where(participant_id: reviewer)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Refactoring Views (_all_actions.html.erb and _topic_names.html.erb)====&lt;br /&gt;
The last element of the prior implementation that caused DRY violations had to do with its implementation of views. Two primary views are necessary for the review bids functionality: one which shows a table where students can bid on which topic they wish to review (rendered by a file called 'show.html.erb'), and a list of assigned reviews which a student must select from (rendered by a file called 'others_work.html.erb'). &lt;br /&gt;
&lt;br /&gt;
In order to render the elements in 'show.html.erb' in particular, a number of partials must be utilized:&lt;br /&gt;
*a partial for the table's header (_table_header.html.erb)&lt;br /&gt;
*a partial for rendering each of the table's rows, describing a topic to bid on (_table_line.html.erb)&lt;br /&gt;
*a partial to contain information related to what actions are available for a student to do for a review, like edit or view (_all_actions.html.erb)&lt;br /&gt;
*a partial for finding and rendering the name of each topic one must review (_topic_names.html.erb)&lt;br /&gt;
&lt;br /&gt;
Both of these views and all four of these partials were contained within the &amp;quot;review_bids&amp;quot; directory within the views directory. The DRY violation incurred by these views has to do with these partials: in particular, '_topic_names.html.erb' and '_all_actions.html.erb' are near identical code copies to those within the sign_up_sheet views, used for rendering and displaying information for topic bidding and normal reviews.&lt;br /&gt;
&lt;br /&gt;
In order to DRY out this portion of the code, we decided that having a separate set of views for the results related to review bids were unnecessary. Within expertiza's structure, most of the views related to students choosing which topics or reviews to work on are all contained within the sign_up_sheet views. The review_vids views were copying the partials within the sign_up_sheet views because they were using the same fundamental components. Thus, we thought the best solution would be to move the two primary views for review_bids ('show.html.erb' and 'others_work.html.erb') into the sign_up_sheet views, and leave behind all redundant partials. In doing so, the redundancy of '_all_actions.html.erb' and '_topic_names.html.erb' were eliminated.&lt;br /&gt;
&lt;br /&gt;
It could be argued that this implementation could be further DRY-ed by leaving behind the other two partials, '_table_header.html.erb' and '_table_line.html.erb', as they are structurally similar to those used for topic bidding. However, this is not actually permissible, as the header and lines for topics when bidding on them for reviews are significantly different than when bidding on them for assignments. More information needs to be available when bidding on topics for an assignment, such as the number of slots and number on the waitlist, but such an idea is not applicable for bids on reviews. While it would be possible to have a single file which produces one view or another depending upon if it's bidding for topics or reviews, we believed this violated the Expert Pattern, by attempting to create a single view for two distinct purposes. Instead, we thought it better to simply have two separate partials, each which precisely gave the desired functionality. Thus, the other two partials were brought over, being renamed '_review_bids_table_header.html.erb' and '_review_bids_table_line.html.erb'.&lt;br /&gt;
&lt;br /&gt;
==Tests==&lt;br /&gt;
&lt;br /&gt;
Throughout the refactoring and merging of [https://github.com/expertiza/expertiza/pull/1822 E2085] to [https://github.com/expertiza/expertiza/pull/2150 E2151], there were some updates that has been made to the test suits to maintain corrosponding testing automation. Since our implementations and changes are focusing on DRY principal optimization, most of the test are based on the previous test that interact with the system and observe the behavior of the user views.&lt;br /&gt;
&lt;br /&gt;
===Video Demonstration===&lt;br /&gt;
 Visit [https://www.youtube.com/watch?v=wxXALQNWFcc Feature Demo] to see a video demonstrating the functionality of the review bidding feature that is working properly after our DRY principle optimization.&lt;br /&gt;
&lt;br /&gt;
===RSpec Testing===&lt;br /&gt;
One of the primary design goals when doing this refactoring was to ensure that all test cases still passed after all changes were made.&lt;br /&gt;
&lt;br /&gt;
There was a single change that needed to be made to the RSpec files for the review bidding algorithm, which was the removal of a test relying on the 'create' method of the review_bids_controller. As previously mentioned, this function was removed because it had become obsolete. Thus, the test case for this function (which simply checked if it redirected to the right page) was no longer necessary, and thus was deleted.&lt;br /&gt;
&lt;br /&gt;
Otherwise, the test cases for both the review_bids_controller and the review_bids model were manually run and found to have no errors, as shown below.&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_test_results.png|800px]]&lt;br /&gt;
&lt;br /&gt;
For details on what these specific tests were, please refer to the previous work referenced before.&lt;br /&gt;
&lt;br /&gt;
==Conclusions and Future Work==&lt;br /&gt;
While the current state of the review bidding code is operational, and is certainly more DRY and stable than the previous incarnation of this work, there are still several issues with the current state of this feature that make it difficult to recommend an immediate merge into expertiza.&lt;br /&gt;
&lt;br /&gt;
===Enhancement of Algorithm Service Stability===&lt;br /&gt;
&lt;br /&gt;
Across the process of refining the refactored front end page view along with more robust edge cases testing towards the algorithm service, we have discovered an underlying issue that could impact the availability of the review bidding algorithm service. Through cause isolation, we have observed a high correlation to flask application crash with the edge case scenario input where the algorithm service is trying to match a student who was not signed up with any topic with other students.&lt;br /&gt;
&lt;br /&gt;
Because the scope of our project was focused on refactoring, we did not have the time or prior warning to need to address these edge cases. However, we will provide the error log for the reference of any future teams who may work on the stability improvement of the algorithm service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;POST /match_topics HTTP/1.1&amp;quot; 500 -&lt;br /&gt;
{'tid': [5133, 5134, 5135, None], 'users': {'45514': {'otid': 5135, 'tid': [5133, 5134], 'time': ['2021-11-30T17:57:20.000-05:00', '2021-11-30T17:57:24.000-05:00'], 'priority': [2, 1]}, '45513': {'otid': 5134, 'tid': [5133, 5135], 'time': ['2021-11-30T17:57:41.000-05:00', '2021-11-30T17:57:43.000-05:00'], 'priority': [2, 1]}, '45512': {'otid': 5133, 'tid': [5134, 5135], 'time': ['2021-11-30T17:57:58.000-05:00', '2021-11-30T17:58:00.000-05:00'], 'priority': [2, 1]}, '45515': {'otid': None, 'tid': [], 'time': [0], 'priority': [3, 1, 4, 2]}}, 'max_accepted_proposals': 3}&lt;br /&gt;
[2021-11-28 18:10:40,576] ERROR in app: Exception on /match_topics [POST]&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 2447, in wsgi_app&lt;br /&gt;
    response = self.full_dispatch_request()&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1952, in full_dispatch_request&lt;br /&gt;
    rv = self.handle_user_exception(e)&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1821, in handle_user_exception&lt;br /&gt;
    reraise(exc_type, exc_value, tb)&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/_compat.py&amp;quot;, line 39, in reraise&lt;br /&gt;
    raise value&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1950, in full_dispatch_request&lt;br /&gt;
    rv = self.dispatch_request()&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1936, in dispatch_request&lt;br /&gt;
    return self.view_functions[rule.endpoint](**req.view_args)&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/app.py&amp;quot;, line 19, in topic_matching&lt;br /&gt;
    return jsonify(assigned_topics_model.get_student_topic_matches())&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/topics_matcher.py&amp;quot;, line 57, in get_student_topic_matches&lt;br /&gt;
    student.accept_proposal()&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/student.py&amp;quot;, line 24, in accept_proposal&lt;br /&gt;
    self.proposals.sort(key=lambda proposal: self.choices.index(proposal))&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/student.py&amp;quot;, line 24, in &amp;lt;lambda&amp;gt;&lt;br /&gt;
    self.proposals.sort(key=lambda proposal: self.choices.index(proposal))&lt;br /&gt;
ValueError: None is not in list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As we can see from the additional information provided above, the error is due to an unhandled edge case of attempting to access missing value. Our further observation also concluded that such missing value is due to the fact that one or more to-be-matched students did not have any topic signed up at the time of algorithm execution. To address the issue, a general enhancement can be implemented on the algorithm service side with Flask to increase the crash recovery stability. Further refinement of interaction flow with user in the front end can also reduce the possibility of algorithm service error.&lt;br /&gt;
&lt;br /&gt;
Additional to the unhandled cases from the algorithm service, we also noticed an inconsistency of the system due to the performance limitation of the Heroku deployment.&lt;br /&gt;
&lt;br /&gt;
[[File:Out_of_scope_External-Issue_E2151.gif|frameless|x1000px]]&lt;br /&gt;
&lt;br /&gt;
As we can see from the above recorded screen capture animation, with the exact same input, the output and algorithm service result are unstable. Because of the performance limitation of the Heroku, sometime the Flask app that deployed were overloaded. Furthermore, we have also attempted to deploy on VCL, however, we notice the limitation of VCL deployment that will become offline once the VCL reservation expired. After all, because of the focus of our tasks is on the DRY principal optimization, the external algorithm service can be improved in the future. To access and deploy the algorithm on local environment or another environment, setup guide and resource are available on [https://github.com/uahamedncsu/IntelligentAssignment IntelligentAssignment] repository.&lt;br /&gt;
&lt;br /&gt;
===Lack of Comprehensive Testing===&lt;br /&gt;
&lt;br /&gt;
A notable contradiction that was noticed when working with this project was that the previously-mentioned failed edge cases existed, yet all tests for this feature passed. This is illustrative of the fact that this feature requires better and more exhaustive testing. With the scope limitation of our tasks that focusing on the DRY principal enhancement of the Expertiza internally, the external algorithm service module was not within our focus. However, with our experience of deployment with the algorithm service, we can offer some suggestions for the future team who will address those edge cases of the algorithm service.&lt;br /&gt;
&lt;br /&gt;
When dealing with an issue with so many factors as how students bid on reviews, an extensive suite of edge cases should be considered. Any future project group working on this function should consider the following edge cases to cover:&lt;br /&gt;
* Does a student who does not bid on any reviews still get reviews?&lt;br /&gt;
* Does a student who did not submit anything for their assignment still have a review to bid on?&lt;br /&gt;
* What if there are less assignments to have reviews for than the minimum number required for all students to have the minimum number of reviews?&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
While we believe the current state of this feature is greatly improved, with many of its DRY violations removed and several noteworthy bugs corrected, we believe the feature of allowing students to bid on what to review still needs further development before it is deployed. While the basic functionality is working under ideal situations, the issues mentioned above should be addressed before this feature is put in the hands of actual instructors, as if this feature fails, it could ruin the entire reviewing process for an assignment.&lt;br /&gt;
&lt;br /&gt;
Still, we think there is notable promise to this feature, and it would be a very engaging and interesting feature if deployed successfully, so we believe develop on it should continue until it is ready for deployment.&lt;br /&gt;
&lt;br /&gt;
==Github and Related Link==&lt;br /&gt;
Github repository corresponding to this task is publicly available at [https://github.com/WeiRui-Wang/expertiza E2151 GitHub].&lt;br /&gt;
&lt;br /&gt;
Github pull request and file changes can be viewed at [https://github.com/expertiza/expertiza/pull/2150/files E2151 Pull Request].&lt;br /&gt;
&lt;br /&gt;
Github of source code of externally hosted bidding algorithm service deployment manual and files can be access at [https://github.com/uahamedncsu/IntelligentAssignment IntelligentAssignment].&lt;br /&gt;
&lt;br /&gt;
==Contributors==&lt;br /&gt;
This feature was created as part of Dr. Edward Gehringer's &amp;quot;CSC/ECE 517: Object-Oriented Design and Development&amp;quot; class, Fall 2021. The contributors were: Geoff Garrido, Ayush Luthra, and WeiRui Wang. Our project mentor was Luis Delossantos (lgdeloss@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=142182</id>
		<title>CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=142182"/>
		<updated>2021-11-30T01:36:37Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: /* review_bid.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic Overview==&lt;br /&gt;
===Statement of Problem===&lt;br /&gt;
Reviewing is an important stage of learning and improving, both as a reviewer and a reviewee, and so allowing reviewers more freedom and choice in what they review would result in better reviews and more engaged reviewers. However, currently the only way to choose a topic to review is a first-come-first-served basis, penalizing students who do not sign up quickly by not allowing them to review the topics they would be most interesting in engaging with.&lt;br /&gt;
&lt;br /&gt;
A better alternative would be to implement a bidding system, similar to that used for topics, which would allow students to establish preferences for which topics they would most like to review. A good bidding algorithm implementing with this idea would ensure that all students (who care enough to bid) receive a topic to review that they actively want.&lt;br /&gt;
&lt;br /&gt;
A prior project group created a prototype for this function, allowing students to bid on what topics they wanted to review. While the functionality was as desired, the feature was not able to be merged due to having too many DRY violations. Thus, the goal of this topic was to bring this prior implementation into the current version of the expertiza beta branch, and remove these DRY violations, so that it may be merged.&lt;br /&gt;
&lt;br /&gt;
As development continued, it became clear this prototype also had several bugs and issues that made it unable to work under several conditions. Thus, a secondary goal was to fix any issues which existed such that the feature would generally work with the functionality the prior implementation demonstrated.&lt;br /&gt;
&lt;br /&gt;
===Prior Work===&lt;br /&gt;
The prior work which is the basis for this topic is linked here [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review is linked here]. This work was done in Fall of 2020, and as previously mentioned, achieved much of the desired functionality for this task. This prior work will be referenced several times within this documentation, as it has a more comprehensive explanation of the underlying design principles behind the views, controller, model, algorithm, and RSpec tests implemented. These details will only be briefly summarized here. &lt;br /&gt;
&lt;br /&gt;
As previously noted, this prior implementation was rejected due to DRY violations, and so correcting these violations--and explaining how those corrections were done--will be the major focus of this project documentation.&lt;br /&gt;
&lt;br /&gt;
==Explanation of Feature==&lt;br /&gt;
&lt;br /&gt;
===Existing Bidding Functionality for Topics===&lt;br /&gt;
Currently in expertiza, students may bid on which topics they would like to work on. An image showcasing this functionality is given below:&lt;br /&gt;
&lt;br /&gt;
[[File:expected_review_UI.PNG]]&lt;br /&gt;
&lt;br /&gt;
Students may choose a number of topics to bid on, in order of priority, and once the deadline is reached, all students are given a topic.&lt;br /&gt;
&lt;br /&gt;
Behind the scenes, this works by utilizing a modified version of the Gale-Shapely Algorithm. This algorithm seeks to find a 'stable' matching of each student to each topic, such that in the end, all students have a topic they wanted (at least to some degree), and that the preferences of students is respected as well as possible. To help break situations where there are ties in preferences, each topic assigns a Priority to each student. This Priority is determined by A. whether the student is part of a group bidding for this topic (groups getting higher priority), and B. the time at which the bid for the topic was made (earlier bidders are given Priority). Once this has been determined and the deadline for bidding has ended, the following steps occur:&lt;br /&gt;
# Each student is matched with each topic they most prefer.&lt;br /&gt;
# If the number of students assigned to a topic is above the maximum allowed for that topic, the students with the highest Priority are assigned the topic&lt;br /&gt;
# All maximally filled topics are removed from the pool of available topics&lt;br /&gt;
# All unmatched students begin this cycle again, now choosing the most preferred topic remaining&lt;br /&gt;
# Repeat until all students are assigned a topic&lt;br /&gt;
# If any matches are 'unstable' (two students would have their preferences better met if they were swapped), perform any swaps until matches are as stable as possible.&lt;br /&gt;
&lt;br /&gt;
This algorithm has a time complexity of O(n^2). For more details on this algorithm and its implementation, refer to the previous year's work, where this algorithm was implemented.&lt;br /&gt;
&lt;br /&gt;
===Desired Functionality for Reviews===&lt;br /&gt;
&lt;br /&gt;
The desired feature for reviews should have an almost identical structure to this, with reviews instead of topics. Students should be shown a list of the topics that were worked on, and may bid on which of those topics they would like to review the most. The Priority system could be handled in the same way, with the only caveat being that a student should not be able to review their own work.&lt;br /&gt;
&lt;br /&gt;
In terms of what this feature looks like, it can be enabled as an option when editing/creating a new assignment, under the &amp;quot;Topics&amp;quot; section, using interface drop down show below.&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_interface.png|center|800px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once this option is enabled, during the review phase of an assignment, students will be able to access a new view listing all the topics of all the submitted assignments (except for their own). They will then be able to bid on as many topics as they like, assigning them a preference, in a manner similar to the interface for topic bidding. The table that allows for this drag-and-drop priorities is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_options.png|center|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Whenever the instructor decides they would like to close the window for review bidding, they may return to the options for the given assignment and navigate to &amp;quot;Topics&amp;quot;, where they will see a button marked &amp;quot;Run Review Algorithm&amp;quot;. This will make a call to the external webservice to determine which students are assigned what reviews, and will then assign those reviews to all students. Once this button is pressed, it locks out the ability for students to perform any more bidding, and cannot be pressed again. The button allowing this option is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_run_algorithm.png|center|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After this point, students may navigate to the &amp;quot;Others Work&amp;quot; option under their assignment and see all of their assigned reviews. They will see up to the maximum number of allowed reviews, but will be informed of how many they are required to do (for example, a student may see 4 reviews, but will be told they are only required to complete 2).&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
The following Use Case Diagram demonstrates the primary functionality explained in the previous section for different types of users.&lt;br /&gt;
&lt;br /&gt;
[[File:Use_Case_Diagram_Rev1_E2151.jpg|center]]&lt;br /&gt;
&lt;br /&gt;
==Plan and List of Work Done==&lt;br /&gt;
&lt;br /&gt;
===General Design Goals===&lt;br /&gt;
&lt;br /&gt;
* Move all prior work for this topic into a new version of the expertiza beta branch, without loss in functionality.&lt;br /&gt;
* Ensure all prior/expected functionality is working correctly, and if not, make any repairs or changes necessary.&lt;br /&gt;
* DRY out prior implementation's controller and model methods which have functionality that already exists within the expertiza system.&lt;br /&gt;
* Remove repetitive views and partials that exist by merging views for review bids into the set of views for sign up sheets, from which it uses partials.&lt;br /&gt;
* Ensure all present test cases still work properly after making the above changes.&lt;br /&gt;
&lt;br /&gt;
===Specific Tasks Completed===&lt;br /&gt;
&lt;br /&gt;
* Transferred over all code files relevant to the review bidding feature&lt;br /&gt;
* Re-deployed the external website which handles the review bidding algorithm&lt;br /&gt;
* Added that website's url to the webservices url's within expertiza&lt;br /&gt;
* Enhanced the stability of the webservice for the bidding algorithm by testing with edge cases and optimize the endpoint by restoring the original access endpoint reference&lt;br /&gt;
* Analyzed the necessity of the phase finding related logic code section&lt;br /&gt;
* Optimized phase finding related logic by removing unused code segment&lt;br /&gt;
* Removed an instance variable within the ''review_bids_controller'' which would have made any practical deployment fail, removing the unnecessary functionality it was created for&lt;br /&gt;
* Updated method calls to ''assignment.find_current_stage'' to their new form ''assignment.current_stage''&lt;br /&gt;
* Removed the review_bid model method ''self.reviewer_self_topic'' and replaced its usage with the already-existing ''SignedUpTeam.topic_id'' method&lt;br /&gt;
* Removed DRY-violating code used to calculate the current assignment phase which was never utilized by the controller or views&lt;br /&gt;
* Moved several view files from the ''review_bids'' view directory into the ''sign_up_sheet'' view directory. Partials which were duplicates in the two directories (''_all_actions.html.erb'' and ''_topic_names.html.erb'' were no longer necessary and deleted&lt;br /&gt;
* Refactored the naming of the variable that represents the id of the reviewer object from 'reviewer' to 'reviewer_id' for clarity&lt;br /&gt;
* Removed the unnecessary 'create' function within the review_bids_controller&lt;br /&gt;
* Removed the sparse testing files under the 'test' directory in keeping with typical expertiza structure&lt;br /&gt;
* Removed a test case from the unit tests which relied upon the removed 'create' method of the review_bids_controller&lt;br /&gt;
&lt;br /&gt;
==Initial Implementation==&lt;br /&gt;
&lt;br /&gt;
A considerable amount of time and effort was necessary to review, understand, and re-implement the previous implementation of the Review Bidding feature. While the feature was only created a year ago, several underlying functions and methods have since been refactored, and so needed to be changed in the implementation. Additionally, certain parts of how the implementation was designed did not seem to be properly implemented, and so had to be revised.&lt;br /&gt;
&lt;br /&gt;
===Code Transfer===&lt;br /&gt;
First, all files that were added in the original pull request were copied and moved to the new version of the expertiza beta branch. This includes the following files:&lt;br /&gt;
&lt;br /&gt;
*'''controllers/review_bids_controller.rb''': the primary controller that handles calls to review bids functionality from views, managing them itself or directing them to the appropriate model&lt;br /&gt;
*'''helpers/review_bids_helper.rb''': contains helper methods for rendering the rows of topics available to choose a review for&lt;br /&gt;
*'''models/review_bid.rb''': contains the methods that each individual review bid knows and manages, including assigning a review to a student, getting info on the topic it applies to, etc.&lt;br /&gt;
*'''views/review_bids/_all_actions.html.erb''': a view partial used to render the actions available to a student on the review bidding view. Nearly identical to the _all_actions file for topic bidding.&lt;br /&gt;
*'''views/review_bids/_table_header.html.erb''': a view partial used to render the head of the table for review bids. Though structurally similar to that of topics reviews, contains significantly less information, as less needs to be known by a student for particular topics to review.&lt;br /&gt;
*'''views/review_bids/_table_line.html.erb''': a view partial used to render individual rows of the review bids table. Like the table header, is structurally similar to that of topic bidding, but functions differently.&lt;br /&gt;
*'''views/review_bids/show.html.erb''': the view which displays all the available topics to bid on reviewing. Uses the aforementioned partials to render this bidding table.&lt;br /&gt;
*'''views/review_bids/others_work.html.erb''': displays the available review work which has the user has bid for.&lt;br /&gt;
*'''db/migrate/20201107203204_create_review_bids.rb''': the migration which creates the review bid objects within the expertiza database.&lt;br /&gt;
*'''spec/controllers/review_bids_controller_spec.rb''': the unit tests for the review bids controller&lt;br /&gt;
*'''spec/models/review_bid_spec.rb''': the unit tests for the review bids model&lt;br /&gt;
*'''test/controllers/review_bids_controller_test.rb''': a more elaborate feature test for the review bids functionality&lt;br /&gt;
*'''test/fixtures/review_bids.yml''': fixtures that are utilized for the review_bids_controller_test&lt;br /&gt;
*'''test/models/review_bid_test.rb''': A more elaborate feature test of the review bid model.&lt;br /&gt;
&lt;br /&gt;
In addition to adding the previous files, the following files were also added to existing pages as modifications:&lt;br /&gt;
&lt;br /&gt;
*'''controllers/student_review_controller.rb''': the student review controller's &amp;quot;list&amp;quot; method now redirects to the review_bid_controller's &amp;quot;index&amp;quot; method if the assignment in question has a review_choosing_algorithm set to &amp;quot;Bidding&amp;quot; (the option an instructor sets when they wish to allow students to bid on reviews).&lt;br /&gt;
*'''student_task/view.html.erb''': Instead of simply linking directly to the student_review controller's &amp;quot;list&amp;quot; method, the view instead checks if the assignment this view pertains to has their review_choosing_algorithm set to Bidding. If it does, and the assignment allows students to choose the topic to review (meaning the algorithm to assign bids has not yet been run), they are redirected to the 'show' method of the review_bids_controller. Otherwise, they are redirected to the 'index' method (showing them the info on their currently available topics to review).&lt;br /&gt;
*'''config/webservices.yml''': added a new url for the website that is called to run the review bidding algorithm&lt;br /&gt;
*'''config/routes.rb''': routes added for review_bids.&lt;br /&gt;
*'''views/assignments/edit/_topics.html.erb''': Added a new option box which allows an instructor to choose to allow bidding to occur using the review bidding algorithm, rather than the default 'Simple Choose.' Once this option is selected, it also offers a button that, when clicked, runs the review bidding algorithm on all currently bid upon reviews.&lt;br /&gt;
&lt;br /&gt;
===Website Reimplementation===&lt;br /&gt;
In the previous implementation, the algorithm which handles the assigning of reviews was hosted on an external website. This was done for the sake of improved performance. Thus, to get the feature in working condition, we pulled the code necessary to run the algorithm and hosted it on our own website (linked at the end of this documentation). We also made a note in the pull request that the place where this website is referenced (in the &amp;quot;assign_reviews_algorithm&amp;quot; method of the review_bids_controller) should be replaced by a proper external web tool, as is done for similar web tools in other parts of expertiza.&lt;br /&gt;
&lt;br /&gt;
===Modifications to Methods===&lt;br /&gt;
Certain methods utilized in the original version of the webpages were changed or renamed in later versions, and so, needed to be modified. The primary example of this is the method that assignments use to determine what stage of assignment completion they are in. The previous year's implementation called this method as &amp;quot;assignment.find_current_stage(topic_id),&amp;quot; but this failed when trying to execute. After comparing how this page worked to how normal review pages work, we determined the new call to this method is &amp;quot;assignment.current_stage(topic_id).&amp;quot; All calls to this method were replaced in all files.&lt;br /&gt;
&lt;br /&gt;
Another change to methods was the removal of a method from the review_bids_controller named 'create'. This method primarily served as a redirect for an aspect of the feature that was unnecessary and so removed (see the following section), that being the button to show another review. With this feature removed, this method was no longer used, and so it was removed from the controller.&lt;br /&gt;
&lt;br /&gt;
===Errors Corrected===&lt;br /&gt;
A notable period of time was also spent on determining the purpose of a particular local area that caused issues when trying to view the bids, that being a variable named &amp;quot;@number_of_reviews_to_show&amp;quot;. This variable apparently kept track of how many reviews a student needed to be shown, so that they could request another. The issue was that this was created as a local variable within the review_bids_controller, and therefore would never work outside of a manual testing environment, as the variable would need to be different from every student and every assignment. After some investigation, we realized that all this variable did was limit the number of already-assigned reviews the student was able to see (as the review bidding algorithm already assigned all possible reviews). Thus, rather than try to recreate this functionality, we simply removed it.&lt;br /&gt;
&lt;br /&gt;
This means that, when the review bidding algorithm runs, a student is able to see all of the reviews assigned to them, up to the maximum number of reviews for the assignment, and therefore have no reason to ask for any more. It may be the case that this feature could be improved by adding a possibility for students to request any reviews not assigned to any other student, or that still have available slots, using the &amp;quot;normal&amp;quot; review assignment scheme. For the time being, we did not consider this part of the baseline necessary functionality, and so did not implement it.&lt;br /&gt;
&lt;br /&gt;
==Final Implementation==&lt;br /&gt;
&lt;br /&gt;
===DRY Principle and Code Duplication Refactoring===&lt;br /&gt;
Per comments and feedbacks on the previous implementation [https://github.com/expertiza/expertiza/pull/1822 E2085], there were 3 sections of the code that potentially were DRY violations. For each of those violations, we have had made appropriate and provided the justification on the results.&lt;br /&gt;
&lt;br /&gt;
====review_bids_controller.rb====&lt;br /&gt;
For the refactoring of review bids controller.eb, the original issue is the DRY principle violation on the internal logic of finding the phase of assignments.&lt;br /&gt;
The original implementation to be refactored and optimized are shown as follow.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # Finding the current phase that we are in&lt;br /&gt;
    due_dates = AssignmentDueDate.where(parent_id: @assignment.id)&lt;br /&gt;
    @very_last_due_date = AssignmentDueDate.where(parent_id: @assignment.id).order(&amp;quot;due_at DESC&amp;quot;).limit(1)&lt;br /&gt;
    next_due_date = @very_last_due_date[0]&lt;br /&gt;
    for due_date in due_dates&lt;br /&gt;
      if due_date.due_at &amp;gt; Time.now&lt;br /&gt;
        next_due_date = due_date if due_date.due_at &amp;lt; next_due_date.due_at&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    @review_phase = next_due_date.deadline_type_id&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Through some discovery process, we have found some related logics that is already implemented from the system which enable the refactoring and reuse of the method. Some code snippets are demonstrated as follow.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.current_due_date(due_dates)&lt;br /&gt;
    #Get the current due date from list of due dates&lt;br /&gt;
    due_dates.each do |due_date|&lt;br /&gt;
      if due_date.due_at &amp;gt; Time.now&lt;br /&gt;
        current_due_date = due_date&lt;br /&gt;
        return current_due_date&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    #in case current due date not found&lt;br /&gt;
    return nil &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.teammate_review_allowed(student)&lt;br /&gt;
    # time when teammate review is allowed&lt;br /&gt;
    due_date = current_due_date(student.assignment.due_dates)&lt;br /&gt;
    student.assignment.find_current_stage == 'Finished' ||&lt;br /&gt;
    due_date &amp;amp;&amp;amp;&lt;br /&gt;
    (due_date.teammate_review_allowed_id == 3 ||&lt;br /&gt;
    due_date.teammate_review_allowed_id == 2) # late(2) or yes(3)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As we can observed above, both methods of &amp;lt;code&amp;gt;current_due_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;teammate_review_allowed&amp;lt;/code&amp;gt; provides the capability of getting the &amp;lt;code&amp;gt;review_phase&amp;lt;/code&amp;gt; without the repetition. Additionally, we can see that those existing implementation still have some difference in implementation and purpose to be fully reusable by the logic that find current phase of a topic because the methods provided are helper methods for broader abstraction.&lt;br /&gt;
&lt;br /&gt;
Furthermore, the section that we attempted to refactoring out have a similar logic that is used to get the current stage as shown below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def find_current_stage(topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(self.id, topic_id)&lt;br /&gt;
    return 'Finished' if next_due_date.nil?&lt;br /&gt;
    next_due_date&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
However, it is worth pointing out that the method is not fully substitutable, particularly the internal functionality that finds the &amp;lt;code&amp;gt;@very_last_due_date&amp;lt;/code&amp;gt;. A similar logic does exist that is meant to use to acquire current due date and assist with finding current stage.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def current_stage_name(topic_id = nil)&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      return (topic_id.nil? ? 'Unknown' : current_stage(topic_id))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    due_date = find_current_stage(topic_id)&lt;br /&gt;
    unless due_date == 'Finished' || due_date.nil? || due_date.deadline_name.nil?&lt;br /&gt;
      return due_date.deadline_name&lt;br /&gt;
    end&lt;br /&gt;
    current_stage(topic_id)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
With all the findings, we have come to conclusion that the portion of the code to be dry is in similar, but required full restructure, form of existing methods. The internal logic flow itself is not fully matching the reusable methods consists across the controllers. Because of the clarity of limited reusability of existing methods, we have come to conclusion that the portions to be refactored are not duplication of any existing methods. Additionally, after a more detailed discovery, it has come to realization that the code portion of getting the current phase of the next due date was, in fact, meant to find the last due date. After further analysis of the purpose of the code, the portion has been deleted from &amp;lt;code&amp;gt;review_bids_controller.rb&amp;lt;/code&amp;gt; because there was no usage observed with the result of the execution.&lt;br /&gt;
&lt;br /&gt;
====review_bid.rb====&lt;br /&gt;
Per the previous iteration's feedback, the review_bid.rb model file presented some DRY violations. These violations are highlighted in the method below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def self.reviewer_self_topic(reviewer_id)&lt;br /&gt;
      participant = AssignmentParticipant.find_by(id: reviewer_id)&lt;br /&gt;
      team_id = participant.team.try(:id)&lt;br /&gt;
      self_topic = SignedUpTeam.where(team_id: team_id).pluck(:topic_id).first&lt;br /&gt;
&lt;br /&gt;
      return self_topic&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This method returns the topic corresponding to the reviewer that is passed into the method. Line 1 gets the participant from the reviewer_id parameter. Line 2 extracts the team that the participant is in. Line 3 will get the topic which is assigned to the participant's team. This topic is returned. Our goal while refactoring was to find a similar method that can replace this method. &lt;br /&gt;
&lt;br /&gt;
While searching through the project for similar methods which perform the same action, we came across this method in the signed_up_team.rb model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def self.topic_id(assignment_id, user_id)&lt;br /&gt;
      # team_id variable represents the team_id for this user in this assignment&lt;br /&gt;
      team_id = TeamsUser.team_id(assignment_id, user_id)&lt;br /&gt;
      topic_id_by_team_id(team_id) if team_id&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This method gets the team_id from the user_id and isolates the topic from said team_id. This method performs a similar function to reviewer_self_topic. We decided to replace all uses of reviewer_self_topic with topic_id. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
By reusing an existing method, we are DRYing out this code. By removing reviewer_self_topic from the code base and using an existing method, less code is being reused.&lt;br /&gt;
&lt;br /&gt;
====Refactoring Views (_all_actions.html.erb and _topic_names.html.erb)====&lt;br /&gt;
The last element of the prior implementation that caused DRY violations had to do with its implementation of views. Two primary views are necessary for the review bids functionality: one which shows a table where students can bid on which topic they wish to review (rendered by a file called 'show.html.erb'), and a list of assigned reviews which a student must select from (rendered by a file called 'others_work.html.erb'). &lt;br /&gt;
&lt;br /&gt;
In order to render the elements in 'show.html.erb' in particular, a number of partials must be utilized:&lt;br /&gt;
*a partial for the table's header (_table_header.html.erb)&lt;br /&gt;
*a partial for rendering each of the table's rows, describing a topic to bid on (_table_line.html.erb)&lt;br /&gt;
*a partial to contain information related to what actions are available for a student to do for a review, like edit or view (_all_actions.html.erb)&lt;br /&gt;
*a partial for finding and rendering the name of each topic one must review (_topic_names.html.erb)&lt;br /&gt;
&lt;br /&gt;
Both of these views and all four of these partials were contained within the &amp;quot;review_bids&amp;quot; directory within the views directory. The DRY violation incurred by these views has to do with these partials: in particular, '_topic_names.html.erb' and '_all_actions.html.erb' are near identical code copies to those within the sign_up_sheet views, used for rendering and displaying information for topic bidding and normal reviews.&lt;br /&gt;
&lt;br /&gt;
In order to DRY out this portion of the code, we decided that having a separate set of views for the results related to review bids were unnecessary. Within expertiza's structure, most of the views related to students choosing which topics or reviews to work on are all contained within the sign_up_sheet views. The review_vids views were copying the partials within the sign_up_sheet views because they were using the same fundamental components. Thus, we thought the best solution would be to move the two primary views for review_bids ('show.html.erb' and 'others_work.html.erb') into the sign_up_sheet views, and leave behind all redundant partials. In doing so, the redundancy of '_all_actions.html.erb' and '_topic_names.html.erb' were eliminated.&lt;br /&gt;
&lt;br /&gt;
It could be argued that this implementation could be further DRY-ed by leaving behind the other two partials, '_table_header.html.erb' and '_table_line.html.erb', as they are structurally similar to those used for topic bidding. However, this is not actually permissible, as the header and lines for topics when bidding on them for reviews are significantly different than when bidding on them for assignments. More information needs to be available when bidding on topics for an assignment, such as the number of slots and number on the waitlist, but such an idea is not applicable for bids on reviews. While it would be possible to have a single file which produces one view or another depending upon if it's bidding for topics or reviews, we believed this violated the Expert Pattern, by attempting to create a single view for two distinct purposes. Instead, we thought it better to simply have two separate partials, each which precisely gave the desired functionality. Thus, the other two partials were brought over, being renamed '_review_bids_table_header.html.erb' and '_review_bids_table_line.html.erb'.&lt;br /&gt;
&lt;br /&gt;
==Tests==&lt;br /&gt;
&lt;br /&gt;
Throughout the refactoring and merging of [https://github.com/expertiza/expertiza/pull/1822 E2085] to [https://github.com/expertiza/expertiza/pull/2150 E2151], there were some updates that has been made to the test suits to maintain corrosponding testing automation.&lt;br /&gt;
&lt;br /&gt;
===Video Demonstration===&lt;br /&gt;
 Visit [https://www.youtube.com/watch?v=wxXALQNWFcc Feature Demo] to see a video demonstrating the functionality of the review bidding feature that is working properly after our DRY principle optimization.&lt;br /&gt;
&lt;br /&gt;
===RSpec Testing===&lt;br /&gt;
One of the primary design goals when doing this refactoring was to ensure that all test cases still passed after all changes were made.&lt;br /&gt;
&lt;br /&gt;
There was a single change that needed to be made to the RSpec files for the review bidding algorithm, which was the removal of a test relying on the 'create' method of the review_bids_controller. As previously mentioned, this function was removed because it had become obsolete. Thus, the test case for this function (which simply checked if it redirected to the right page) was no longer necessary, and thus was deleted.&lt;br /&gt;
&lt;br /&gt;
Otherwise, the test cases for both the review_bids_controller and the review_bids model were manually run and found to have no errors, as shown below.&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_test_results.png|800px]]&lt;br /&gt;
&lt;br /&gt;
For details on what these specific tests were, please refer to the previous work referenced before.&lt;br /&gt;
&lt;br /&gt;
==Conclusions and Future Work==&lt;br /&gt;
While the current state of the review bidding code is operational, and is certainly more DRY and stable than the previous incarnation of this work, there are still several issues with the current state of this feature that make it difficult to recommend an immediate merge into expertiza.&lt;br /&gt;
&lt;br /&gt;
===Enhancement of Algorithm Service Stability===&lt;br /&gt;
&lt;br /&gt;
Across the process of refining the refactored front end page view along with more robust edge cases testing towards the algorithm service, we have discovered an underlying issue that could impact the availability of the review bidding algorithm service. Through cause isolation, we have observed a high correlation to flask application crash with the edge case scenario input where the algorithm service is trying to match a student who was not signed up with any topic with other students.&lt;br /&gt;
&lt;br /&gt;
Because the scope of our project was focused on refactoring, we did not have the time or prior warning to need to address these edge cases. However, we will provide the error log for the reference of any future teams who may work on the stability improvement of the algorithm service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;POST /match_topics HTTP/1.1&amp;quot; 500 -&lt;br /&gt;
{'tid': [5133, 5134, 5135, None], 'users': {'45514': {'otid': 5135, 'tid': [5133, 5134], 'time': ['2021-11-30T17:57:20.000-05:00', '2021-11-30T17:57:24.000-05:00'], 'priority': [2, 1]}, '45513': {'otid': 5134, 'tid': [5133, 5135], 'time': ['2021-11-30T17:57:41.000-05:00', '2021-11-30T17:57:43.000-05:00'], 'priority': [2, 1]}, '45512': {'otid': 5133, 'tid': [5134, 5135], 'time': ['2021-11-30T17:57:58.000-05:00', '2021-11-30T17:58:00.000-05:00'], 'priority': [2, 1]}, '45515': {'otid': None, 'tid': [], 'time': [0], 'priority': [3, 1, 4, 2]}}, 'max_accepted_proposals': 3}&lt;br /&gt;
[2021-11-28 18:10:40,576] ERROR in app: Exception on /match_topics [POST]&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 2447, in wsgi_app&lt;br /&gt;
    response = self.full_dispatch_request()&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1952, in full_dispatch_request&lt;br /&gt;
    rv = self.handle_user_exception(e)&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1821, in handle_user_exception&lt;br /&gt;
    reraise(exc_type, exc_value, tb)&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/_compat.py&amp;quot;, line 39, in reraise&lt;br /&gt;
    raise value&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1950, in full_dispatch_request&lt;br /&gt;
    rv = self.dispatch_request()&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1936, in dispatch_request&lt;br /&gt;
    return self.view_functions[rule.endpoint](**req.view_args)&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/app.py&amp;quot;, line 19, in topic_matching&lt;br /&gt;
    return jsonify(assigned_topics_model.get_student_topic_matches())&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/topics_matcher.py&amp;quot;, line 57, in get_student_topic_matches&lt;br /&gt;
    student.accept_proposal()&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/student.py&amp;quot;, line 24, in accept_proposal&lt;br /&gt;
    self.proposals.sort(key=lambda proposal: self.choices.index(proposal))&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/student.py&amp;quot;, line 24, in &amp;lt;lambda&amp;gt;&lt;br /&gt;
    self.proposals.sort(key=lambda proposal: self.choices.index(proposal))&lt;br /&gt;
ValueError: None is not in list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As we can see from the additional information provided above, the error is due to an unhandled edge case of attempting to access missing value. Our further observation also concluded that such missing value is due to the fact that one or more to-be-matched students did not have any topic signed up at the time of algorithm execution. To address the issue, a general enhancement can be implemented on the algorithm service side with Flask to increase the crash recovery stability. Further refinement of interaction flow with user in the front end can also reduce the possibility of algorithm service error.&lt;br /&gt;
&lt;br /&gt;
Additional to the unhandled cases from the algorithm service, we also noticed an inconsistency of the system due to the performance limitation of the Heroku deployment.&lt;br /&gt;
&lt;br /&gt;
[[File:Out_of_scope_External-Issue_E2151.gif|frameless|x1000px]]&lt;br /&gt;
&lt;br /&gt;
As we can see from the above recorded screen capture animation, with the exact same input, the output and algorithm service result are unstable. Because of the performance limitation of the Heroku, sometime the Flask app that deployed were overloaded. Furthermore, we have also attempted to deploy on VCL, however, we notice the limitation of VCL deployment that will become offline once the VCL reservation expired. After all, because of the focus of our tasks is on the DRY principal optimization, the external algorithm service can be improved in the future. To access and deploy the algorithm on local environment or another environment, setup guide and resource are available on [https://github.com/uahamedncsu/IntelligentAssignment IntelligentAssignment] repository.&lt;br /&gt;
&lt;br /&gt;
===Lack of Comprehensive Testing===&lt;br /&gt;
&lt;br /&gt;
A notable contradiction that was noticed when working with this project was that the previously-mentioned failed edge cases existed, yet all tests for this feature passed. This is illustrative of the fact that this feature requires better and more exhaustive testing. With the scope limitation of our tasks that focusing on the DRY principal enhancement of the Expertiza internally, the external algorithm service module was not within our focus. However, with our experience of deployment with the algorithm service, we can offer some suggestions for the future team who will address those edge cases of the algorithm service.&lt;br /&gt;
&lt;br /&gt;
When dealing with an issue with so many factors as how students bid on reviews, an extensive suite of edge cases should be considered. Any future project group working on this function should consider the following edge cases to cover:&lt;br /&gt;
* Does a student who does not bid on any reviews still get reviews?&lt;br /&gt;
* Does a student who did not submit anything for their assignment still have a review to bid on?&lt;br /&gt;
* What if there are less assignments to have reviews for than the minimum number required for all students to have the minimum number of reviews?&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
While we believe the current state of this feature is greatly improved, with many of its DRY violations removed and several noteworthy bugs corrected, we believe the feature of allowing students to bid on what to review still needs further development before it is deployed. While the basic functionality is working under ideal situations, the issues mentioned above should be addressed before this feature is put in the hands of actual instructors, as if this feature fails, it could ruin the entire reviewing process for an assignment.&lt;br /&gt;
&lt;br /&gt;
Still, we think there is notable promise to this feature, and it would be a very engaging and interesting feature if deployed successfully, so we believe develop on it should continue until it is ready for deployment.&lt;br /&gt;
&lt;br /&gt;
==Github and Related Link==&lt;br /&gt;
Github repository corresponding to this task is publicly available at [https://github.com/WeiRui-Wang/expertiza E2151 GitHub].&lt;br /&gt;
&lt;br /&gt;
Github pull request and file changes can be viewed at [https://github.com/expertiza/expertiza/pull/2150/files E2151 Pull Request].&lt;br /&gt;
&lt;br /&gt;
Github of source code of externally hosted bidding algorithm service deployment manual and files can be access at [https://github.com/uahamedncsu/IntelligentAssignment IntelligentAssignment].&lt;br /&gt;
&lt;br /&gt;
==Contributors==&lt;br /&gt;
This feature was created as part of Dr. Edward Gehringer's &amp;quot;CSC/ECE 517: Object-Oriented Design and Development&amp;quot; class, Fall 2021. The contributors were: Geoff Garrido, Ayush Luthra, and WeiRui Wang. Our project mentor was Luis Delossantos (lgdeloss@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=142179</id>
		<title>CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=142179"/>
		<updated>2021-11-30T01:34:35Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: /* review_bid.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic Overview==&lt;br /&gt;
===Statement of Problem===&lt;br /&gt;
Reviewing is an important stage of learning and improving, both as a reviewer and a reviewee, and so allowing reviewers more freedom and choice in what they review would result in better reviews and more engaged reviewers. However, currently the only way to choose a topic to review is a first-come-first-served basis, penalizing students who do not sign up quickly by not allowing them to review the topics they would be most interesting in engaging with.&lt;br /&gt;
&lt;br /&gt;
A better alternative would be to implement a bidding system, similar to that used for topics, which would allow students to establish preferences for which topics they would most like to review. A good bidding algorithm implementing with this idea would ensure that all students (who care enough to bid) receive a topic to review that they actively want.&lt;br /&gt;
&lt;br /&gt;
A prior project group created a prototype for this function, allowing students to bid on what topics they wanted to review. While the functionality was as desired, the feature was not able to be merged due to having too many DRY violations. Thus, the goal of this topic was to bring this prior implementation into the current version of the expertiza beta branch, and remove these DRY violations, so that it may be merged.&lt;br /&gt;
&lt;br /&gt;
As development continued, it became clear this prototype also had several bugs and issues that made it unable to work under several conditions. Thus, a secondary goal was to fix any issues which existed such that the feature would generally work with the functionality the prior implementation demonstrated.&lt;br /&gt;
&lt;br /&gt;
===Prior Work===&lt;br /&gt;
The prior work which is the basis for this topic is linked here [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review is linked here]. This work was done in Fall of 2020, and as previously mentioned, achieved much of the desired functionality for this task. This prior work will be referenced several times within this documentation, as it has a more comprehensive explanation of the underlying design principles behind the views, controller, model, algorithm, and RSpec tests implemented. These details will only be briefly summarized here. &lt;br /&gt;
&lt;br /&gt;
As previously noted, this prior implementation was rejected due to DRY violations, and so correcting these violations--and explaining how those corrections were done--will be the major focus of this project documentation.&lt;br /&gt;
&lt;br /&gt;
==Explanation of Feature==&lt;br /&gt;
&lt;br /&gt;
===Existing Bidding Functionality for Topics===&lt;br /&gt;
Currently in expertiza, students may bid on which topics they would like to work on. An image showcasing this functionality is given below:&lt;br /&gt;
&lt;br /&gt;
[[File:expected_review_UI.PNG]]&lt;br /&gt;
&lt;br /&gt;
Students may choose a number of topics to bid on, in order of priority, and once the deadline is reached, all students are given a topic.&lt;br /&gt;
&lt;br /&gt;
Behind the scenes, this works by utilizing a modified version of the Gale-Shapely Algorithm. This algorithm seeks to find a 'stable' matching of each student to each topic, such that in the end, all students have a topic they wanted (at least to some degree), and that the preferences of students is respected as well as possible. To help break situations where there are ties in preferences, each topic assigns a Priority to each student. This Priority is determined by A. whether the student is part of a group bidding for this topic (groups getting higher priority), and B. the time at which the bid for the topic was made (earlier bidders are given Priority). Once this has been determined and the deadline for bidding has ended, the following steps occur:&lt;br /&gt;
# Each student is matched with each topic they most prefer.&lt;br /&gt;
# If the number of students assigned to a topic is above the maximum allowed for that topic, the students with the highest Priority are assigned the topic&lt;br /&gt;
# All maximally filled topics are removed from the pool of available topics&lt;br /&gt;
# All unmatched students begin this cycle again, now choosing the most preferred topic remaining&lt;br /&gt;
# Repeat until all students are assigned a topic&lt;br /&gt;
# If any matches are 'unstable' (two students would have their preferences better met if they were swapped), perform any swaps until matches are as stable as possible.&lt;br /&gt;
&lt;br /&gt;
This algorithm has a time complexity of O(n^2). For more details on this algorithm and its implementation, refer to the previous year's work, where this algorithm was implemented.&lt;br /&gt;
&lt;br /&gt;
===Desired Functionality for Reviews===&lt;br /&gt;
&lt;br /&gt;
The desired feature for reviews should have an almost identical structure to this, with reviews instead of topics. Students should be shown a list of the topics that were worked on, and may bid on which of those topics they would like to review the most. The Priority system could be handled in the same way, with the only caveat being that a student should not be able to review their own work.&lt;br /&gt;
&lt;br /&gt;
In terms of what this feature looks like, it can be enabled as an option when editing/creating a new assignment, under the &amp;quot;Topics&amp;quot; section, using interface drop down show below.&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_interface.png|center|800px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once this option is enabled, during the review phase of an assignment, students will be able to access a new view listing all the topics of all the submitted assignments (except for their own). They will then be able to bid on as many topics as they like, assigning them a preference, in a manner similar to the interface for topic bidding. The table that allows for this drag-and-drop priorities is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_options.png|center|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Whenever the instructor decides they would like to close the window for review bidding, they may return to the options for the given assignment and navigate to &amp;quot;Topics&amp;quot;, where they will see a button marked &amp;quot;Run Review Algorithm&amp;quot;. This will make a call to the external webservice to determine which students are assigned what reviews, and will then assign those reviews to all students. Once this button is pressed, it locks out the ability for students to perform any more bidding, and cannot be pressed again. The button allowing this option is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_run_algorithm.png|center|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After this point, students may navigate to the &amp;quot;Others Work&amp;quot; option under their assignment and see all of their assigned reviews. They will see up to the maximum number of allowed reviews, but will be informed of how many they are required to do (for example, a student may see 4 reviews, but will be told they are only required to complete 2).&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
The following Use Case Diagram demonstrates the primary functionality explained in the previous section for different types of users.&lt;br /&gt;
&lt;br /&gt;
[[File:Use_Case_Diagram_Rev1_E2151.jpg|center]]&lt;br /&gt;
&lt;br /&gt;
==Plan and List of Work Done==&lt;br /&gt;
&lt;br /&gt;
===General Design Goals===&lt;br /&gt;
&lt;br /&gt;
* Move all prior work for this topic into a new version of the expertiza beta branch, without loss in functionality.&lt;br /&gt;
* Ensure all prior/expected functionality is working correctly, and if not, make any repairs or changes necessary.&lt;br /&gt;
* DRY out prior implementation's controller and model methods which have functionality that already exists within the expertiza system.&lt;br /&gt;
* Remove repetitive views and partials that exist by merging views for review bids into the set of views for sign up sheets, from which it uses partials.&lt;br /&gt;
* Ensure all present test cases still work properly after making the above changes.&lt;br /&gt;
&lt;br /&gt;
===Specific Tasks Completed===&lt;br /&gt;
&lt;br /&gt;
* Transferred over all code files relevant to the review bidding feature&lt;br /&gt;
* Re-deployed the external website which handles the review bidding algorithm&lt;br /&gt;
* Added that website's url to the webservices url's within expertiza&lt;br /&gt;
* Enhanced the stability of the webservice for the bidding algorithm by testing with edge cases and optimize the endpoint by restoring the original access endpoint reference&lt;br /&gt;
* Analyzed the necessity of the phase finding related logic code section&lt;br /&gt;
* Optimized phase finding related logic by removing unused code segment&lt;br /&gt;
* Removed an instance variable within the ''review_bids_controller'' which would have made any practical deployment fail, removing the unnecessary functionality it was created for&lt;br /&gt;
* Updated method calls to ''assignment.find_current_stage'' to their new form ''assignment.current_stage''&lt;br /&gt;
* Removed the review_bid model method ''self.reviewer_self_topic'' and replaced its usage with the already-existing ''SignedUpTeam.topic_id'' method&lt;br /&gt;
* Removed DRY-violating code used to calculate the current assignment phase which was never utilized by the controller or views&lt;br /&gt;
* Moved several view files from the ''review_bids'' view directory into the ''sign_up_sheet'' view directory. Partials which were duplicates in the two directories (''_all_actions.html.erb'' and ''_topic_names.html.erb'' were no longer necessary and deleted&lt;br /&gt;
* Refactored the naming of the variable that represents the id of the reviewer object from 'reviewer' to 'reviewer_id' for clarity&lt;br /&gt;
* Removed the unnecessary 'create' function within the review_bids_controller&lt;br /&gt;
* Removed the sparse testing files under the 'test' directory in keeping with typical expertiza structure&lt;br /&gt;
* Removed a test case from the unit tests which relied upon the removed 'create' method of the review_bids_controller&lt;br /&gt;
&lt;br /&gt;
==Initial Implementation==&lt;br /&gt;
&lt;br /&gt;
A considerable amount of time and effort was necessary to review, understand, and re-implement the previous implementation of the Review Bidding feature. While the feature was only created a year ago, several underlying functions and methods have since been refactored, and so needed to be changed in the implementation. Additionally, certain parts of how the implementation was designed did not seem to be properly implemented, and so had to be revised.&lt;br /&gt;
&lt;br /&gt;
===Code Transfer===&lt;br /&gt;
First, all files that were added in the original pull request were copied and moved to the new version of the expertiza beta branch. This includes the following files:&lt;br /&gt;
&lt;br /&gt;
*'''controllers/review_bids_controller.rb''': the primary controller that handles calls to review bids functionality from views, managing them itself or directing them to the appropriate model&lt;br /&gt;
*'''helpers/review_bids_helper.rb''': contains helper methods for rendering the rows of topics available to choose a review for&lt;br /&gt;
*'''models/review_bid.rb''': contains the methods that each individual review bid knows and manages, including assigning a review to a student, getting info on the topic it applies to, etc.&lt;br /&gt;
*'''views/review_bids/_all_actions.html.erb''': a view partial used to render the actions available to a student on the review bidding view. Nearly identical to the _all_actions file for topic bidding.&lt;br /&gt;
*'''views/review_bids/_table_header.html.erb''': a view partial used to render the head of the table for review bids. Though structurally similar to that of topics reviews, contains significantly less information, as less needs to be known by a student for particular topics to review.&lt;br /&gt;
*'''views/review_bids/_table_line.html.erb''': a view partial used to render individual rows of the review bids table. Like the table header, is structurally similar to that of topic bidding, but functions differently.&lt;br /&gt;
*'''views/review_bids/show.html.erb''': the view which displays all the available topics to bid on reviewing. Uses the aforementioned partials to render this bidding table.&lt;br /&gt;
*'''views/review_bids/others_work.html.erb''': displays the available review work which has the user has bid for.&lt;br /&gt;
*'''db/migrate/20201107203204_create_review_bids.rb''': the migration which creates the review bid objects within the expertiza database.&lt;br /&gt;
*'''spec/controllers/review_bids_controller_spec.rb''': the unit tests for the review bids controller&lt;br /&gt;
*'''spec/models/review_bid_spec.rb''': the unit tests for the review bids model&lt;br /&gt;
*'''test/controllers/review_bids_controller_test.rb''': a more elaborate feature test for the review bids functionality&lt;br /&gt;
*'''test/fixtures/review_bids.yml''': fixtures that are utilized for the review_bids_controller_test&lt;br /&gt;
*'''test/models/review_bid_test.rb''': A more elaborate feature test of the review bid model.&lt;br /&gt;
&lt;br /&gt;
In addition to adding the previous files, the following files were also added to existing pages as modifications:&lt;br /&gt;
&lt;br /&gt;
*'''controllers/student_review_controller.rb''': the student review controller's &amp;quot;list&amp;quot; method now redirects to the review_bid_controller's &amp;quot;index&amp;quot; method if the assignment in question has a review_choosing_algorithm set to &amp;quot;Bidding&amp;quot; (the option an instructor sets when they wish to allow students to bid on reviews).&lt;br /&gt;
*'''student_task/view.html.erb''': Instead of simply linking directly to the student_review controller's &amp;quot;list&amp;quot; method, the view instead checks if the assignment this view pertains to has their review_choosing_algorithm set to Bidding. If it does, and the assignment allows students to choose the topic to review (meaning the algorithm to assign bids has not yet been run), they are redirected to the 'show' method of the review_bids_controller. Otherwise, they are redirected to the 'index' method (showing them the info on their currently available topics to review).&lt;br /&gt;
*'''config/webservices.yml''': added a new url for the website that is called to run the review bidding algorithm&lt;br /&gt;
*'''config/routes.rb''': routes added for review_bids.&lt;br /&gt;
*'''views/assignments/edit/_topics.html.erb''': Added a new option box which allows an instructor to choose to allow bidding to occur using the review bidding algorithm, rather than the default 'Simple Choose.' Once this option is selected, it also offers a button that, when clicked, runs the review bidding algorithm on all currently bid upon reviews.&lt;br /&gt;
&lt;br /&gt;
===Website Reimplementation===&lt;br /&gt;
In the previous implementation, the algorithm which handles the assigning of reviews was hosted on an external website. This was done for the sake of improved performance. Thus, to get the feature in working condition, we pulled the code necessary to run the algorithm and hosted it on our own website (linked at the end of this documentation). We also made a note in the pull request that the place where this website is referenced (in the &amp;quot;assign_reviews_algorithm&amp;quot; method of the review_bids_controller) should be replaced by a proper external web tool, as is done for similar web tools in other parts of expertiza.&lt;br /&gt;
&lt;br /&gt;
===Modifications to Methods===&lt;br /&gt;
Certain methods utilized in the original version of the webpages were changed or renamed in later versions, and so, needed to be modified. The primary example of this is the method that assignments use to determine what stage of assignment completion they are in. The previous year's implementation called this method as &amp;quot;assignment.find_current_stage(topic_id),&amp;quot; but this failed when trying to execute. After comparing how this page worked to how normal review pages work, we determined the new call to this method is &amp;quot;assignment.current_stage(topic_id).&amp;quot; All calls to this method were replaced in all files.&lt;br /&gt;
&lt;br /&gt;
Another change to methods was the removal of a method from the review_bids_controller named 'create'. This method primarily served as a redirect for an aspect of the feature that was unnecessary and so removed (see the following section), that being the button to show another review. With this feature removed, this method was no longer used, and so it was removed from the controller.&lt;br /&gt;
&lt;br /&gt;
===Errors Corrected===&lt;br /&gt;
A notable period of time was also spent on determining the purpose of a particular local area that caused issues when trying to view the bids, that being a variable named &amp;quot;@number_of_reviews_to_show&amp;quot;. This variable apparently kept track of how many reviews a student needed to be shown, so that they could request another. The issue was that this was created as a local variable within the review_bids_controller, and therefore would never work outside of a manual testing environment, as the variable would need to be different from every student and every assignment. After some investigation, we realized that all this variable did was limit the number of already-assigned reviews the student was able to see (as the review bidding algorithm already assigned all possible reviews). Thus, rather than try to recreate this functionality, we simply removed it.&lt;br /&gt;
&lt;br /&gt;
This means that, when the review bidding algorithm runs, a student is able to see all of the reviews assigned to them, up to the maximum number of reviews for the assignment, and therefore have no reason to ask for any more. It may be the case that this feature could be improved by adding a possibility for students to request any reviews not assigned to any other student, or that still have available slots, using the &amp;quot;normal&amp;quot; review assignment scheme. For the time being, we did not consider this part of the baseline necessary functionality, and so did not implement it.&lt;br /&gt;
&lt;br /&gt;
==Final Implementation==&lt;br /&gt;
&lt;br /&gt;
===DRY Principle and Code Duplication Refactoring===&lt;br /&gt;
Per comments and feedbacks on the previous implementation [https://github.com/expertiza/expertiza/pull/1822 E2085], there were 3 sections of the code that potentially were DRY violations. For each of those violations, we have had made appropriate and provided the justification on the results.&lt;br /&gt;
&lt;br /&gt;
====review_bids_controller.rb====&lt;br /&gt;
For the refactoring of review bids controller.eb, the original issue is the DRY principle violation on the internal logic of finding the phase of assignments.&lt;br /&gt;
The original implementation to be refactored and optimized are shown as follow.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # Finding the current phase that we are in&lt;br /&gt;
    due_dates = AssignmentDueDate.where(parent_id: @assignment.id)&lt;br /&gt;
    @very_last_due_date = AssignmentDueDate.where(parent_id: @assignment.id).order(&amp;quot;due_at DESC&amp;quot;).limit(1)&lt;br /&gt;
    next_due_date = @very_last_due_date[0]&lt;br /&gt;
    for due_date in due_dates&lt;br /&gt;
      if due_date.due_at &amp;gt; Time.now&lt;br /&gt;
        next_due_date = due_date if due_date.due_at &amp;lt; next_due_date.due_at&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    @review_phase = next_due_date.deadline_type_id&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Through some discovery process, we have found some related logics that is already implemented from the system which enable the refactoring and reuse of the method. Some code snippets are demonstrated as follow.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.current_due_date(due_dates)&lt;br /&gt;
    #Get the current due date from list of due dates&lt;br /&gt;
    due_dates.each do |due_date|&lt;br /&gt;
      if due_date.due_at &amp;gt; Time.now&lt;br /&gt;
        current_due_date = due_date&lt;br /&gt;
        return current_due_date&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    #in case current due date not found&lt;br /&gt;
    return nil &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.teammate_review_allowed(student)&lt;br /&gt;
    # time when teammate review is allowed&lt;br /&gt;
    due_date = current_due_date(student.assignment.due_dates)&lt;br /&gt;
    student.assignment.find_current_stage == 'Finished' ||&lt;br /&gt;
    due_date &amp;amp;&amp;amp;&lt;br /&gt;
    (due_date.teammate_review_allowed_id == 3 ||&lt;br /&gt;
    due_date.teammate_review_allowed_id == 2) # late(2) or yes(3)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As we can observed above, both methods of &amp;lt;code&amp;gt;current_due_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;teammate_review_allowed&amp;lt;/code&amp;gt; provides the capability of getting the &amp;lt;code&amp;gt;review_phase&amp;lt;/code&amp;gt; without the repetition. Additionally, we can see that those existing implementation still have some difference in implementation and purpose to be fully reusable by the logic that find current phase of a topic because the methods provided are helper methods for broader abstraction.&lt;br /&gt;
&lt;br /&gt;
Furthermore, the section that we attempted to refactoring out have a similar logic that is used to get the current stage as shown below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def find_current_stage(topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(self.id, topic_id)&lt;br /&gt;
    return 'Finished' if next_due_date.nil?&lt;br /&gt;
    next_due_date&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
However, it is worth pointing out that the method is not fully substitutable, particularly the internal functionality that finds the &amp;lt;code&amp;gt;@very_last_due_date&amp;lt;/code&amp;gt;. A similar logic does exist that is meant to use to acquire current due date and assist with finding current stage.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def current_stage_name(topic_id = nil)&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      return (topic_id.nil? ? 'Unknown' : current_stage(topic_id))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    due_date = find_current_stage(topic_id)&lt;br /&gt;
    unless due_date == 'Finished' || due_date.nil? || due_date.deadline_name.nil?&lt;br /&gt;
      return due_date.deadline_name&lt;br /&gt;
    end&lt;br /&gt;
    current_stage(topic_id)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
With all the findings, we have come to conclusion that the portion of the code to be dry is in similar, but required full restructure, form of existing methods. The internal logic flow itself is not fully matching the reusable methods consists across the controllers. Because of the clarity of limited reusability of existing methods, we have come to conclusion that the portions to be refactored are not duplication of any existing methods. Additionally, after a more detailed discovery, it has come to realization that the code portion of getting the current phase of the next due date was, in fact, meant to find the last due date. After further analysis of the purpose of the code, the portion has been deleted from &amp;lt;code&amp;gt;review_bids_controller.rb&amp;lt;/code&amp;gt; because there was no usage observed with the result of the execution.&lt;br /&gt;
&lt;br /&gt;
====review_bid.rb====&lt;br /&gt;
Per the previous iteration's feedback, the review_bid.rb model file presented some DRY violations. These violations are highlighted in the method below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def self.reviewer_self_topic(reviewer_id)&lt;br /&gt;
      participant = AssignmentParticipant.find_by(id: reviewer_id)&lt;br /&gt;
      team_id = participant.team.try(:id)&lt;br /&gt;
      self_topic = SignedUpTeam.where(team_id: team_id).pluck(:topic_id).first&lt;br /&gt;
&lt;br /&gt;
      return self_topic&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This method returns the topic corresponding to the reviewer that is passed into the method. Line 1 gets the participant from the reviewer_id parameter. Line 2 extracts the team that the participant is in. Line 3 will get the topic which is assigned to the participant's team. This topic is returned. Our goal while refactoring was to find a similar method that can replace this method. &lt;br /&gt;
&lt;br /&gt;
While searching through the project for similar methods which perform the same action, we came across this method in the signed_up_team.rb model:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def self.topic_id(assignment_id, user_id)&lt;br /&gt;
      # team_id variable represents the team_id for this user in this assignment&lt;br /&gt;
      team_id = TeamsUser.team_id(assignment_id, user_id)&lt;br /&gt;
      topic_id_by_team_id(team_id) if team_id&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This method gets the team_id from the user_id and isolates the topic from said team_id. This method performs a similar function to reviewer_self_topic. We decided to replace all uses of reviewer_self_topic with topic_id. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Refactoring Views (_all_actions.html.erb and _topic_names.html.erb)====&lt;br /&gt;
The last element of the prior implementation that caused DRY violations had to do with its implementation of views. Two primary views are necessary for the review bids functionality: one which shows a table where students can bid on which topic they wish to review (rendered by a file called 'show.html.erb'), and a list of assigned reviews which a student must select from (rendered by a file called 'others_work.html.erb'). &lt;br /&gt;
&lt;br /&gt;
In order to render the elements in 'show.html.erb' in particular, a number of partials must be utilized:&lt;br /&gt;
*a partial for the table's header (_table_header.html.erb)&lt;br /&gt;
*a partial for rendering each of the table's rows, describing a topic to bid on (_table_line.html.erb)&lt;br /&gt;
*a partial to contain information related to what actions are available for a student to do for a review, like edit or view (_all_actions.html.erb)&lt;br /&gt;
*a partial for finding and rendering the name of each topic one must review (_topic_names.html.erb)&lt;br /&gt;
&lt;br /&gt;
Both of these views and all four of these partials were contained within the &amp;quot;review_bids&amp;quot; directory within the views directory. The DRY violation incurred by these views has to do with these partials: in particular, '_topic_names.html.erb' and '_all_actions.html.erb' are near identical code copies to those within the sign_up_sheet views, used for rendering and displaying information for topic bidding and normal reviews.&lt;br /&gt;
&lt;br /&gt;
In order to DRY out this portion of the code, we decided that having a separate set of views for the results related to review bids were unnecessary. Within expertiza's structure, most of the views related to students choosing which topics or reviews to work on are all contained within the sign_up_sheet views. The review_vids views were copying the partials within the sign_up_sheet views because they were using the same fundamental components. Thus, we thought the best solution would be to move the two primary views for review_bids ('show.html.erb' and 'others_work.html.erb') into the sign_up_sheet views, and leave behind all redundant partials. In doing so, the redundancy of '_all_actions.html.erb' and '_topic_names.html.erb' were eliminated.&lt;br /&gt;
&lt;br /&gt;
It could be argued that this implementation could be further DRY-ed by leaving behind the other two partials, '_table_header.html.erb' and '_table_line.html.erb', as they are structurally similar to those used for topic bidding. However, this is not actually permissible, as the header and lines for topics when bidding on them for reviews are significantly different than when bidding on them for assignments. More information needs to be available when bidding on topics for an assignment, such as the number of slots and number on the waitlist, but such an idea is not applicable for bids on reviews. While it would be possible to have a single file which produces one view or another depending upon if it's bidding for topics or reviews, we believed this violated the Expert Pattern, by attempting to create a single view for two distinct purposes. Instead, we thought it better to simply have two separate partials, each which precisely gave the desired functionality. Thus, the other two partials were brought over, being renamed '_review_bids_table_header.html.erb' and '_review_bids_table_line.html.erb'.&lt;br /&gt;
&lt;br /&gt;
==Tests==&lt;br /&gt;
&lt;br /&gt;
Throughout the refactoring and merging of [https://github.com/expertiza/expertiza/pull/1822 E2085] to [https://github.com/expertiza/expertiza/pull/2150 E2151], there were some updates that has been made to the test suits to maintain corrosponding testing automation.&lt;br /&gt;
&lt;br /&gt;
===Video Demonstration===&lt;br /&gt;
 Visit [https://www.youtube.com/watch?v=wxXALQNWFcc Feature Demo] to see a video demonstrating the functionality of the review bidding feature that is working properly after our DRY principle optimization.&lt;br /&gt;
&lt;br /&gt;
===RSpec Testing===&lt;br /&gt;
One of the primary design goals when doing this refactoring was to ensure that all test cases still passed after all changes were made.&lt;br /&gt;
&lt;br /&gt;
There was a single change that needed to be made to the RSpec files for the review bidding algorithm, which was the removal of a test relying on the 'create' method of the review_bids_controller. As previously mentioned, this function was removed because it had become obsolete. Thus, the test case for this function (which simply checked if it redirected to the right page) was no longer necessary, and thus was deleted.&lt;br /&gt;
&lt;br /&gt;
Otherwise, the test cases for both the review_bids_controller and the review_bids model were manually run and found to have no errors, as shown below.&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_test_results.png|800px]]&lt;br /&gt;
&lt;br /&gt;
For details on what these specific tests were, please refer to the previous work referenced before.&lt;br /&gt;
&lt;br /&gt;
==Conclusions and Future Work==&lt;br /&gt;
While the current state of the review bidding code is operational, and is certainly more DRY and stable than the previous incarnation of this work, there are still several issues with the current state of this feature that make it difficult to recommend an immediate merge into expertiza.&lt;br /&gt;
&lt;br /&gt;
===Enhancement of Algorithm Service Stability===&lt;br /&gt;
&lt;br /&gt;
Across the process of refining the refactored front end page view along with more robust edge cases testing towards the algorithm service, we have discovered an underlying issue that could impact the availability of the review bidding algorithm service. Through cause isolation, we have observed a high correlation to flask application crash with the edge case scenario input where the algorithm service is trying to match a student who was not signed up with any topic with other students.&lt;br /&gt;
&lt;br /&gt;
Because the scope of our project was focused on refactoring, we did not have the time or prior warning to need to address these edge cases. However, we will provide the error log for the reference of any future teams who may work on the stability improvement of the algorithm service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;POST /match_topics HTTP/1.1&amp;quot; 500 -&lt;br /&gt;
{'tid': [5133, 5134, 5135, None], 'users': {'45514': {'otid': 5135, 'tid': [5133, 5134], 'time': ['2021-11-30T17:57:20.000-05:00', '2021-11-30T17:57:24.000-05:00'], 'priority': [2, 1]}, '45513': {'otid': 5134, 'tid': [5133, 5135], 'time': ['2021-11-30T17:57:41.000-05:00', '2021-11-30T17:57:43.000-05:00'], 'priority': [2, 1]}, '45512': {'otid': 5133, 'tid': [5134, 5135], 'time': ['2021-11-30T17:57:58.000-05:00', '2021-11-30T17:58:00.000-05:00'], 'priority': [2, 1]}, '45515': {'otid': None, 'tid': [], 'time': [0], 'priority': [3, 1, 4, 2]}}, 'max_accepted_proposals': 3}&lt;br /&gt;
[2021-11-28 18:10:40,576] ERROR in app: Exception on /match_topics [POST]&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 2447, in wsgi_app&lt;br /&gt;
    response = self.full_dispatch_request()&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1952, in full_dispatch_request&lt;br /&gt;
    rv = self.handle_user_exception(e)&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1821, in handle_user_exception&lt;br /&gt;
    reraise(exc_type, exc_value, tb)&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/_compat.py&amp;quot;, line 39, in reraise&lt;br /&gt;
    raise value&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1950, in full_dispatch_request&lt;br /&gt;
    rv = self.dispatch_request()&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1936, in dispatch_request&lt;br /&gt;
    return self.view_functions[rule.endpoint](**req.view_args)&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/app.py&amp;quot;, line 19, in topic_matching&lt;br /&gt;
    return jsonify(assigned_topics_model.get_student_topic_matches())&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/topics_matcher.py&amp;quot;, line 57, in get_student_topic_matches&lt;br /&gt;
    student.accept_proposal()&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/student.py&amp;quot;, line 24, in accept_proposal&lt;br /&gt;
    self.proposals.sort(key=lambda proposal: self.choices.index(proposal))&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/student.py&amp;quot;, line 24, in &amp;lt;lambda&amp;gt;&lt;br /&gt;
    self.proposals.sort(key=lambda proposal: self.choices.index(proposal))&lt;br /&gt;
ValueError: None is not in list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As we can see from the additional information provided above, the error is due to an unhandled edge case of attempting to access missing value. Our further observation also concluded that such missing value is due to the fact that one or more to-be-matched students did not have any topic signed up at the time of algorithm execution. To address the issue, a general enhancement can be implemented on the algorithm service side with Flask to increase the crash recovery stability. Further refinement of interaction flow with user in the front end can also reduce the possibility of algorithm service error.&lt;br /&gt;
&lt;br /&gt;
Additional to the unhandled cases from the algorithm service, we also noticed an inconsistency of the system due to the performance limitation of the Heroku deployment.&lt;br /&gt;
&lt;br /&gt;
[[File:Out_of_scope_External-Issue_E2151.gif|frameless|x1000px]]&lt;br /&gt;
&lt;br /&gt;
As we can see from the above recorded screen capture animation, with the exact same input, the output and algorithm service result are unstable. Because of the performance limitation of the Heroku, sometime the Flask app that deployed were overloaded. Furthermore, we have also attempted to deploy on VCL, however, we notice the limitation of VCL deployment that will become offline once the VCL reservation expired. After all, because of the focus of our tasks is on the DRY principal optimization, the external algorithm service can be improved in the future. To access and deploy the algorithm on local environment or another environment, setup guide and resource are available on [https://github.com/uahamedncsu/IntelligentAssignment IntelligentAssignment] repository.&lt;br /&gt;
&lt;br /&gt;
===Lack of Comprehensive Testing===&lt;br /&gt;
&lt;br /&gt;
A notable contradiction that was noticed when working with this project was that the previously-mentioned failed edge cases existed, yet all tests for this feature passed. This is illustrative of the fact that this feature requires better and more exhaustive testing. With the scope limitation of our tasks that focusing on the DRY principal enhancement of the Expertiza internally, the external algorithm service module was not within our focus. However, with our experience of deployment with the algorithm service, we can offer some suggestions for the future team who will address those edge cases of the algorithm service.&lt;br /&gt;
&lt;br /&gt;
When dealing with an issue with so many factors as how students bid on reviews, an extensive suite of edge cases should be considered. Any future project group working on this function should consider the following edge cases to cover:&lt;br /&gt;
* Does a student who does not bid on any reviews still get reviews?&lt;br /&gt;
* Does a student who did not submit anything for their assignment still have a review to bid on?&lt;br /&gt;
* What if there are less assignments to have reviews for than the minimum number required for all students to have the minimum number of reviews?&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
While we believe the current state of this feature is greatly improved, with many of its DRY violations removed and several noteworthy bugs corrected, we believe the feature of allowing students to bid on what to review still needs further development before it is deployed. While the basic functionality is working under ideal situations, the issues mentioned above should be addressed before this feature is put in the hands of actual instructors, as if this feature fails, it could ruin the entire reviewing process for an assignment.&lt;br /&gt;
&lt;br /&gt;
Still, we think there is notable promise to this feature, and it would be a very engaging and interesting feature if deployed successfully, so we believe develop on it should continue until it is ready for deployment.&lt;br /&gt;
&lt;br /&gt;
==Github and Related Link==&lt;br /&gt;
Github repository corresponding to this task is publicly available at [https://github.com/WeiRui-Wang/expertiza E2151 GitHub].&lt;br /&gt;
&lt;br /&gt;
Github pull request and file changes can be viewed at [https://github.com/expertiza/expertiza/pull/2150/files E2151 Pull Request].&lt;br /&gt;
&lt;br /&gt;
Github of source code of externally hosted bidding algorithm service deployment manual and files can be access at [https://github.com/uahamedncsu/IntelligentAssignment IntelligentAssignment].&lt;br /&gt;
&lt;br /&gt;
==Contributors==&lt;br /&gt;
This feature was created as part of Dr. Edward Gehringer's &amp;quot;CSC/ECE 517: Object-Oriented Design and Development&amp;quot; class, Fall 2021. The contributors were: Geoff Garrido, Ayush Luthra, and WeiRui Wang. Our project mentor was Luis Delossantos (lgdeloss@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=142167</id>
		<title>CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=142167"/>
		<updated>2021-11-30T01:22:23Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: /* review_bid.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic Overview==&lt;br /&gt;
===Statement of Problem===&lt;br /&gt;
Reviewing is an important stage of learning and improving, both as a reviewer and a reviewee, and so allowing reviewers more freedom and choice in what they review would result in better reviews and more engaged reviewers. However, currently the only way to choose a topic to review is a first-come-first-served basis, penalizing students who do not sign up quickly by not allowing them to review the topics they would be most interesting in engaging with.&lt;br /&gt;
&lt;br /&gt;
A better alternative would be to implement a bidding system, similar to that used for topics, which would allow students to establish preferences for which topics they would most like to review. A good bidding algorithm implementing with this idea would ensure that all students (who care enough to bid) receive a topic to review that they actively want.&lt;br /&gt;
&lt;br /&gt;
A prior project group created a prototype for this function, allowing students to bid on what topics they wanted to review. While the functionality was as desired, the feature was not able to be merged due to having too many DRY violations. Thus, the goal of this topic was to bring this prior implementation into the current version of the expertiza beta branch, and remove these DRY violations, so that it may be merged.&lt;br /&gt;
&lt;br /&gt;
As development continued, it became clear this prototype also had several bugs and issues that made it unable to work under several conditions. Thus, a secondary goal was to fix any issues which existed such that the feature would generally work with the functionality the prior implementation demonstrated.&lt;br /&gt;
&lt;br /&gt;
===Prior Work===&lt;br /&gt;
The prior work which is the basis for this topic is linked here [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review is linked here]. This work was done in Fall of 2020, and as previously mentioned, achieved much of the desired functionality for this task. This prior work will be referenced several times within this documentation, as it has a more comprehensive explanation of the underlying design principles behind the views, controller, model, algorithm, and RSpec tests implemented. These details will only be briefly summarized here. &lt;br /&gt;
&lt;br /&gt;
As previously noted, this prior implementation was rejected due to DRY violations, and so correcting these violations--and explaining how those corrections were done--will be the major focus of this project documentation.&lt;br /&gt;
&lt;br /&gt;
==Explanation of Feature==&lt;br /&gt;
&lt;br /&gt;
===Existing Bidding Functionality for Topics===&lt;br /&gt;
Currently in expertiza, students may bid on which topics they would like to work on. An image showcasing this functionality is given below:&lt;br /&gt;
&lt;br /&gt;
[[File:expected_review_UI.PNG]]&lt;br /&gt;
&lt;br /&gt;
Students may choose a number of topics to bid on, in order of priority, and once the deadline is reached, all students are given a topic.&lt;br /&gt;
&lt;br /&gt;
Behind the scenes, this works by utilizing a modified version of the Gale-Shapely Algorithm. This algorithm seeks to find a 'stable' matching of each student to each topic, such that in the end, all students have a topic they wanted (at least to some degree), and that the preferences of students is respected as well as possible. To help break situations where there are ties in preferences, each topic assigns a Priority to each student. This Priority is determined by A. whether the student is part of a group bidding for this topic (groups getting higher priority), and B. the time at which the bid for the topic was made (earlier bidders are given Priority). Once this has been determined and the deadline for bidding has ended, the following steps occur:&lt;br /&gt;
# Each student is matched with each topic they most prefer.&lt;br /&gt;
# If the number of students assigned to a topic is above the maximum allowed for that topic, the students with the highest Priority are assigned the topic&lt;br /&gt;
# All maximally filled topics are removed from the pool of available topics&lt;br /&gt;
# All unmatched students begin this cycle again, now choosing the most preferred topic remaining&lt;br /&gt;
# Repeat until all students are assigned a topic&lt;br /&gt;
# If any matches are 'unstable' (two students would have their preferences better met if they were swapped), perform any swaps until matches are as stable as possible.&lt;br /&gt;
&lt;br /&gt;
This algorithm has a time complexity of O(n^2). For more details on this algorithm and its implementation, refer to the previous year's work, where this algorithm was implemented.&lt;br /&gt;
&lt;br /&gt;
===Desired Functionality for Reviews===&lt;br /&gt;
&lt;br /&gt;
The desired feature for reviews should have an almost identical structure to this, with reviews instead of topics. Students should be shown a list of the topics that were worked on, and may bid on which of those topics they would like to review the most. The Priority system could be handled in the same way, with the only caveat being that a student should not be able to review their own work.&lt;br /&gt;
&lt;br /&gt;
In terms of what this feature looks like, it can be enabled as an option when editing/creating a new assignment, under the &amp;quot;Topics&amp;quot; section, using interface drop down show below.&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_interface.png|center|800px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once this option is enabled, during the review phase of an assignment, students will be able to access a new view listing all the topics of all the submitted assignments (except for their own). They will then be able to bid on as many topics as they like, assigning them a preference, in a manner similar to the interface for topic bidding. The table that allows for this drag-and-drop priorities is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_options.png|center|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Whenever the instructor decides they would like to close the window for review bidding, they may return to the options for the given assignment and navigate to &amp;quot;Topics&amp;quot;, where they will see a button marked &amp;quot;Run Review Algorithm&amp;quot;. This will make a call to the external webservice to determine which students are assigned what reviews, and will then assign those reviews to all students. Once this button is pressed, it locks out the ability for students to perform any more bidding, and cannot be pressed again. The button allowing this option is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_run_algorithm.png|center|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After this point, students may navigate to the &amp;quot;Others Work&amp;quot; option under their assignment and see all of their assigned reviews. They will see up to the maximum number of allowed reviews, but will be informed of how many they are required to do (for example, a student may see 4 reviews, but will be told they are only required to complete 2).&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
The following Use Case Diagram demonstrates the primary functionality explained in the previous section for different types of users.&lt;br /&gt;
&lt;br /&gt;
[[File:Use_Case_Diagram_Rev1_E2151.jpg|center]]&lt;br /&gt;
&lt;br /&gt;
==Plan and List of Work Done==&lt;br /&gt;
&lt;br /&gt;
===General Design Goals===&lt;br /&gt;
&lt;br /&gt;
* Move all prior work for this topic into a new version of the expertiza beta branch, without loss in functionality.&lt;br /&gt;
* Ensure all prior/expected functionality is working correctly, and if not, make any repairs or changes necessary.&lt;br /&gt;
* DRY out prior implementation's controller and model methods which have functionality that already exists within the expertiza system.&lt;br /&gt;
* Remove repetitive views and partials that exist by merging views for review bids into the set of views for sign up sheets, from which it uses partials.&lt;br /&gt;
* Ensure all present test cases still work properly after making the above changes.&lt;br /&gt;
&lt;br /&gt;
===Specific Tasks Completed===&lt;br /&gt;
&lt;br /&gt;
* Transferred over all code files relevant to the review bidding feature&lt;br /&gt;
* Re-deployed the external website which handles the review bidding algorithm&lt;br /&gt;
* Added that website's url to the webservices url's within expertiza&lt;br /&gt;
* Enhanced the stability of the webservice for the bidding algorithm by testing with edge cases and optimize the endpoint by restoring the original access endpoint reference&lt;br /&gt;
* Analyzed the necessity of the phase finding related logic code section&lt;br /&gt;
* Optimized phase finding related logic by removing unused code segment&lt;br /&gt;
* Removed an instance variable within the ''review_bids_controller'' which would have made any practical deployment fail, removing the unnecessary functionality it was created for&lt;br /&gt;
* Updated method calls to ''assignment.find_current_stage'' to their new form ''assignment.current_stage''&lt;br /&gt;
* Removed the review_bid model method ''self.reviewer_self_topic'' and replaced its usage with the already-existing ''SignedUpTeam.topic_id'' method&lt;br /&gt;
* Removed DRY-violating code used to calculate the current assignment phase which was never utilized by the controller or views&lt;br /&gt;
* Moved several view files from the ''review_bids'' view directory into the ''sign_up_sheet'' view directory. Partials which were duplicates in the two directories (''_all_actions.html.erb'' and ''_topic_names.html.erb'' were no longer necessary and deleted&lt;br /&gt;
* Refactored the naming of the variable that represents the id of the reviewer object from 'reviewer' to 'reviewer_id' for clarity&lt;br /&gt;
* Removed the unnecessary 'create' function within the review_bids_controller&lt;br /&gt;
* Removed the sparse testing files under the 'test' directory in keeping with typical expertiza structure&lt;br /&gt;
* Removed a test case from the unit tests which relied upon the removed 'create' method of the review_bids_controller&lt;br /&gt;
&lt;br /&gt;
==Initial Implementation==&lt;br /&gt;
&lt;br /&gt;
A considerable amount of time and effort was necessary to review, understand, and re-implement the previous implementation of the Review Bidding feature. While the feature was only created a year ago, several underlying functions and methods have since been refactored, and so needed to be changed in the implementation. Additionally, certain parts of how the implementation was designed did not seem to be properly implemented, and so had to be revised.&lt;br /&gt;
&lt;br /&gt;
===Code Transfer===&lt;br /&gt;
First, all files that were added in the original pull request were copied and moved to the new version of the expertiza beta branch. This includes the following files:&lt;br /&gt;
&lt;br /&gt;
*'''controllers/review_bids_controller.rb''': the primary controller that handles calls to review bids functionality from views, managing them itself or directing them to the appropriate model&lt;br /&gt;
*'''helpers/review_bids_helper.rb''': contains helper methods for rendering the rows of topics available to choose a review for&lt;br /&gt;
*'''models/review_bid.rb''': contains the methods that each individual review bid knows and manages, including assigning a review to a student, getting info on the topic it applies to, etc.&lt;br /&gt;
*'''views/review_bids/_all_actions.html.erb''': a view partial used to render the actions available to a student on the review bidding view. Nearly identical to the _all_actions file for topic bidding.&lt;br /&gt;
*'''views/review_bids/_table_header.html.erb''': a view partial used to render the head of the table for review bids. Though structurally similar to that of topics reviews, contains significantly less information, as less needs to be known by a student for particular topics to review.&lt;br /&gt;
*'''views/review_bids/_table_line.html.erb''': a view partial used to render individual rows of the review bids table. Like the table header, is structurally similar to that of topic bidding, but functions differently.&lt;br /&gt;
*'''views/review_bids/show.html.erb''': the view which displays all the available topics to bid on reviewing. Uses the aforementioned partials to render this bidding table.&lt;br /&gt;
*'''views/review_bids/others_work.html.erb''': displays the available review work which has the user has bid for.&lt;br /&gt;
*'''db/migrate/20201107203204_create_review_bids.rb''': the migration which creates the review bid objects within the expertiza database.&lt;br /&gt;
*'''spec/controllers/review_bids_controller_spec.rb''': the unit tests for the review bids controller&lt;br /&gt;
*'''spec/models/review_bid_spec.rb''': the unit tests for the review bids model&lt;br /&gt;
*'''test/controllers/review_bids_controller_test.rb''': a more elaborate feature test for the review bids functionality&lt;br /&gt;
*'''test/fixtures/review_bids.yml''': fixtures that are utilized for the review_bids_controller_test&lt;br /&gt;
*'''test/models/review_bid_test.rb''': A more elaborate feature test of the review bid model.&lt;br /&gt;
&lt;br /&gt;
In addition to adding the previous files, the following files were also added to existing pages as modifications:&lt;br /&gt;
&lt;br /&gt;
*'''controllers/student_review_controller.rb''': the student review controller's &amp;quot;list&amp;quot; method now redirects to the review_bid_controller's &amp;quot;index&amp;quot; method if the assignment in question has a review_choosing_algorithm set to &amp;quot;Bidding&amp;quot; (the option an instructor sets when they wish to allow students to bid on reviews).&lt;br /&gt;
*'''student_task/view.html.erb''': Instead of simply linking directly to the student_review controller's &amp;quot;list&amp;quot; method, the view instead checks if the assignment this view pertains to has their review_choosing_algorithm set to Bidding. If it does, and the assignment allows students to choose the topic to review (meaning the algorithm to assign bids has not yet been run), they are redirected to the 'show' method of the review_bids_controller. Otherwise, they are redirected to the 'index' method (showing them the info on their currently available topics to review).&lt;br /&gt;
*'''config/webservices.yml''': added a new url for the website that is called to run the review bidding algorithm&lt;br /&gt;
*'''config/routes.rb''': routes added for review_bids.&lt;br /&gt;
*'''views/assignments/edit/_topics.html.erb''': Added a new option box which allows an instructor to choose to allow bidding to occur using the review bidding algorithm, rather than the default 'Simple Choose.' Once this option is selected, it also offers a button that, when clicked, runs the review bidding algorithm on all currently bid upon reviews.&lt;br /&gt;
&lt;br /&gt;
===Website Reimplementation===&lt;br /&gt;
In the previous implementation, the algorithm which handles the assigning of reviews was hosted on an external website. This was done for the sake of improved performance. Thus, to get the feature in working condition, we pulled the code necessary to run the algorithm and hosted it on our own website (linked at the end of this documentation). We also made a note in the pull request that the place where this website is referenced (in the &amp;quot;assign_reviews_algorithm&amp;quot; method of the review_bids_controller) should be replaced by a proper external web tool, as is done for similar web tools in other parts of expertiza.&lt;br /&gt;
&lt;br /&gt;
===Modifications to Methods===&lt;br /&gt;
Certain methods utilized in the original version of the webpages were changed or renamed in later versions, and so, needed to be modified. The primary example of this is the method that assignments use to determine what stage of assignment completion they are in. The previous year's implementation called this method as &amp;quot;assignment.find_current_stage(topic_id),&amp;quot; but this failed when trying to execute. After comparing how this page worked to how normal review pages work, we determined the new call to this method is &amp;quot;assignment.current_stage(topic_id).&amp;quot; All calls to this method were replaced in all files.&lt;br /&gt;
&lt;br /&gt;
Another change to methods was the removal of a method from the review_bids_controller named 'create'. This method primarily served as a redirect for an aspect of the feature that was unnecessary and so removed (see the following section), that being the button to show another review. With this feature removed, this method was no longer used, and so it was removed from the controller.&lt;br /&gt;
&lt;br /&gt;
===Errors Corrected===&lt;br /&gt;
A notable period of time was also spent on determining the purpose of a particular local area that caused issues when trying to view the bids, that being a variable named &amp;quot;@number_of_reviews_to_show&amp;quot;. This variable apparently kept track of how many reviews a student needed to be shown, so that they could request another. The issue was that this was created as a local variable within the review_bids_controller, and therefore would never work outside of a manual testing environment, as the variable would need to be different from every student and every assignment. After some investigation, we realized that all this variable did was limit the number of already-assigned reviews the student was able to see (as the review bidding algorithm already assigned all possible reviews). Thus, rather than try to recreate this functionality, we simply removed it.&lt;br /&gt;
&lt;br /&gt;
This means that, when the review bidding algorithm runs, a student is able to see all of the reviews assigned to them, up to the maximum number of reviews for the assignment, and therefore have no reason to ask for any more. It may be the case that this feature could be improved by adding a possibility for students to request any reviews not assigned to any other student, or that still have available slots, using the &amp;quot;normal&amp;quot; review assignment scheme. For the time being, we did not consider this part of the baseline necessary functionality, and so did not implement it.&lt;br /&gt;
&lt;br /&gt;
==Refinement Implementation==&lt;br /&gt;
&lt;br /&gt;
===DRY Principle and Code Duplication Refactoring===&lt;br /&gt;
Per comments and feedbacks on the previous implementation [https://github.com/expertiza/expertiza/pull/1822 E2085], there were 3 sections of the code that potentially were DRY violations. For each of those violations, we have had made appropriate and provided the justification on the results.&lt;br /&gt;
&lt;br /&gt;
====review_bids_controller.rb====&lt;br /&gt;
For the refactoring of review bids controller.eb, the original issue is the DRY principle violation on the internal logic of finding the phase of assignments.&lt;br /&gt;
The original implementation to be refactored and optimized are shown as follow.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # Finding the current phase that we are in&lt;br /&gt;
    due_dates = AssignmentDueDate.where(parent_id: @assignment.id)&lt;br /&gt;
    @very_last_due_date = AssignmentDueDate.where(parent_id: @assignment.id).order(&amp;quot;due_at DESC&amp;quot;).limit(1)&lt;br /&gt;
    next_due_date = @very_last_due_date[0]&lt;br /&gt;
    for due_date in due_dates&lt;br /&gt;
      if due_date.due_at &amp;gt; Time.now&lt;br /&gt;
        next_due_date = due_date if due_date.due_at &amp;lt; next_due_date.due_at&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    @review_phase = next_due_date.deadline_type_id&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Through some discovery process, we have found some related logics that is already implemented from the system which enable the refactoring and reuse of the method. Some code snippets are demonstrated as follow.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.current_due_date(due_dates)&lt;br /&gt;
    #Get the current due date from list of due dates&lt;br /&gt;
    due_dates.each do |due_date|&lt;br /&gt;
      if due_date.due_at &amp;gt; Time.now&lt;br /&gt;
        current_due_date = due_date&lt;br /&gt;
        return current_due_date&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    #in case current due date not found&lt;br /&gt;
    return nil &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.teammate_review_allowed(student)&lt;br /&gt;
    # time when teammate review is allowed&lt;br /&gt;
    due_date = current_due_date(student.assignment.due_dates)&lt;br /&gt;
    student.assignment.find_current_stage == 'Finished' ||&lt;br /&gt;
    due_date &amp;amp;&amp;amp;&lt;br /&gt;
    (due_date.teammate_review_allowed_id == 3 ||&lt;br /&gt;
    due_date.teammate_review_allowed_id == 2) # late(2) or yes(3)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As we can observed above, both methods of &amp;lt;code&amp;gt;current_due_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;teammate_review_allowed&amp;lt;/code&amp;gt; provides the capability of getting the &amp;lt;code&amp;gt;review_phase&amp;lt;/code&amp;gt; without the repetition. Additionally, we can see that those existing implementation still have some difference in implementation and purpose to be fully reusable by the logic that find current phase of a topic because the methods provided are helper methods for broader abstraction.&lt;br /&gt;
&lt;br /&gt;
Furthermore, the section that we attempted to refactoring out have a similar logic that is used to get the current stage as shown below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def find_current_stage(topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(self.id, topic_id)&lt;br /&gt;
    return 'Finished' if next_due_date.nil?&lt;br /&gt;
    next_due_date&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
However, it is worth pointing out that the method is not fully substitutable, particularly the internal functionality that finds the &amp;lt;code&amp;gt;@very_last_due_date&amp;lt;/code&amp;gt;. A similar logic does exist that is meant to use to acquire current due date and assist with finding current stage.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def current_stage_name(topic_id = nil)&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      return (topic_id.nil? ? 'Unknown' : current_stage(topic_id))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    due_date = find_current_stage(topic_id)&lt;br /&gt;
    unless due_date == 'Finished' || due_date.nil? || due_date.deadline_name.nil?&lt;br /&gt;
      return due_date.deadline_name&lt;br /&gt;
    end&lt;br /&gt;
    current_stage(topic_id)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
With all the findings, we have come to conclusion that the portion of the code to be dry is in similar, but required full restructure, form of existing methods. The internal logic flow itself is not fully matching the reusable methods consists across the controllers. Because of the clarity of limited reusability of existing methods, we have come to conclusion that the portions to be refactored are not duplication of any existing methods. Additionally, after a more detailed discovery, it has come to realization that the code portion of getting the current phase of the next due date was, in fact, meant to find the last due date. After further analysis of the purpose of the code, the portion has been deleted from &amp;lt;code&amp;gt;review_bids_controller.rb&amp;lt;/code&amp;gt; because there was no usage observed with the result of the execution.&lt;br /&gt;
&lt;br /&gt;
====review_bid.rb====&lt;br /&gt;
Per the previous iteration's feedback, the review_bid.rb model file presented some DRY violations. These violations are highlighted in the method below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # method to get reviewers own project topic&lt;br /&gt;
    # return self_topic&lt;br /&gt;
    def self.reviewer_self_topic(reviewer_id)&lt;br /&gt;
      participant = AssignmentParticipant.find_by(id: reviewer_id)&lt;br /&gt;
      team_id = participant.team.try(:id)&lt;br /&gt;
      self_topic = SignedUpTeam.where(team_id: team_id).pluck(:topic_id).first&lt;br /&gt;
&lt;br /&gt;
      return self_topic&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Refactoring Views (_all_actions.html.erb and _topic_names.html.erb)====&lt;br /&gt;
The last element of the prior implementation that caused DRY violations had to do with its implementation of views. Two primary views are necessary for the review bids functionality: one which shows a table where students can bid on which topic they wish to review (rendered by a file called 'show.html.erb'), and a list of assigned reviews which a student must select from (rendered by a file called 'others_work.html.erb'). &lt;br /&gt;
&lt;br /&gt;
In order to render the elements in 'show.html.erb' in particular, a number of partials must be utilized:&lt;br /&gt;
*a partial for the table's header (_table_header.html.erb)&lt;br /&gt;
*a partial for rendering each of the table's rows, describing a topic to bid on (_table_line.html.erb)&lt;br /&gt;
*a partial to contain information related to what actions are available for a student to do for a review, like edit or view (_all_actions.html.erb)&lt;br /&gt;
*a partial for finding and rendering the name of each topic one must review (_topic_names.html.erb)&lt;br /&gt;
&lt;br /&gt;
Both of these views and all four of these partials were contained within the &amp;quot;review_bids&amp;quot; directory within the views directory. The DRY violation incurred by these views has to do with these partials: in particular, '_topic_names.html.erb' and '_all_actions.html.erb' are near identical code copies to those within the sign_up_sheet views, used for rendering and displaying information for topic bidding and normal reviews.&lt;br /&gt;
&lt;br /&gt;
In order to DRY out this portion of the code, we decided that having a separate set of views for the results related to review bids were unnecessary. Within expertiza's structure, most of the views related to students choosing which topics or reviews to work on are all contained within the sign_up_sheet views. The review_vids views were copying the partials within the sign_up_sheet views because they were using the same fundamental components. Thus, we thought the best solution would be to move the two primary views for review_bids ('show.html.erb' and 'others_work.html.erb') into the sign_up_sheet views, and leave behind all redundant partials. In doing so, the redundancy of '_all_actions.html.erb' and '_topic_names.html.erb' were eliminated.&lt;br /&gt;
&lt;br /&gt;
It could be argued that this implementation could be further DRY-ed by leaving behind the other two partials, '_table_header.html.erb' and '_table_line.html.erb', as they are structurally similar to those used for topic bidding. However, this is not actually permissible, as the header and lines for topics when bidding on them for reviews are significantly different than when bidding on them for assignments. More information needs to be available when bidding on topics for an assignment, such as the number of slots and number on the waitlist, but such an idea is not applicable for bids on reviews. While it would be possible to have a single file which produces one view or another depending upon if it's bidding for topics or reviews, we believed this violated the Expert Pattern, by attempting to create a single view for two distinct purposes. Instead, we thought it better to simply have two separate partials, each which precisely gave the desired functionality. Thus, the other two partials were brought over, being renamed '_review_bids_table_header.html.erb' and '_review_bids_table_line.html.erb'.&lt;br /&gt;
&lt;br /&gt;
==Tests==&lt;br /&gt;
&lt;br /&gt;
Throughout the refactoring and merging of [https://github.com/expertiza/expertiza/pull/1822 E2085] to [https://github.com/expertiza/expertiza/pull/2150 E2151], there were some updates that has been made to the test suits to maintain corrosponding testing automation.&lt;br /&gt;
&lt;br /&gt;
===Video Demonstration===&lt;br /&gt;
[https://www.youtube.com/watch?v=wxXALQNWFcc Click this link] to see a video demonstrating the functionality of the review bidding feature.&lt;br /&gt;
&lt;br /&gt;
===RSpec Testing===&lt;br /&gt;
One of the primary design goals when doing this refactoring was to ensure that all test cases still passed after all changes were made.&lt;br /&gt;
&lt;br /&gt;
There was a single change that needed to be made to the RSpec files for the review bidding algorithm, which was the removal of a test relying on the 'create' method of the review_bids_controller. As previously mentioned, this function was removed because it had become obsolete. Thus, the test case for this function (which simply checked if it redirected to the right page) was no longer necessary, and thus was deleted.&lt;br /&gt;
&lt;br /&gt;
Otherwise, the test cases for both the review_bids_controller and the review_bids model were manually run and found to have no errors, as shown below.&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_test_results.png|800px]]&lt;br /&gt;
&lt;br /&gt;
For details on what these specific tests were, please refer to the previous work referenced before.&lt;br /&gt;
&lt;br /&gt;
==Conclusions and Future Work==&lt;br /&gt;
While the current state of the review bidding code is operational, and is certainly more DRY and stable than the previous incarnation of this work, there are still several issues with the current state of this feature that make it difficult to recommend an immediate merge into expertiza.&lt;br /&gt;
&lt;br /&gt;
===Enhancement of Algorithm Service Stability===&lt;br /&gt;
&lt;br /&gt;
Across the process of refining the refactored front end page view along with more robust edge cases testing towards the algorithm service, we have discovered an underlying issue that could impact the availability of the review bidding algorithm service. Through cause isolation, we have observed a high correlation to flask application crash with the edge case scenario input where the algorithm service is trying to match a student who was not signed up with any topic with other students.&lt;br /&gt;
&lt;br /&gt;
Because the scope of our project was focused on refactoring, we did not have the time or prior warning to need to address these edge cases. However, we will provide the error log for the reference of any future teams who may work on the stability improvement of the algorithm service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;POST /match_topics HTTP/1.1&amp;quot; 500 -&lt;br /&gt;
{'tid': [5133, 5134, 5135, None], 'users': {'45514': {'otid': 5135, 'tid': [5133, 5134], 'time': ['2021-11-30T17:57:20.000-05:00', '2021-11-30T17:57:24.000-05:00'], 'priority': [2, 1]}, '45513': {'otid': 5134, 'tid': [5133, 5135], 'time': ['2021-11-30T17:57:41.000-05:00', '2021-11-30T17:57:43.000-05:00'], 'priority': [2, 1]}, '45512': {'otid': 5133, 'tid': [5134, 5135], 'time': ['2021-11-30T17:57:58.000-05:00', '2021-11-30T17:58:00.000-05:00'], 'priority': [2, 1]}, '45515': {'otid': None, 'tid': [], 'time': [0], 'priority': [3, 1, 4, 2]}}, 'max_accepted_proposals': 3}&lt;br /&gt;
[2021-11-28 18:10:40,576] ERROR in app: Exception on /match_topics [POST]&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 2447, in wsgi_app&lt;br /&gt;
    response = self.full_dispatch_request()&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1952, in full_dispatch_request&lt;br /&gt;
    rv = self.handle_user_exception(e)&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1821, in handle_user_exception&lt;br /&gt;
    reraise(exc_type, exc_value, tb)&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/_compat.py&amp;quot;, line 39, in reraise&lt;br /&gt;
    raise value&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1950, in full_dispatch_request&lt;br /&gt;
    rv = self.dispatch_request()&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1936, in dispatch_request&lt;br /&gt;
    return self.view_functions[rule.endpoint](**req.view_args)&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/app.py&amp;quot;, line 19, in topic_matching&lt;br /&gt;
    return jsonify(assigned_topics_model.get_student_topic_matches())&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/topics_matcher.py&amp;quot;, line 57, in get_student_topic_matches&lt;br /&gt;
    student.accept_proposal()&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/student.py&amp;quot;, line 24, in accept_proposal&lt;br /&gt;
    self.proposals.sort(key=lambda proposal: self.choices.index(proposal))&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/student.py&amp;quot;, line 24, in &amp;lt;lambda&amp;gt;&lt;br /&gt;
    self.proposals.sort(key=lambda proposal: self.choices.index(proposal))&lt;br /&gt;
ValueError: None is not in list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As we can see from the additional information provided above, the error is due to an unhandled edge case of attempting to access missing value. Our further observation also concluded that such missing value is due to the fact that one or more to-be-matched students did not have any topic signed up at the time of algorithm execution. To address the issue, a general enhancement can be implemented on the algorithm service side with Flask to increase the crash recovery stability. Further refinement of interaction flow with user in the front end can also reduce the possibility of algorithm service error.&lt;br /&gt;
&lt;br /&gt;
Additional to the unhandled cases from the algorithm service, we also noticed an inconsistency of the system due to the performance limitation of the Heroku deployment.&lt;br /&gt;
&lt;br /&gt;
[[File:Out_of_scope_External-Issue_E2151.gif|frameless|x1000px]]&lt;br /&gt;
&lt;br /&gt;
As we can see from the above recorded screen capture animation, with the exact same input, the output and algorithm service result are unstable. Because of the performance limitation of the Heroku, sometime the Flask app that deployed were overloaded. Furthermore, we have also attempted to deploy on VCL, however, we notice the limitation of VCL deployment that will become offline once the VCL reservation expired. After all, because of the focus of our tasks is on the DRY principal optimization, the external algorithm service can be improved in the future. To access and deploy the algorithm on local environment or another environment, setup guide and resource are available on [https://github.com/uahamedncsu/IntelligentAssignment IntelligentAssignment] repository.&lt;br /&gt;
&lt;br /&gt;
===Lack of Comprehensive Testing===&lt;br /&gt;
&lt;br /&gt;
A notable contradiction that was noticed when working with this project was that the previously-mentioned failed edge cases existed, yet all tests for this feature passed. This is illustrative of the fact that this feature requires better and more exhaustive testing.&lt;br /&gt;
&lt;br /&gt;
With the scope limitation of our tasks that focusing on the DRY principal enhancement of the Expertiza internally, the external algorithm service module was not within our focus. However, with our experience of deployment with the algorithm service, we can offer some suggestions for the future team who will address those edge cases of the algorithm service.&lt;br /&gt;
&lt;br /&gt;
When dealing with an issue with so many factors as how students bid on reviews, an extensive suite of edge cases should be considered. Any future project group working on this function should consider the following edge cases to cover:&lt;br /&gt;
* Does a student who does not bid on any reviews still get reviews?&lt;br /&gt;
* Does a student who did not submit anything for their assignment still have a review to bid on?&lt;br /&gt;
* What if there are less assignments to have reviews for than the minimum number required for all students to have the minimum number of reviews?&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
While we believe the current state of this feature is greatly improved, with many of its DRY violations removed and several noteworthy bugs corrected, we believe the feature of allowing students to bid on what to review still needs further development before it is deployed. While the basic functionality is working under ideal situations, the issues mentioned above should be addressed before this feature is put in the hands of actual instructors, as if this feature fails, it could ruin the entire reviewing process for an assignment.&lt;br /&gt;
&lt;br /&gt;
Still, we think there is notable promise to this feature, and it would be a very engaging and interesting feature if deployed successfully, so we believe develop on it should continue until it is ready for deployment.&lt;br /&gt;
&lt;br /&gt;
==Github and Related Link==&lt;br /&gt;
Github repository corresponding to this task is publicly available at [https://github.com/WeiRui-Wang/expertiza E2151 GitHub].&lt;br /&gt;
&lt;br /&gt;
Github pull request and file changes can be viewed at [https://github.com/expertiza/expertiza/pull/2150/files E2151 Pull Request].&lt;br /&gt;
&lt;br /&gt;
Github of source code of externally hosted bidding algorithm service deployment manual and files can be access at [https://github.com/uahamedncsu/IntelligentAssignment IntelligentAssignment].&lt;br /&gt;
&lt;br /&gt;
==Contributors==&lt;br /&gt;
This feature was created as part of Dr. Edward Gehringer's &amp;quot;CSC/ECE 517: Object-Oriented Design and Development&amp;quot; class, Fall 2021. The contributors were: Geoff Garrido, Ayush Luthra, and WeiRui Wang. Our project mentor was Luis Delossantos (lgdeloss@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=142161</id>
		<title>CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=142161"/>
		<updated>2021-11-30T01:20:36Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: /* review_bid.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic Overview==&lt;br /&gt;
===Statement of Problem===&lt;br /&gt;
Reviewing is an important stage of learning and improving, both as a reviewer and a reviewee, and so allowing reviewers more freedom and choice in what they review would result in better reviews and more engaged reviewers. However, currently the only way to choose a topic to review is a first-come-first-served basis, penalizing students who do not sign up quickly by not allowing them to review the topics they would be most interesting in engaging with.&lt;br /&gt;
&lt;br /&gt;
A better alternative would be to implement a bidding system, similar to that used for topics, which would allow students to establish preferences for which topics they would most like to review. A good bidding algorithm implementing with this idea would ensure that all students (who care enough to bid) receive a topic to review that they actively want.&lt;br /&gt;
&lt;br /&gt;
A prior project group created a prototype for this function, allowing students to bid on what topics they wanted to review. While the functionality was as desired, the feature was not able to be merged due to having too many DRY violations. Thus, the goal of this topic was to bring this prior implementation into the current version of the expertiza beta branch, and remove these DRY violations, so that it may be merged.&lt;br /&gt;
&lt;br /&gt;
As development continued, it became clear this prototype also had several bugs and issues that made it unable to work under several conditions. Thus, a secondary goal was to fix any issues which existed such that the feature would generally work with the functionality the prior implementation demonstrated.&lt;br /&gt;
&lt;br /&gt;
===Prior Work===&lt;br /&gt;
The prior work which is the basis for this topic is linked here [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review is linked here]. This work was done in Fall of 2020, and as previously mentioned, achieved much of the desired functionality for this task. This prior work will be referenced several times within this documentation, as it has a more comprehensive explanation of the underlying design principles behind the views, controller, model, algorithm, and RSpec tests implemented. These details will only be briefly summarized here. &lt;br /&gt;
&lt;br /&gt;
As previously noted, this prior implementation was rejected due to DRY violations, and so correcting these violations--and explaining how those corrections were done--will be the major focus of this project documentation.&lt;br /&gt;
&lt;br /&gt;
==Explanation of Feature==&lt;br /&gt;
&lt;br /&gt;
===Existing Bidding Functionality for Topics===&lt;br /&gt;
Currently in expertiza, students may bid on which topics they would like to work on. An image showcasing this functionality is given below:&lt;br /&gt;
&lt;br /&gt;
[[File:expected_review_UI.PNG]]&lt;br /&gt;
&lt;br /&gt;
Students may choose a number of topics to bid on, in order of priority, and once the deadline is reached, all students are given a topic.&lt;br /&gt;
&lt;br /&gt;
Behind the scenes, this works by utilizing a modified version of the Gale-Shapely Algorithm. This algorithm seeks to find a 'stable' matching of each student to each topic, such that in the end, all students have a topic they wanted (at least to some degree), and that the preferences of students is respected as well as possible. To help break situations where there are ties in preferences, each topic assigns a Priority to each student. This Priority is determined by A. whether the student is part of a group bidding for this topic (groups getting higher priority), and B. the time at which the bid for the topic was made (earlier bidders are given Priority). Once this has been determined and the deadline for bidding has ended, the following steps occur:&lt;br /&gt;
# Each student is matched with each topic they most prefer.&lt;br /&gt;
# If the number of students assigned to a topic is above the maximum allowed for that topic, the students with the highest Priority are assigned the topic&lt;br /&gt;
# All maximally filled topics are removed from the pool of available topics&lt;br /&gt;
# All unmatched students begin this cycle again, now choosing the most preferred topic remaining&lt;br /&gt;
# Repeat until all students are assigned a topic&lt;br /&gt;
# If any matches are 'unstable' (two students would have their preferences better met if they were swapped), perform any swaps until matches are as stable as possible.&lt;br /&gt;
&lt;br /&gt;
This algorithm has a time complexity of O(n^2). For more details on this algorithm and its implementation, refer to the previous year's work, where this algorithm was implemented.&lt;br /&gt;
&lt;br /&gt;
===Desired Functionality for Reviews===&lt;br /&gt;
&lt;br /&gt;
The desired feature for reviews should have an almost identical structure to this, with reviews instead of topics. Students should be shown a list of the topics that were worked on, and may bid on which of those topics they would like to review the most. The Priority system could be handled in the same way, with the only caveat being that a student should not be able to review their own work.&lt;br /&gt;
&lt;br /&gt;
In terms of what this feature looks like, it can be enabled as an option when editing/creating a new assignment, under the &amp;quot;Topics&amp;quot; section, using interface drop down show below.&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_interface.png|center|800px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once this option is enabled, during the review phase of an assignment, students will be able to access a new view listing all the topics of all the submitted assignments (except for their own). They will then be able to bid on as many topics as they like, assigning them a preference, in a manner similar to the interface for topic bidding. The table that allows for this drag-and-drop priorities is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_options.png|center|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Whenever the instructor decides they would like to close the window for review bidding, they may return to the options for the given assignment and navigate to &amp;quot;Topics&amp;quot;, where they will see a button marked &amp;quot;Run Review Algorithm&amp;quot;. This will make a call to the external webservice to determine which students are assigned what reviews, and will then assign those reviews to all students. Once this button is pressed, it locks out the ability for students to perform any more bidding, and cannot be pressed again. The button allowing this option is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_run_algorithm.png|center|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After this point, students may navigate to the &amp;quot;Others Work&amp;quot; option under their assignment and see all of their assigned reviews. They will see up to the maximum number of allowed reviews, but will be informed of how many they are required to do (for example, a student may see 4 reviews, but will be told they are only required to complete 2).&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
The following Use Case Diagram demonstrates the primary functionality explained in the previous section for different types of users.&lt;br /&gt;
&lt;br /&gt;
[[File:Use_Case_Diagram_Rev1_E2151.jpg|center]]&lt;br /&gt;
&lt;br /&gt;
==Plan and List of Work Done==&lt;br /&gt;
&lt;br /&gt;
===General Design Goals===&lt;br /&gt;
&lt;br /&gt;
* Move all prior work for this topic into a new version of the expertiza beta branch, without loss in functionality.&lt;br /&gt;
* Ensure all prior/expected functionality is working correctly, and if not, make any repairs or changes necessary.&lt;br /&gt;
* DRY out prior implementation's controller and model methods which have functionality that already exists within the expertiza system.&lt;br /&gt;
* Remove repetitive views and partials that exist by merging views for review bids into the set of views for sign up sheets, from which it uses partials.&lt;br /&gt;
* Ensure all present test cases still work properly after making the above changes.&lt;br /&gt;
&lt;br /&gt;
===Specific Tasks Completed===&lt;br /&gt;
&lt;br /&gt;
* Transferred over all code files relevant to the review bidding feature&lt;br /&gt;
* Re-deployed the external website which handles the review bidding algorithm&lt;br /&gt;
* Added that website's url to the webservices url's within expertiza&lt;br /&gt;
* Enhanced the stability of the webservice for the bidding algorithm by testing with edge cases and optimize the endpoint by restoring the original access endpoint reference* Analyzed the necessity of the phase finding related logic code section&lt;br /&gt;
* Optimized phase finding related logic by removing unused code segment&lt;br /&gt;
* Removed an instance variable within the ''review_bids_controller'' which would have made any practical deployment fail, removing the unnecessary functionality it was created for&lt;br /&gt;
* Updated method calls to ''assignment.find_current_stage'' to their new form ''assignment.current_stage''&lt;br /&gt;
* Removed the review_bid model method ''self.reviewer_self_topic'' and replaced its usage with the already-existing ''SignedUpTeam.topic_id'' method&lt;br /&gt;
* Removed DRY-violating code used to calculate the current assignment phase which was never utilized by the controller or views&lt;br /&gt;
* Moved several view files from the ''review_bids'' view directory into the ''sign_up_sheet'' view directory. Partials which were duplicates in the two directories (''_all_actions.html.erb'' and ''_topic_names.html.erb'' were no longer necessary and deleted&lt;br /&gt;
* Refactored the naming of the variable that represents the id of the reviewer object from 'reviewer' to 'reviewer_id' for clarity&lt;br /&gt;
* Removed the unnecessary 'create' function within the review_bids_controller&lt;br /&gt;
* Removed the sparse testing files under the 'test' directory in keeping with typical expertiza structure&lt;br /&gt;
* Removed a test case from the unit tests which relied upon the removed 'create' method of the review_bids_controller&lt;br /&gt;
&lt;br /&gt;
==Initial Implementation==&lt;br /&gt;
&lt;br /&gt;
A considerable amount of time and effort was necessary to review, understand, and re-implement the previous implementation of the Review Bidding feature. While the feature was only created a year ago, several underlying functions and methods have since been refactored, and so needed to be changed in the implementation. Additionally, certain parts of how the implementation was designed did not seem to be properly implemented, and so had to be revised.&lt;br /&gt;
&lt;br /&gt;
===Code Transfer===&lt;br /&gt;
First, all files that were added in the original pull request were copied and moved to the new version of the expertiza beta branch. This includes the following files:&lt;br /&gt;
&lt;br /&gt;
*'''controllers/review_bids_controller.rb''': the primary controller that handles calls to review bids functionality from views, managing them itself or directing them to the appropriate model&lt;br /&gt;
*'''helpers/review_bids_helper.rb''': contains helper methods for rendering the rows of topics available to choose a review for&lt;br /&gt;
*'''models/review_bid.rb''': contains the methods that each individual review bid knows and manages, including assigning a review to a student, getting info on the topic it applies to, etc.&lt;br /&gt;
*'''views/review_bids/_all_actions.html.erb''': a view partial used to render the actions available to a student on the review bidding view. Nearly identical to the _all_actions file for topic bidding.&lt;br /&gt;
*'''views/review_bids/_table_header.html.erb''': a view partial used to render the head of the table for review bids. Though structurally similar to that of topics reviews, contains significantly less information, as less needs to be known by a student for particular topics to review.&lt;br /&gt;
*'''views/review_bids/_table_line.html.erb''': a view partial used to render individual rows of the review bids table. Like the table header, is structurally similar to that of topic bidding, but functions differently.&lt;br /&gt;
*'''views/review_bids/show.html.erb''': the view which displays all the available topics to bid on reviewing. Uses the aforementioned partials to render this bidding table.&lt;br /&gt;
*'''views/review_bids/others_work.html.erb''': displays the available review work which has the user has bid for.&lt;br /&gt;
*'''db/migrate/20201107203204_create_review_bids.rb''': the migration which creates the review bid objects within the expertiza database.&lt;br /&gt;
*'''spec/controllers/review_bids_controller_spec.rb''': the unit tests for the review bids controller&lt;br /&gt;
*'''spec/models/review_bid_spec.rb''': the unit tests for the review bids model&lt;br /&gt;
*'''test/controllers/review_bids_controller_test.rb''': a more elaborate feature test for the review bids functionality&lt;br /&gt;
*'''test/fixtures/review_bids.yml''': fixtures that are utilized for the review_bids_controller_test&lt;br /&gt;
*'''test/models/review_bid_test.rb''': A more elaborate feature test of the review bid model.&lt;br /&gt;
&lt;br /&gt;
In addition to adding the previous files, the following files were also added to existing pages as modifications:&lt;br /&gt;
&lt;br /&gt;
*'''controllers/student_review_controller.rb''': the student review controller's &amp;quot;list&amp;quot; method now redirects to the review_bid_controller's &amp;quot;index&amp;quot; method if the assignment in question has a review_choosing_algorithm set to &amp;quot;Bidding&amp;quot; (the option an instructor sets when they wish to allow students to bid on reviews).&lt;br /&gt;
*'''student_task/view.html.erb''': Instead of simply linking directly to the student_review controller's &amp;quot;list&amp;quot; method, the view instead checks if the assignment this view pertains to has their review_choosing_algorithm set to Bidding. If it does, and the assignment allows students to choose the topic to review (meaning the algorithm to assign bids has not yet been run), they are redirected to the 'show' method of the review_bids_controller. Otherwise, they are redirected to the 'index' method (showing them the info on their currently available topics to review).&lt;br /&gt;
*'''config/webservices.yml''': added a new url for the website that is called to run the review bidding algorithm&lt;br /&gt;
*'''config/routes.rb''': routes added for review_bids.&lt;br /&gt;
*'''views/assignments/edit/_topics.html.erb''': Added a new option box which allows an instructor to choose to allow bidding to occur using the review bidding algorithm, rather than the default 'Simple Choose.' Once this option is selected, it also offers a button that, when clicked, runs the review bidding algorithm on all currently bid upon reviews.&lt;br /&gt;
&lt;br /&gt;
===Website Reimplementation===&lt;br /&gt;
In the previous implementation, the algorithm which handles the assigning of reviews was hosted on an external website. This was done for the sake of improved performance. Thus, to get the feature in working condition, we pulled the code necessary to run the algorithm and hosted it on our own website (linked at the end of this documentation). We also made a note in the pull request that the place where this website is referenced (in the &amp;quot;assign_reviews_algorithm&amp;quot; method of the review_bids_controller) should be replaced by a proper external web tool, as is done for similar web tools in other parts of expertiza.&lt;br /&gt;
&lt;br /&gt;
===Modifications to Methods===&lt;br /&gt;
Certain methods utilized in the original version of the webpages were changed or renamed in later versions, and so, needed to be modified. The primary example of this is the method that assignments use to determine what stage of assignment completion they are in. The previous year's implementation called this method as &amp;quot;assignment.find_current_stage(topic_id),&amp;quot; but this failed when trying to execute. After comparing how this page worked to how normal review pages work, we determined the new call to this method is &amp;quot;assignment.current_stage(topic_id).&amp;quot; All calls to this method were replaced in all files.&lt;br /&gt;
&lt;br /&gt;
Another change to methods was the removal of a method from the review_bids_controller named 'create'. This method primarily served as a redirect for an aspect of the feature that was unnecessary and so removed (see the following section), that being the button to show another review. With this feature removed, this method was no longer used, and so it was removed from the controller.&lt;br /&gt;
&lt;br /&gt;
===Errors Corrected===&lt;br /&gt;
A notable period of time was also spent on determining the purpose of a particular local area that caused issues when trying to view the bids, that being a variable named &amp;quot;@number_of_reviews_to_show&amp;quot;. This variable apparently kept track of how many reviews a student needed to be shown, so that they could request another. The issue was that this was created as a local variable within the review_bids_controller, and therefore would never work outside of a manual testing environment, as the variable would need to be different from every student and every assignment. After some investigation, we realized that all this variable did was limit the number of already-assigned reviews the student was able to see (as the review bidding algorithm already assigned all possible reviews). Thus, rather than try to recreate this functionality, we simply removed it.&lt;br /&gt;
&lt;br /&gt;
This means that, when the review bidding algorithm runs, a student is able to see all of the reviews assigned to them, up to the maximum number of reviews for the assignment, and therefore have no reason to ask for any more. It may be the case that this feature could be improved by adding a possibility for students to request any reviews not assigned to any other student, or that still have available slots, using the &amp;quot;normal&amp;quot; review assignment scheme. For the time being, we did not consider this part of the baseline necessary functionality, and so did not implement it.&lt;br /&gt;
&lt;br /&gt;
==Refinement Implementation==&lt;br /&gt;
&lt;br /&gt;
===DRY Principle and Code Duplication Refactoring===&lt;br /&gt;
Per comments and feedbacks on the previous implementation [https://github.com/expertiza/expertiza/pull/1822 E2085], there were 3 sections of the code that potentially were DRY violations. For each of those violations, we have had made appropriate and provided the justification on the results.&lt;br /&gt;
&lt;br /&gt;
====review_bids_controller.rb====&lt;br /&gt;
For the refactoring of review bids controller.eb, the original issue is the DRY principle violation on the internal logic of finding the phase of assignments.&lt;br /&gt;
The original implementation to be refactored and optimized are shown as follow.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # Finding the current phase that we are in&lt;br /&gt;
    due_dates = AssignmentDueDate.where(parent_id: @assignment.id)&lt;br /&gt;
    @very_last_due_date = AssignmentDueDate.where(parent_id: @assignment.id).order(&amp;quot;due_at DESC&amp;quot;).limit(1)&lt;br /&gt;
    next_due_date = @very_last_due_date[0]&lt;br /&gt;
    for due_date in due_dates&lt;br /&gt;
      if due_date.due_at &amp;gt; Time.now&lt;br /&gt;
        next_due_date = due_date if due_date.due_at &amp;lt; next_due_date.due_at&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    @review_phase = next_due_date.deadline_type_id&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Through some discovery process, we have found some related logics that is already implemented from the system which enable the refactoring and reuse of the method. Some code snippets are demonstrated as follow.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.current_due_date(due_dates)&lt;br /&gt;
    #Get the current due date from list of due dates&lt;br /&gt;
    due_dates.each do |due_date|&lt;br /&gt;
      if due_date.due_at &amp;gt; Time.now&lt;br /&gt;
        current_due_date = due_date&lt;br /&gt;
        return current_due_date&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    #in case current due date not found&lt;br /&gt;
    return nil &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.teammate_review_allowed(student)&lt;br /&gt;
    # time when teammate review is allowed&lt;br /&gt;
    due_date = current_due_date(student.assignment.due_dates)&lt;br /&gt;
    student.assignment.find_current_stage == 'Finished' ||&lt;br /&gt;
    due_date &amp;amp;&amp;amp;&lt;br /&gt;
    (due_date.teammate_review_allowed_id == 3 ||&lt;br /&gt;
    due_date.teammate_review_allowed_id == 2) # late(2) or yes(3)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As we can observed above, both methods of &amp;lt;code&amp;gt;current_due_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;teammate_review_allowed&amp;lt;/code&amp;gt; provides the capability of getting the &amp;lt;code&amp;gt;review_phase&amp;lt;/code&amp;gt; without the repetition. Additionally, we can see that those existing implementation still have some difference in implementation and purpose to be fully reusable by the logic that find current phase of a topic because the methods provided are helper methods for broader abstraction.&lt;br /&gt;
&lt;br /&gt;
Furthermore, the section that we attempted to refactoring out have a similar logic that is used to get the current stage as shown below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def find_current_stage(topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(self.id, topic_id)&lt;br /&gt;
    return 'Finished' if next_due_date.nil?&lt;br /&gt;
    next_due_date&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
However, it is worth pointing out that the method is not fully substitutable, particularly the internal functionality that finds the &amp;lt;code&amp;gt;@very_last_due_date&amp;lt;/code&amp;gt;. A similar logic does exist that is meant to use to acquire current due date and assist with finding current stage.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def current_stage_name(topic_id = nil)&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      return (topic_id.nil? ? 'Unknown' : current_stage(topic_id))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    due_date = find_current_stage(topic_id)&lt;br /&gt;
    unless due_date == 'Finished' || due_date.nil? || due_date.deadline_name.nil?&lt;br /&gt;
      return due_date.deadline_name&lt;br /&gt;
    end&lt;br /&gt;
    current_stage(topic_id)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
With all the findings, we have come to conclusion that the portion of the code to be dry is in similar, but required full restructure, form of existing methods. The internal logic flow itself is not fully matching the reusable methods consists across the controllers. Because of the clarity of limited reusability of existing methods, we have come to conclusion that the portions to be refactored are not duplication of any existing methods. Additionally, after a more detailed discovery, it has come to realization that the code portion of getting the current phase of the next due date was, in fact, meant to find the last due date. After further analysis of the purpose of the code, the portion has been deleted from &amp;lt;code&amp;gt;review_bids_controller.rb&amp;lt;/code&amp;gt; because there was no usage observed with the result of the execution.&lt;br /&gt;
&lt;br /&gt;
====review_bid.rb====&lt;br /&gt;
Per the previous iteration's feedback, the review_bid.rb model file presented some DRY violations. These violations are highlighted in the method below:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Review_bid_original.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Refactoring Views (_all_actions.html.erb and _topic_names.html.erb)====&lt;br /&gt;
The last element of the prior implementation that caused DRY violations had to do with its implementation of views. Two primary views are necessary for the review bids functionality: one which shows a table where students can bid on which topic they wish to review (rendered by a file called 'show.html.erb'), and a list of assigned reviews which a student must select from (rendered by a file called 'others_work.html.erb'). &lt;br /&gt;
&lt;br /&gt;
In order to render the elements in 'show.html.erb' in particular, a number of partials must be utilized:&lt;br /&gt;
*a partial for the table's header (_table_header.html.erb)&lt;br /&gt;
*a partial for rendering each of the table's rows, describing a topic to bid on (_table_line.html.erb)&lt;br /&gt;
*a partial to contain information related to what actions are available for a student to do for a review, like edit or view (_all_actions.html.erb)&lt;br /&gt;
*a partial for finding and rendering the name of each topic one must review (_topic_names.html.erb)&lt;br /&gt;
&lt;br /&gt;
Both of these views and all four of these partials were contained within the &amp;quot;review_bids&amp;quot; directory within the views directory. The DRY violation incurred by these views has to do with these partials: in particular, '_topic_names.html.erb' and '_all_actions.html.erb' are near identical code copies to those within the sign_up_sheet views, used for rendering and displaying information for topic bidding and normal reviews.&lt;br /&gt;
&lt;br /&gt;
In order to DRY out this portion of the code, we decided that having a separate set of views for the results related to review bids were unnecessary. Within expertiza's structure, most of the views related to students choosing which topics or reviews to work on are all contained within the sign_up_sheet views. The review_vids views were copying the partials within the sign_up_sheet views because they were using the same fundamental components. Thus, we thought the best solution would be to move the two primary views for review_bids ('show.html.erb' and 'others_work.html.erb') into the sign_up_sheet views, and leave behind all redundant partials. In doing so, the redundancy of '_all_actions.html.erb' and '_topic_names.html.erb' were eliminated.&lt;br /&gt;
&lt;br /&gt;
It could be argued that this implementation could be further DRY-ed by leaving behind the other two partials, '_table_header.html.erb' and '_table_line.html.erb', as they are structurally similar to those used for topic bidding. However, this is not actually permissible, as the header and lines for topics when bidding on them for reviews are significantly different than when bidding on them for assignments. More information needs to be available when bidding on topics for an assignment, such as the number of slots and number on the waitlist, but such an idea is not applicable for bids on reviews. While it would be possible to have a single file which produces one view or another depending upon if it's bidding for topics or reviews, we believed this violated the Expert Pattern, by attempting to create a single view for two distinct purposes. Instead, we thought it better to simply have two separate partials, each which precisely gave the desired functionality. Thus, the other two partials were brought over, being renamed '_review_bids_table_header.html.erb' and '_review_bids_table_line.html.erb'.&lt;br /&gt;
&lt;br /&gt;
==Tests==&lt;br /&gt;
&lt;br /&gt;
Throughout the refactoring and merging of [https://github.com/expertiza/expertiza/pull/1822 E2085] to [https://github.com/expertiza/expertiza/pull/2150 E2151], there were some updates that has been made to the test suits to maintain corrosponding testing automation.&lt;br /&gt;
&lt;br /&gt;
===Video Demonstration===&lt;br /&gt;
[https://www.youtube.com/watch?v=wxXALQNWFcc Click this link] to see a video demonstrating the functionality of the review bidding feature.&lt;br /&gt;
&lt;br /&gt;
===RSpec Testing===&lt;br /&gt;
One of the primary design goals when doing this refactoring was to ensure that all test cases still passed after all changes were made.&lt;br /&gt;
&lt;br /&gt;
There was a single change that needed to be made to the RSpec files for the review bidding algorithm, which was the removal of a test relying on the 'create' method of the review_bids_controller. As previously mentioned, this function was removed because it had become obsolete. Thus, the test case for this function (which simply checked if it redirected to the right page) was no longer necessary, and thus was deleted.&lt;br /&gt;
&lt;br /&gt;
Otherwise, the test cases for both the review_bids_controller and the review_bids model were manually run and found to have no errors, as shown below.&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_test_results.png|800px]]&lt;br /&gt;
&lt;br /&gt;
For details on what these specific tests were, please refer to the previous work referenced before.&lt;br /&gt;
&lt;br /&gt;
==Conclusions and Future Work==&lt;br /&gt;
While the current state of the review bidding code is operational, and is certainly more DRY and stable than the previous incarnation of this work, there are still several issues with the current state of this feature that make it difficult to recommend an immediate merge into expertiza.&lt;br /&gt;
&lt;br /&gt;
===Enhancement of Algorithm Service Stability===&lt;br /&gt;
&lt;br /&gt;
Across the process of refining the refactored front end page view along with more robust edge cases testing towards the algorithm service, we have discovered an underlying issue that could impact the availability of the review bidding algorithm service. Through cause isolation, we have observed a high correlation to flask application crash with the edge case scenario input where the algorithm service is trying to match a student who was not signed up with any topic with other students.&lt;br /&gt;
&lt;br /&gt;
Because the scope of our project was focused on refactoring, we did not have the time or prior warning to need to address these edge cases. However, we will provide the error log for the reference of any future teams who may work on the stability improvement of the algorithm service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;POST /match_topics HTTP/1.1&amp;quot; 500 -&lt;br /&gt;
{'tid': [5133, 5134, 5135, None], 'users': {'45514': {'otid': 5135, 'tid': [5133, 5134], 'time': ['2021-11-30T17:57:20.000-05:00', '2021-11-30T17:57:24.000-05:00'], 'priority': [2, 1]}, '45513': {'otid': 5134, 'tid': [5133, 5135], 'time': ['2021-11-30T17:57:41.000-05:00', '2021-11-30T17:57:43.000-05:00'], 'priority': [2, 1]}, '45512': {'otid': 5133, 'tid': [5134, 5135], 'time': ['2021-11-30T17:57:58.000-05:00', '2021-11-30T17:58:00.000-05:00'], 'priority': [2, 1]}, '45515': {'otid': None, 'tid': [], 'time': [0], 'priority': [3, 1, 4, 2]}}, 'max_accepted_proposals': 3}&lt;br /&gt;
[2021-11-28 18:10:40,576] ERROR in app: Exception on /match_topics [POST]&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 2447, in wsgi_app&lt;br /&gt;
    response = self.full_dispatch_request()&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1952, in full_dispatch_request&lt;br /&gt;
    rv = self.handle_user_exception(e)&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1821, in handle_user_exception&lt;br /&gt;
    reraise(exc_type, exc_value, tb)&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/_compat.py&amp;quot;, line 39, in reraise&lt;br /&gt;
    raise value&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1950, in full_dispatch_request&lt;br /&gt;
    rv = self.dispatch_request()&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1936, in dispatch_request&lt;br /&gt;
    return self.view_functions[rule.endpoint](**req.view_args)&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/app.py&amp;quot;, line 19, in topic_matching&lt;br /&gt;
    return jsonify(assigned_topics_model.get_student_topic_matches())&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/topics_matcher.py&amp;quot;, line 57, in get_student_topic_matches&lt;br /&gt;
    student.accept_proposal()&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/student.py&amp;quot;, line 24, in accept_proposal&lt;br /&gt;
    self.proposals.sort(key=lambda proposal: self.choices.index(proposal))&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/student.py&amp;quot;, line 24, in &amp;lt;lambda&amp;gt;&lt;br /&gt;
    self.proposals.sort(key=lambda proposal: self.choices.index(proposal))&lt;br /&gt;
ValueError: None is not in list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As we can see from the additional information provided above, the error is due to an unhandled edge case of attempting to access missing value. Our further observation also concluded that such missing value is due to the fact that one or more to-be-matched students did not have any topic signed up at the time of algorithm execution. To address the issue, a general enhancement can be implemented on the algorithm service side with Flask to increase the crash recovery stability. Further refinement of interaction flow with user in the front end can also reduce the possibility of algorithm service error.&lt;br /&gt;
&lt;br /&gt;
Additional to the unhandled cases from the algorithm service, we also noticed an inconsistency of the system due to the performance limitation of the Heroku deployment.&lt;br /&gt;
&lt;br /&gt;
[[File:Out_of_scope_External-Issue_E2151.gif|frameless|x1000px]]&lt;br /&gt;
&lt;br /&gt;
As we can see from the above recorded screen capture animation, with the exact same input, the output and algorithm service result are unstable. Because of the performance limitation of the Heroku, sometime the Flask app that deployed were overloaded. Furthermore, we have also attempted to deploy on VCL, however, we notice the limitation of VCL deployment that will become offline once the VCL reservation expired. After all, because of the focus of our tasks is on the DRY principal optimization, the external algorithm service can be improved in the future. To access and deploy the algorithm on local environment or another environment, setup guide and resource are available on [https://github.com/uahamedncsu/IntelligentAssignment IntelligentAssignment] repository.&lt;br /&gt;
&lt;br /&gt;
===Lack of Comprehensive Testing===&lt;br /&gt;
&lt;br /&gt;
A notable contradiction that was noticed when working with this project was that the previously-mentioned failed edge cases existed, yet all tests for this feature passed. This is illustrative of the fact that this feature requires better and more exhaustive testing.&lt;br /&gt;
&lt;br /&gt;
When dealing with an issue with so many factors as how students bid on reviews, an extensive suite of edge cases should be considered. Any future project group working on this function should consider the following edge cases to cover:&lt;br /&gt;
* Does a student who does not bid on any reviews still get reviews?&lt;br /&gt;
* Does a student who did not submit anything for their assignment still have a review to bid on?&lt;br /&gt;
* What if there are less assignments to have reviews for than the minimum number required for all students to have the minimum number of reviews?&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
While we believe the current state of this feature is greatly improved, with many of its DRY violations removed and several noteworthy bugs corrected, we believe the feature of allowing students to bid on what to review still needs further development before it is deployed. While the basic functionality is working under ideal situations, the issues mentioned above should be addressed before this feature is put in the hands of actual instructors, as if this feature fails, it could ruin the entire reviewing process for an assignment.&lt;br /&gt;
&lt;br /&gt;
Still, we think there is notable promise to this feature, and it would be a very engaging and interesting feature if deployed successfully, so we believe develop on it should continue until it is ready for deployment.&lt;br /&gt;
&lt;br /&gt;
==Github and Related Link==&lt;br /&gt;
Github repository corresponding to this task is publicly available at [https://github.com/WeiRui-Wang/expertiza E2151 GitHub].&lt;br /&gt;
&lt;br /&gt;
Github pull request and file changes can be viewed at [https://github.com/expertiza/expertiza/pull/2150/files E2151 Pull Request].&lt;br /&gt;
&lt;br /&gt;
Github of source code of externally hosted bidding algorithm service deployment manual and files can be access at [https://github.com/uahamedncsu/IntelligentAssignment IntelligentAssignment].&lt;br /&gt;
&lt;br /&gt;
==Contributors==&lt;br /&gt;
This feature was created as part of Dr. Edward Gehringer's &amp;quot;CSC/ECE 517: Object-Oriented Design and Development&amp;quot; class, Fall 2021. The contributors were: Geoff Garrido, Ayush Luthra, and WeiRui Wang. Our project mentor was Luis Delossantos (lgdeloss@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=142155</id>
		<title>CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=142155"/>
		<updated>2021-11-30T01:11:53Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: /* review_bid.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic Overview==&lt;br /&gt;
===Statement of Problem===&lt;br /&gt;
Reviewing is an important stage of learning and improving, both as a reviewer and a reviewee, and so allowing reviewers more freedom and choice in what they review would result in better reviews and more engaged reviewers. However, currently the only way to choose a topic to review is a first-come-first-served basis, penalizing students who do not sign up quickly by not allowing them to review the topics they would be most interesting in engaging with.&lt;br /&gt;
&lt;br /&gt;
A better alternative would be to implement a bidding system, similar to that used for topics, which would allow students to establish preferences for which topics they would most like to review. A good bidding algorithm implementing with this idea would ensure that all students (who care enough to bid) receive a topic to review that they actively want.&lt;br /&gt;
&lt;br /&gt;
A prior project group created a prototype for this function, allowing students to bid on what topics they wanted to review. While the functionality was as desired, the feature was not able to be merged due to having too many DRY violations. Thus, the goal of this topic was to bring this prior implementation into the current version of the expertiza beta branch, and remove these DRY violations, so that it may be merged.&lt;br /&gt;
&lt;br /&gt;
As development continued, it became clear this prototype also had several bugs and issues that made it unable to work under several conditions. Thus, a secondary goal was to fix any issues which existed such that the feature would generally work with the functionality the prior implementation demonstrated.&lt;br /&gt;
&lt;br /&gt;
===Prior Work===&lt;br /&gt;
The prior work which is the basis for this topic is linked here [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review is linked here]. This work was done in Fall of 2020, and as previously mentioned, achieved much of the desired functionality for this task. This prior work will be referenced several times within this documentation, as it has a more comprehensive explanation of the underlying design principles behind the views, controller, model, algorithm, and RSpec tests implemented. These details will only be briefly summarized here. &lt;br /&gt;
&lt;br /&gt;
As previously noted, this prior implementation was rejected due to DRY violations, and so correcting these violations--and explaining how those corrections were done--will be the major focus of this project documentation.&lt;br /&gt;
&lt;br /&gt;
==Explanation of Feature==&lt;br /&gt;
&lt;br /&gt;
===Existing Bidding Functionality for Topics===&lt;br /&gt;
Currently in expertiza, students may bid on which topics they would like to work on. An image showcasing this functionality is given below:&lt;br /&gt;
&lt;br /&gt;
[[File:expected_review_UI.PNG]]&lt;br /&gt;
&lt;br /&gt;
Students may choose a number of topics to bid on, in order of priority, and once the deadline is reached, all students are given a topic.&lt;br /&gt;
&lt;br /&gt;
Behind the scenes, this works by utilizing a modified version of the Gale-Shapely Algorithm. This algorithm seeks to find a 'stable' matching of each student to each topic, such that in the end, all students have a topic they wanted (at least to some degree), and that the preferences of students is respected as well as possible. To help break situations where there are ties in preferences, each topic assigns a Priority to each student. This Priority is determined by A. whether the student is part of a group bidding for this topic (groups getting higher priority), and B. the time at which the bid for the topic was made (earlier bidders are given Priority). Once this has been determined and the deadline for bidding has ended, the following steps occur:&lt;br /&gt;
# Each student is matched with each topic they most prefer.&lt;br /&gt;
# If the number of students assigned to a topic is above the maximum allowed for that topic, the students with the highest Priority are assigned the topic&lt;br /&gt;
# All maximally filled topics are removed from the pool of available topics&lt;br /&gt;
# All unmatched students begin this cycle again, now choosing the most preferred topic remaining&lt;br /&gt;
# Repeat until all students are assigned a topic&lt;br /&gt;
# If any matches are 'unstable' (two students would have their preferences better met if they were swapped), perform any swaps until matches are as stable as possible.&lt;br /&gt;
&lt;br /&gt;
This algorithm has a time complexity of O(n^2). For more details on this algorithm and its implementation, refer to the previous year's work, where this algorithm was implemented.&lt;br /&gt;
&lt;br /&gt;
===Desired Functionality for Reviews===&lt;br /&gt;
&lt;br /&gt;
The desired feature for reviews should have an almost identical structure to this, with reviews instead of topics. Students should be shown a list of the topics that were worked on, and may bid on which of those topics they would like to review the most. The Priority system could be handled in the same way, with the only caveat being that a student should not be able to review their own work.&lt;br /&gt;
&lt;br /&gt;
In terms of what this feature looks like, it can be enabled as an option when editing/creating a new assignment, under the &amp;quot;Topics&amp;quot; section, using interface drop down show below.&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_interface.png|center|800px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once this option is enabled, during the review phase of an assignment, students will be able to access a new view listing all the topics of all the submitted assignments (except for their own). They will then be able to bid on as many topics as they like, assigning them a preference, in a manner similar to the interface for topic bidding. The table that allows for this drag-and-drop priorities is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_options.png|center|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Whenever the instructor decides they would like to close the window for review bidding, they may return to the options for the given assignment and navigate to &amp;quot;Topics&amp;quot;, where they will see a button marked &amp;quot;Run Review Algorithm&amp;quot;. This will make a call to the external webservice to determine which students are assigned what reviews, and will then assign those reviews to all students. Once this button is pressed, it locks out the ability for students to perform any more bidding, and cannot be pressed again. The button allowing this option is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_run_algorithm.png|center|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After this point, students may navigate to the &amp;quot;Others Work&amp;quot; option under their assignment and see all of their assigned reviews. They will see up to the maximum number of allowed reviews, but will be informed of how many they are required to do (for example, a student may see 4 reviews, but will be told they are only required to complete 2).&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
The following Use Case Diagram demonstrates the primary functionality explained in the previous section for different types of users.&lt;br /&gt;
&lt;br /&gt;
[[File:Use_Case_Diagram_Rev1_E2151.jpg|center]]&lt;br /&gt;
&lt;br /&gt;
==Plan and List of Work Done==&lt;br /&gt;
&lt;br /&gt;
===General Design Goals===&lt;br /&gt;
&lt;br /&gt;
* Move all prior work for this topic into a new version of the expertiza beta branch, without loss in functionality.&lt;br /&gt;
* Ensure all prior/expected functionality is working correctly, and if not, make any repairs or changes necessary.&lt;br /&gt;
* DRY out prior implementation's controller and model methods which have functionality that already exists within the expertiza system.&lt;br /&gt;
* Remove repetitive views and partials that exist by merging views for review bids into the set of views for sign up sheets, from which it uses partials.&lt;br /&gt;
* Ensure all present test cases still work properly after making the above changes.&lt;br /&gt;
&lt;br /&gt;
===Specific Tasks Completed===&lt;br /&gt;
&lt;br /&gt;
* Transferred over all code files relevant to the review bidding feature&lt;br /&gt;
* Re-deployed the external website which handles the review bidding algorithm&lt;br /&gt;
* Added that website's url to the webservices url's within expertiza&lt;br /&gt;
* Enhanced the stability of the webservice for the bidding algorithm by testing with edge cases and optimize the endpoint by restoring the original access endpoint reference* Analyzed the necessity of the phase finding related logic code section&lt;br /&gt;
* Optimized phase finding related logic by removing unused code segment&lt;br /&gt;
* Removed an instance variable within the ''review_bids_controller'' which would have made any practical deployment fail, removing the unnecessary functionality it was created for&lt;br /&gt;
* Updated method calls to ''assignment.find_current_stage'' to their new form ''assignment.current_stage''&lt;br /&gt;
* Removed the review_bid model method ''self.reviewer_self_topic'' and replaced its usage with the already-existing ''SignedUpTeam.topic_id'' method&lt;br /&gt;
* Removed DRY-violating code used to calculate the current assignment phase which was never utilized by the controller or views&lt;br /&gt;
* Moved several view files from the ''review_bids'' view directory into the ''sign_up_sheet'' view directory. Partials which were duplicates in the two directories (''_all_actions.html.erb'' and ''_topic_names.html.erb'' were no longer necessary and deleted&lt;br /&gt;
* Refactored the naming of the variable that represents the id of the reviewer object from 'reviewer' to 'reviewer_id' for clarity&lt;br /&gt;
* Removed the unnecessary 'create' function within the review_bids_controller&lt;br /&gt;
* Removed the sparse testing files under the 'test' directory in keeping with typical expertiza structure&lt;br /&gt;
* Removed a test case from the unit tests which relied upon the removed 'create' method of the review_bids_controller&lt;br /&gt;
&lt;br /&gt;
==Initial Implementation==&lt;br /&gt;
&lt;br /&gt;
A considerable amount of time and effort was necessary to review, understand, and re-implement the previous implementation of the Review Bidding feature. While the feature was only created a year ago, several underlying functions and methods have since been refactored, and so needed to be changed in the implementation. Additionally, certain parts of how the implementation was designed did not seem to be properly implemented, and so had to be revised.&lt;br /&gt;
&lt;br /&gt;
===Code Transfer===&lt;br /&gt;
First, all files that were added in the original pull request were copied and moved to the new version of the expertiza beta branch. This includes the following files:&lt;br /&gt;
&lt;br /&gt;
*'''controllers/review_bids_controller.rb''': the primary controller that handles calls to review bids functionality from views, managing them itself or directing them to the appropriate model&lt;br /&gt;
*'''helpers/review_bids_helper.rb''': contains helper methods for rendering the rows of topics available to choose a review for&lt;br /&gt;
*'''models/review_bid.rb''': contains the methods that each individual review bid knows and manages, including assigning a review to a student, getting info on the topic it applies to, etc.&lt;br /&gt;
*'''views/review_bids/_all_actions.html.erb''': a view partial used to render the actions available to a student on the review bidding view. Nearly identical to the _all_actions file for topic bidding.&lt;br /&gt;
*'''views/review_bids/_table_header.html.erb''': a view partial used to render the head of the table for review bids. Though structurally similar to that of topics reviews, contains significantly less information, as less needs to be known by a student for particular topics to review.&lt;br /&gt;
*'''views/review_bids/_table_line.html.erb''': a view partial used to render individual rows of the review bids table. Like the table header, is structurally similar to that of topic bidding, but functions differently.&lt;br /&gt;
*'''views/review_bids/show.html.erb''': the view which displays all the available topics to bid on reviewing. Uses the aforementioned partials to render this bidding table.&lt;br /&gt;
*'''views/review_bids/others_work.html.erb''': displays the available review work which has the user has bid for.&lt;br /&gt;
*'''db/migrate/20201107203204_create_review_bids.rb''': the migration which creates the review bid objects within the expertiza database.&lt;br /&gt;
*'''spec/controllers/review_bids_controller_spec.rb''': the unit tests for the review bids controller&lt;br /&gt;
*'''spec/models/review_bid_spec.rb''': the unit tests for the review bids model&lt;br /&gt;
*'''test/controllers/review_bids_controller_test.rb''': a more elaborate feature test for the review bids functionality&lt;br /&gt;
*'''test/fixtures/review_bids.yml''': fixtures that are utilized for the review_bids_controller_test&lt;br /&gt;
*'''test/models/review_bid_test.rb''': A more elaborate feature test of the review bid model.&lt;br /&gt;
&lt;br /&gt;
In addition to adding the previous files, the following files were also added to existing pages as modifications:&lt;br /&gt;
&lt;br /&gt;
*'''controllers/student_review_controller.rb''': the student review controller's &amp;quot;list&amp;quot; method now redirects to the review_bid_controller's &amp;quot;index&amp;quot; method if the assignment in question has a review_choosing_algorithm set to &amp;quot;Bidding&amp;quot; (the option an instructor sets when they wish to allow students to bid on reviews).&lt;br /&gt;
*'''student_task/view.html.erb''': Instead of simply linking directly to the student_review controller's &amp;quot;list&amp;quot; method, the view instead checks if the assignment this view pertains to has their review_choosing_algorithm set to Bidding. If it does, and the assignment allows students to choose the topic to review (meaning the algorithm to assign bids has not yet been run), they are redirected to the 'show' method of the review_bids_controller. Otherwise, they are redirected to the 'index' method (showing them the info on their currently available topics to review).&lt;br /&gt;
*'''config/webservices.yml''': added a new url for the website that is called to run the review bidding algorithm&lt;br /&gt;
*'''config/routes.rb''': routes added for review_bids.&lt;br /&gt;
*'''views/assignments/edit/_topics.html.erb''': Added a new option box which allows an instructor to choose to allow bidding to occur using the review bidding algorithm, rather than the default 'Simple Choose.' Once this option is selected, it also offers a button that, when clicked, runs the review bidding algorithm on all currently bid upon reviews.&lt;br /&gt;
&lt;br /&gt;
===Website Reimplementation===&lt;br /&gt;
In the previous implementation, the algorithm which handles the assigning of reviews was hosted on an external website. This was done for the sake of improved performance. Thus, to get the feature in working condition, we pulled the code necessary to run the algorithm and hosted it on our own website (linked at the end of this documentation). We also made a note in the pull request that the place where this website is referenced (in the &amp;quot;assign_reviews_algorithm&amp;quot; method of the review_bids_controller) should be replaced by a proper external web tool, as is done for similar web tools in other parts of expertiza.&lt;br /&gt;
&lt;br /&gt;
===Modifications to Methods===&lt;br /&gt;
Certain methods utilized in the original version of the webpages were changed or renamed in later versions, and so, needed to be modified. The primary example of this is the method that assignments use to determine what stage of assignment completion they are in. The previous year's implementation called this method as &amp;quot;assignment.find_current_stage(topic_id),&amp;quot; but this failed when trying to execute. After comparing how this page worked to how normal review pages work, we determined the new call to this method is &amp;quot;assignment.current_stage(topic_id).&amp;quot; All calls to this method were replaced in all files.&lt;br /&gt;
&lt;br /&gt;
Another change to methods was the removal of a method from the review_bids_controller named 'create'. This method primarily served as a redirect for an aspect of the feature that was unnecessary and so removed (see the following section), that being the button to show another review. With this feature removed, this method was no longer used, and so it was removed from the controller.&lt;br /&gt;
&lt;br /&gt;
===Errors Corrected===&lt;br /&gt;
A notable period of time was also spent on determining the purpose of a particular local area that caused issues when trying to view the bids, that being a variable named &amp;quot;@number_of_reviews_to_show&amp;quot;. This variable apparently kept track of how many reviews a student needed to be shown, so that they could request another. The issue was that this was created as a local variable within the review_bids_controller, and therefore would never work outside of a manual testing environment, as the variable would need to be different from every student and every assignment. After some investigation, we realized that all this variable did was limit the number of already-assigned reviews the student was able to see (as the review bidding algorithm already assigned all possible reviews). Thus, rather than try to recreate this functionality, we simply removed it.&lt;br /&gt;
&lt;br /&gt;
This means that, when the review bidding algorithm runs, a student is able to see all of the reviews assigned to them, up to the maximum number of reviews for the assignment, and therefore have no reason to ask for any more. It may be the case that this feature could be improved by adding a possibility for students to request any reviews not assigned to any other student, or that still have available slots, using the &amp;quot;normal&amp;quot; review assignment scheme. For the time being, we did not consider this part of the baseline necessary functionality, and so did not implement it.&lt;br /&gt;
&lt;br /&gt;
==Refinement Implementation==&lt;br /&gt;
&lt;br /&gt;
===DRY Principle and Code Duplication Refactoring===&lt;br /&gt;
Per comments and feedbacks on the previous implementation [https://github.com/expertiza/expertiza/pull/1822 E2085], there were 3 sections of the code that potentially were DRY violations. For each of those violations, we have had made appropriate and provided the justification on the results.&lt;br /&gt;
&lt;br /&gt;
====review_bids_controller.rb====&lt;br /&gt;
For the refactoring of review bids controller.eb, the original issue is the DRY principle violation on the internal logic of finding the phase of assignments.&lt;br /&gt;
The original implementation to be refactored and optimized are shown as follow.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # Finding the current phase that we are in&lt;br /&gt;
    due_dates = AssignmentDueDate.where(parent_id: @assignment.id)&lt;br /&gt;
    @very_last_due_date = AssignmentDueDate.where(parent_id: @assignment.id).order(&amp;quot;due_at DESC&amp;quot;).limit(1)&lt;br /&gt;
    next_due_date = @very_last_due_date[0]&lt;br /&gt;
    for due_date in due_dates&lt;br /&gt;
      if due_date.due_at &amp;gt; Time.now&lt;br /&gt;
        next_due_date = due_date if due_date.due_at &amp;lt; next_due_date.due_at&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    @review_phase = next_due_date.deadline_type_id&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Through some discovery process, we have found some related logics that is already implemented from the system which enable the refactoring and reuse of the method. Some code snippets are demonstrated as follow.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.current_due_date(due_dates)&lt;br /&gt;
    #Get the current due date from list of due dates&lt;br /&gt;
    due_dates.each do |due_date|&lt;br /&gt;
      if due_date.due_at &amp;gt; Time.now&lt;br /&gt;
        current_due_date = due_date&lt;br /&gt;
        return current_due_date&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    #in case current due date not found&lt;br /&gt;
    return nil &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.teammate_review_allowed(student)&lt;br /&gt;
    # time when teammate review is allowed&lt;br /&gt;
    due_date = current_due_date(student.assignment.due_dates)&lt;br /&gt;
    student.assignment.find_current_stage == 'Finished' ||&lt;br /&gt;
    due_date &amp;amp;&amp;amp;&lt;br /&gt;
    (due_date.teammate_review_allowed_id == 3 ||&lt;br /&gt;
    due_date.teammate_review_allowed_id == 2) # late(2) or yes(3)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As we can observed above, both methods of &amp;lt;code&amp;gt;current_due_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;teammate_review_allowed&amp;lt;/code&amp;gt; provides the capability of getting the &amp;lt;code&amp;gt;review_phase&amp;lt;/code&amp;gt; without the repetition. Additionally, we can see that those existing implementation still have some difference in implementation and purpose to be fully reusable by the logic that find current phase of a topic because the methods provided are helper methods for broader abstraction.&lt;br /&gt;
&lt;br /&gt;
Furthermore, the section that we attempted to refactoring out have a similar logic that is used to get the current stage as shown below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def find_current_stage(topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(self.id, topic_id)&lt;br /&gt;
    return 'Finished' if next_due_date.nil?&lt;br /&gt;
    next_due_date&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
However, it is worth pointing out that the method is not fully substitutable, particularly the internal functionality that finds the &amp;lt;code&amp;gt;@very_last_due_date&amp;lt;/code&amp;gt;. A similar logic does exist that is meant to use to acquire current due date and assist with finding current stage.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def current_stage_name(topic_id = nil)&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      return (topic_id.nil? ? 'Unknown' : current_stage(topic_id))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    due_date = find_current_stage(topic_id)&lt;br /&gt;
    unless due_date == 'Finished' || due_date.nil? || due_date.deadline_name.nil?&lt;br /&gt;
      return due_date.deadline_name&lt;br /&gt;
    end&lt;br /&gt;
    current_stage(topic_id)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
With all the findings, we have come to conclusion that the portion of the code to be dry is in similar, but required full restructure, form of existing methods. The internal logic flow itself is not fully matching the reusable methods consists across the controllers. Because of the clarity of limited reusability of existing methods, we have come to conclusion that the portions to be refactored are not duplication of any existing methods. Additionally, after a more detailed discovery, it has come to realization that the code portion of getting the current phase of the next due date was, in fact, meant to find the last due date. After further analysis of the purpose of the code, the portion has been deleted from &amp;lt;code&amp;gt;review_bids_controller.rb&amp;lt;/code&amp;gt; because there was no usage observed with the result of the execution.&lt;br /&gt;
&lt;br /&gt;
====review_bid.rb====&lt;br /&gt;
Per the previous iteration's feedback, the review_bid.rb model file presented some DRY violations. These violations are highlighted in the method below:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Review_bid_original.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Refactoring Views (_all_actions.html.erb and _topic_names.html.erb)====&lt;br /&gt;
The last element of the prior implementation that caused DRY violations had to do with its implementation of views. Two primary views are necessary for the review bids functionality: one which shows a table where students can bid on which topic they wish to review (rendered by a file called 'show.html.erb'), and a list of assigned reviews which a student must select from (rendered by a file called 'others_work.html.erb'). &lt;br /&gt;
&lt;br /&gt;
In order to render the elements in 'show.html.erb' in particular, a number of partials must be utilized:&lt;br /&gt;
*a partial for the table's header (_table_header.html.erb)&lt;br /&gt;
*a partial for rendering each of the table's rows, describing a topic to bid on (_table_line.html.erb)&lt;br /&gt;
*a partial to contain information related to what actions are available for a student to do for a review, like edit or view (_all_actions.html.erb)&lt;br /&gt;
*a partial for finding and rendering the name of each topic one must review (_topic_names.html.erb)&lt;br /&gt;
&lt;br /&gt;
Both of these views and all four of these partials were contained within the &amp;quot;review_bids&amp;quot; directory within the views directory. The DRY violation incurred by these views has to do with these partials: in particular, '_topic_names.html.erb' and '_all_actions.html.erb' are near identical code copies to those within the sign_up_sheet views, used for rendering and displaying information for topic bidding and normal reviews.&lt;br /&gt;
&lt;br /&gt;
In order to DRY out this portion of the code, we decided that having a separate set of views for the results related to review bids were unnecessary. Within expertiza's structure, most of the views related to students choosing which topics or reviews to work on are all contained within the sign_up_sheet views. The review_vids views were copying the partials within the sign_up_sheet views because they were using the same fundamental components. Thus, we thought the best solution would be to move the two primary views for review_bids ('show.html.erb' and 'others_work.html.erb') into the sign_up_sheet views, and leave behind all redundant partials. In doing so, the redundancy of '_all_actions.html.erb' and '_topic_names.html.erb' were eliminated.&lt;br /&gt;
&lt;br /&gt;
It could be argued that this implementation could be further DRY-ed by leaving behind the other two partials, '_table_header.html.erb' and '_table_line.html.erb', as they are structurally similar to those used for topic bidding. However, this is not actually permissible, as the header and lines for topics when bidding on them for reviews are significantly different than when bidding on them for assignments. More information needs to be available when bidding on topics for an assignment, such as the number of slots and number on the waitlist, but such an idea is not applicable for bids on reviews. While it would be possible to have a single file which produces one view or another depending upon if it's bidding for topics or reviews, we believed this violated the Expert Pattern, by attempting to create a single view for two distinct purposes. Instead, we thought it better to simply have two separate partials, each which precisely gave the desired functionality. Thus, the other two partials were brought over, being renamed '_review_bids_table_header.html.erb' and '_review_bids_table_line.html.erb'.&lt;br /&gt;
&lt;br /&gt;
==Tests==&lt;br /&gt;
&lt;br /&gt;
Throughout the refactoring and merging of [https://github.com/expertiza/expertiza/pull/1822 E2085] to [https://github.com/expertiza/expertiza/pull/2150 E2151], there were some updates that has been made to the test suits to maintain corrosponding testing automation.&lt;br /&gt;
&lt;br /&gt;
===Video Demonstration===&lt;br /&gt;
[https://www.youtube.com/watch?v=wxXALQNWFcc Click this link] to see a video demonstrating the functionality of the review bidding feature.&lt;br /&gt;
&lt;br /&gt;
===RSpec Testing===&lt;br /&gt;
One of the primary design goals when doing this refactoring was to ensure that all test cases still passed after all changes were made.&lt;br /&gt;
&lt;br /&gt;
There was a single change that needed to be made to the RSpec files for the review bidding algorithm, which was the removal of a test relying on the 'create' method of the review_bids_controller. As previously mentioned, this function was removed because it had become obsolete. Thus, the test case for this function (which simply checked if it redirected to the right page) was no longer necessary, and thus was deleted.&lt;br /&gt;
&lt;br /&gt;
Otherwise, the test cases for both the review_bids_controller and the review_bids model were manually run and found to have no errors, as shown below.&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_test_results.png|800px]]&lt;br /&gt;
&lt;br /&gt;
For details on what these specific tests were, please refer to the previous work referenced before.&lt;br /&gt;
&lt;br /&gt;
==Conclusions and Future Work==&lt;br /&gt;
While the current state of the review bidding code is operational, and is certainly more DRY and stable than the previous incarnation of this work, there are still several issues with the current state of this feature that make it difficult to recommend an immediate merge into expertiza.&lt;br /&gt;
&lt;br /&gt;
===Enhancement of Algorithm Service Stability===&lt;br /&gt;
&lt;br /&gt;
Across the process of refining the refactored front end page view along with more robust edge cases testing towards the algorithm service, we have discovered an underlying issue that could impact the availability of the review bidding algorithm service. Through cause isolation, we have observed a high correlation to flask application crash with the edge case scenario input where the algorithm service is trying to match a student who was not signed up with any topic with other students.&lt;br /&gt;
&lt;br /&gt;
Because the scope of our project was focused on refactoring, we did not have the time or prior warning to need to address these edge cases. However, we will provide the error log for the reference of any future teams who may work on the stability improvement of the algorithm service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;POST /match_topics HTTP/1.1&amp;quot; 500 -&lt;br /&gt;
{'tid': [5133, 5134, 5135, None], 'users': {'45514': {'otid': 5135, 'tid': [5133, 5134], 'time': ['2021-11-30T17:57:20.000-05:00', '2021-11-30T17:57:24.000-05:00'], 'priority': [2, 1]}, '45513': {'otid': 5134, 'tid': [5133, 5135], 'time': ['2021-11-30T17:57:41.000-05:00', '2021-11-30T17:57:43.000-05:00'], 'priority': [2, 1]}, '45512': {'otid': 5133, 'tid': [5134, 5135], 'time': ['2021-11-30T17:57:58.000-05:00', '2021-11-30T17:58:00.000-05:00'], 'priority': [2, 1]}, '45515': {'otid': None, 'tid': [], 'time': [0], 'priority': [3, 1, 4, 2]}}, 'max_accepted_proposals': 3}&lt;br /&gt;
[2021-11-28 18:10:40,576] ERROR in app: Exception on /match_topics [POST]&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 2447, in wsgi_app&lt;br /&gt;
    response = self.full_dispatch_request()&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1952, in full_dispatch_request&lt;br /&gt;
    rv = self.handle_user_exception(e)&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1821, in handle_user_exception&lt;br /&gt;
    reraise(exc_type, exc_value, tb)&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/_compat.py&amp;quot;, line 39, in reraise&lt;br /&gt;
    raise value&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1950, in full_dispatch_request&lt;br /&gt;
    rv = self.dispatch_request()&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1936, in dispatch_request&lt;br /&gt;
    return self.view_functions[rule.endpoint](**req.view_args)&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/app.py&amp;quot;, line 19, in topic_matching&lt;br /&gt;
    return jsonify(assigned_topics_model.get_student_topic_matches())&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/topics_matcher.py&amp;quot;, line 57, in get_student_topic_matches&lt;br /&gt;
    student.accept_proposal()&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/student.py&amp;quot;, line 24, in accept_proposal&lt;br /&gt;
    self.proposals.sort(key=lambda proposal: self.choices.index(proposal))&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/student.py&amp;quot;, line 24, in &amp;lt;lambda&amp;gt;&lt;br /&gt;
    self.proposals.sort(key=lambda proposal: self.choices.index(proposal))&lt;br /&gt;
ValueError: None is not in list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As we can see from the additional information provided above, the error is due to an unhandled edge case of attempting to access missing value. Our further observation also concluded that such missing value is due to the fact that one or more to-be-matched students did not have any topic signed up at the time of algorithm execution. To address the issue, a general enhancement can be implemented on the algorithm service side with Flask to increase the crash recovery stability. Further refinement of interaction flow with user in the front end can also reduce the possibility of algorithm service error.&lt;br /&gt;
&lt;br /&gt;
Additional to the unhandled cases from the algorithm service, we also noticed an inconsistency of the system due to the performance limitation of the Heroku deployment.&lt;br /&gt;
&lt;br /&gt;
[[File:Out_of_scope_External-Issue_E2151.gif|frameless|x1000px]]&lt;br /&gt;
&lt;br /&gt;
As we can see from the above recorded screen capture animation, with the exact same input, the output and algorithm service result are unstable. Because of the performance limitation of the Heroku, sometime the Flask app that deployed were overloaded. Furthermore, we have also attempted to deploy on VCL, however, we notice the limitation of VCL deployment that will become offline once the VCL reservation expired. After all, because of the focus of our tasks is on the DRY principal optimization, the external algorithm service can be improved in the future. To access and deploy the algorithm on local environment or another environment, setup guide and resource are available on [https://github.com/uahamedncsu/IntelligentAssignment IntelligentAssignment] repository.&lt;br /&gt;
&lt;br /&gt;
===Lack of Comprehensive Testing===&lt;br /&gt;
&lt;br /&gt;
A notable contradiction that was noticed when working with this project was that the previously-mentioned failed edge cases existed, yet all tests for this feature passed. This is illustrative of the fact that this feature requires better and more exhaustive testing.&lt;br /&gt;
&lt;br /&gt;
When dealing with an issue with so many factors as how students bid on reviews, an extensive suite of edge cases should be considered. Any future project group working on this function should consider the following edge cases to cover:&lt;br /&gt;
* Does a student who does not bid on any reviews still get reviews?&lt;br /&gt;
* Does a student who did not submit anything for their assignment still have a review to bid on?&lt;br /&gt;
* What if there are less assignments to have reviews for than the minimum number required for all students to have the minimum number of reviews?&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
While we believe the current state of this feature is greatly improved, with many of its DRY violations removed and several noteworthy bugs corrected, we believe the feature of allowing students to bid on what to review still needs further development before it is deployed. While the basic functionality is working under ideal situations, the issues mentioned above should be addressed before this feature is put in the hands of actual instructors, as if this feature fails, it could ruin the entire reviewing process for an assignment.&lt;br /&gt;
&lt;br /&gt;
Still, we think there is notable promise to this feature, and it would be a very engaging and interesting feature if deployed successfully, so we believe develop on it should continue until it is ready for deployment.&lt;br /&gt;
&lt;br /&gt;
==Github==&lt;br /&gt;
The Github corresponding to this task is publicly available here: https://github.com/WeiRui-Wang/expertiza&lt;br /&gt;
&lt;br /&gt;
==Contributors==&lt;br /&gt;
This feature was created as part of Dr. Edward Gehringer's &amp;quot;CSC/ECE 517: Object-Oriented Design and Development&amp;quot; class, Fall 2021. The contributors were: Geoff Garrido, Ayush Luthra, and WeiRui Wang. Our project mentor was Luis Delossantos (lgdeloss@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Review_bid_original.png&amp;diff=142154</id>
		<title>File:Review bid original.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Review_bid_original.png&amp;diff=142154"/>
		<updated>2021-11-30T01:11:01Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=142152</id>
		<title>CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=142152"/>
		<updated>2021-11-30T01:10:04Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: /* review_bid.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic Overview==&lt;br /&gt;
===Statement of Problem===&lt;br /&gt;
Reviewing is an important stage of learning and improving, both as a reviewer and a reviewee, and so allowing reviewers more freedom and choice in what they review would result in better reviews and more engaged reviewers. However, currently the only way to choose a topic to review is a first-come-first-served basis, penalizing students who do not sign up quickly by not allowing them to review the topics they would be most interesting in engaging with.&lt;br /&gt;
&lt;br /&gt;
A better alternative would be to implement a bidding system, similar to that used for topics, which would allow students to establish preferences for which topics they would most like to review. A good bidding algorithm implementing with this idea would ensure that all students (who care enough to bid) receive a topic to review that they actively want.&lt;br /&gt;
&lt;br /&gt;
A prior project group created a prototype for this function, allowing students to bid on what topics they wanted to review. While the functionality was as desired, the feature was not able to be merged due to having too many DRY violations. Thus, the goal of this topic was to bring this prior implementation into the current version of the expertiza beta branch, and remove these DRY violations, so that it may be merged.&lt;br /&gt;
&lt;br /&gt;
As development continued, it became clear this prototype also had several bugs and issues that made it unable to work under several conditions. Thus, a secondary goal was to fix any issues which existed such that the feature would generally work with the functionality the prior implementation demonstrated.&lt;br /&gt;
&lt;br /&gt;
===Prior Work===&lt;br /&gt;
The prior work which is the basis for this topic is linked here [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review is linked here]. This work was done in Fall of 2020, and as previously mentioned, achieved much of the desired functionality for this task. This prior work will be referenced several times within this documentation, as it has a more comprehensive explanation of the underlying design principles behind the views, controller, model, algorithm, and RSpec tests implemented. These details will only be briefly summarized here. &lt;br /&gt;
&lt;br /&gt;
As previously noted, this prior implementation was rejected due to DRY violations, and so correcting these violations--and explaining how those corrections were done--will be the major focus of this project documentation.&lt;br /&gt;
&lt;br /&gt;
==Explanation of Feature==&lt;br /&gt;
&lt;br /&gt;
===Existing Bidding Functionality for Topics===&lt;br /&gt;
Currently in expertiza, students may bid on which topics they would like to work on. An image showcasing this functionality is given below:&lt;br /&gt;
&lt;br /&gt;
[[File:expected_review_UI.PNG]]&lt;br /&gt;
&lt;br /&gt;
Students may choose a number of topics to bid on, in order of priority, and once the deadline is reached, all students are given a topic.&lt;br /&gt;
&lt;br /&gt;
Behind the scenes, this works by utilizing a modified version of the Gale-Shapely Algorithm. This algorithm seeks to find a 'stable' matching of each student to each topic, such that in the end, all students have a topic they wanted (at least to some degree), and that the preferences of students is respected as well as possible. To help break situations where there are ties in preferences, each topic assigns a Priority to each student. This Priority is determined by A. whether the student is part of a group bidding for this topic (groups getting higher priority), and B. the time at which the bid for the topic was made (earlier bidders are given Priority). Once this has been determined and the deadline for bidding has ended, the following steps occur:&lt;br /&gt;
# Each student is matched with each topic they most prefer.&lt;br /&gt;
# If the number of students assigned to a topic is above the maximum allowed for that topic, the students with the highest Priority are assigned the topic&lt;br /&gt;
# All maximally filled topics are removed from the pool of available topics&lt;br /&gt;
# All unmatched students begin this cycle again, now choosing the most preferred topic remaining&lt;br /&gt;
# Repeat until all students are assigned a topic&lt;br /&gt;
# If any matches are 'unstable' (two students would have their preferences better met if they were swapped), perform any swaps until matches are as stable as possible.&lt;br /&gt;
&lt;br /&gt;
This algorithm has a time complexity of O(n^2). For more details on this algorithm and its implementation, refer to the previous year's work, where this algorithm was implemented.&lt;br /&gt;
&lt;br /&gt;
===Desired Functionality for Reviews===&lt;br /&gt;
&lt;br /&gt;
The desired feature for reviews should have an almost identical structure to this, with reviews instead of topics. Students should be shown a list of the topics that were worked on, and may bid on which of those topics they would like to review the most. The Priority system could be handled in the same way, with the only caveat being that a student should not be able to review their own work.&lt;br /&gt;
&lt;br /&gt;
In terms of what this feature looks like, it can be enabled as an option when editing/creating a new assignment, under the &amp;quot;Topics&amp;quot; section, using interface drop down show below.&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_interface.png|center|800px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once this option is enabled, during the review phase of an assignment, students will be able to access a new view listing all the topics of all the submitted assignments (except for their own). They will then be able to bid on as many topics as they like, assigning them a preference, in a manner similar to the interface for topic bidding. The table that allows for this drag-and-drop priorities is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_options.png|center|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Whenever the instructor decides they would like to close the window for review bidding, they may return to the options for the given assignment and navigate to &amp;quot;Topics&amp;quot;, where they will see a button marked &amp;quot;Run Review Algorithm&amp;quot;. This will make a call to the external webservice to determine which students are assigned what reviews, and will then assign those reviews to all students. Once this button is pressed, it locks out the ability for students to perform any more bidding, and cannot be pressed again. The button allowing this option is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_run_algorithm.png|center|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After this point, students may navigate to the &amp;quot;Others Work&amp;quot; option under their assignment and see all of their assigned reviews. They will see up to the maximum number of allowed reviews, but will be informed of how many they are required to do (for example, a student may see 4 reviews, but will be told they are only required to complete 2).&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
The following Use Case Diagram demonstrates the primary functionality explained in the previous section for different types of users.&lt;br /&gt;
&lt;br /&gt;
[[File:Use_Case_Diagram_Rev1_E2151.jpg|center]]&lt;br /&gt;
&lt;br /&gt;
==Plan and List of Work Done==&lt;br /&gt;
&lt;br /&gt;
===General Design Goals===&lt;br /&gt;
&lt;br /&gt;
* Move all prior work for this topic into a new version of the expertiza beta branch, without loss in functionality.&lt;br /&gt;
* Ensure all prior/expected functionality is working correctly, and if not, make any repairs or changes necessary.&lt;br /&gt;
* DRY out prior implementation's controller and model methods which have functionality that already exists within the expertiza system.&lt;br /&gt;
* Remove repetitive views and partials that exist by merging views for review bids into the set of views for sign up sheets, from which it uses partials.&lt;br /&gt;
* Ensure all present test cases still work properly after making the above changes.&lt;br /&gt;
&lt;br /&gt;
===Specific Tasks Completed===&lt;br /&gt;
&lt;br /&gt;
* Transferred over all code files relevant to the review bidding feature&lt;br /&gt;
* Re-deployed the external website which handles the review bidding algorithm&lt;br /&gt;
* Added that website's url to the webservices url's within expertiza&lt;br /&gt;
* Enhanced the stability of the webservice for the bidding algorithm by testing with edge cases and optimize the endpoint by restoring the original access endpoint reference* Analyzed the necessity of the phase finding related logic code section&lt;br /&gt;
* Optimized phase finding related logic by removing unused code segment&lt;br /&gt;
* Removed an instance variable within the ''review_bids_controller'' which would have made any practical deployment fail, removing the unnecessary functionality it was created for&lt;br /&gt;
* Updated method calls to ''assignment.find_current_stage'' to their new form ''assignment.current_stage''&lt;br /&gt;
* Removed the review_bid model method ''self.reviewer_self_topic'' and replaced its usage with the already-existing ''SignedUpTeam.topic_id'' method&lt;br /&gt;
* Removed DRY-violating code used to calculate the current assignment phase which was never utilized by the controller or views&lt;br /&gt;
* Moved several view files from the ''review_bids'' view directory into the ''sign_up_sheet'' view directory. Partials which were duplicates in the two directories (''_all_actions.html.erb'' and ''_topic_names.html.erb'' were no longer necessary and deleted&lt;br /&gt;
* Refactored the naming of the variable that represents the id of the reviewer object from 'reviewer' to 'reviewer_id' for clarity&lt;br /&gt;
* Removed the unnecessary 'create' function within the review_bids_controller&lt;br /&gt;
* Removed the sparse testing files under the 'test' directory in keeping with typical expertiza structure&lt;br /&gt;
* Removed a test case from the unit tests which relied upon the removed 'create' method of the review_bids_controller&lt;br /&gt;
&lt;br /&gt;
==Initial Implementation==&lt;br /&gt;
&lt;br /&gt;
A considerable amount of time and effort was necessary to review, understand, and re-implement the previous implementation of the Review Bidding feature. While the feature was only created a year ago, several underlying functions and methods have since been refactored, and so needed to be changed in the implementation. Additionally, certain parts of how the implementation was designed did not seem to be properly implemented, and so had to be revised.&lt;br /&gt;
&lt;br /&gt;
===Code Transfer===&lt;br /&gt;
First, all files that were added in the original pull request were copied and moved to the new version of the expertiza beta branch. This includes the following files:&lt;br /&gt;
&lt;br /&gt;
*'''controllers/review_bids_controller.rb''': the primary controller that handles calls to review bids functionality from views, managing them itself or directing them to the appropriate model&lt;br /&gt;
*'''helpers/review_bids_helper.rb''': contains helper methods for rendering the rows of topics available to choose a review for&lt;br /&gt;
*'''models/review_bid.rb''': contains the methods that each individual review bid knows and manages, including assigning a review to a student, getting info on the topic it applies to, etc.&lt;br /&gt;
*'''views/review_bids/_all_actions.html.erb''': a view partial used to render the actions available to a student on the review bidding view. Nearly identical to the _all_actions file for topic bidding.&lt;br /&gt;
*'''views/review_bids/_table_header.html.erb''': a view partial used to render the head of the table for review bids. Though structurally similar to that of topics reviews, contains significantly less information, as less needs to be known by a student for particular topics to review.&lt;br /&gt;
*'''views/review_bids/_table_line.html.erb''': a view partial used to render individual rows of the review bids table. Like the table header, is structurally similar to that of topic bidding, but functions differently.&lt;br /&gt;
*'''views/review_bids/show.html.erb''': the view which displays all the available topics to bid on reviewing. Uses the aforementioned partials to render this bidding table.&lt;br /&gt;
*'''views/review_bids/others_work.html.erb''': displays the available review work which has the user has bid for.&lt;br /&gt;
*'''db/migrate/20201107203204_create_review_bids.rb''': the migration which creates the review bid objects within the expertiza database.&lt;br /&gt;
*'''spec/controllers/review_bids_controller_spec.rb''': the unit tests for the review bids controller&lt;br /&gt;
*'''spec/models/review_bid_spec.rb''': the unit tests for the review bids model&lt;br /&gt;
*'''test/controllers/review_bids_controller_test.rb''': a more elaborate feature test for the review bids functionality&lt;br /&gt;
*'''test/fixtures/review_bids.yml''': fixtures that are utilized for the review_bids_controller_test&lt;br /&gt;
*'''test/models/review_bid_test.rb''': A more elaborate feature test of the review bid model.&lt;br /&gt;
&lt;br /&gt;
In addition to adding the previous files, the following files were also added to existing pages as modifications:&lt;br /&gt;
&lt;br /&gt;
*'''controllers/student_review_controller.rb''': the student review controller's &amp;quot;list&amp;quot; method now redirects to the review_bid_controller's &amp;quot;index&amp;quot; method if the assignment in question has a review_choosing_algorithm set to &amp;quot;Bidding&amp;quot; (the option an instructor sets when they wish to allow students to bid on reviews).&lt;br /&gt;
*'''student_task/view.html.erb''': Instead of simply linking directly to the student_review controller's &amp;quot;list&amp;quot; method, the view instead checks if the assignment this view pertains to has their review_choosing_algorithm set to Bidding. If it does, and the assignment allows students to choose the topic to review (meaning the algorithm to assign bids has not yet been run), they are redirected to the 'show' method of the review_bids_controller. Otherwise, they are redirected to the 'index' method (showing them the info on their currently available topics to review).&lt;br /&gt;
*'''config/webservices.yml''': added a new url for the website that is called to run the review bidding algorithm&lt;br /&gt;
*'''config/routes.rb''': routes added for review_bids.&lt;br /&gt;
*'''views/assignments/edit/_topics.html.erb''': Added a new option box which allows an instructor to choose to allow bidding to occur using the review bidding algorithm, rather than the default 'Simple Choose.' Once this option is selected, it also offers a button that, when clicked, runs the review bidding algorithm on all currently bid upon reviews.&lt;br /&gt;
&lt;br /&gt;
===Website Reimplementation===&lt;br /&gt;
In the previous implementation, the algorithm which handles the assigning of reviews was hosted on an external website. This was done for the sake of improved performance. Thus, to get the feature in working condition, we pulled the code necessary to run the algorithm and hosted it on our own website (linked at the end of this documentation). We also made a note in the pull request that the place where this website is referenced (in the &amp;quot;assign_reviews_algorithm&amp;quot; method of the review_bids_controller) should be replaced by a proper external web tool, as is done for similar web tools in other parts of expertiza.&lt;br /&gt;
&lt;br /&gt;
===Modifications to Methods===&lt;br /&gt;
Certain methods utilized in the original version of the webpages were changed or renamed in later versions, and so, needed to be modified. The primary example of this is the method that assignments use to determine what stage of assignment completion they are in. The previous year's implementation called this method as &amp;quot;assignment.find_current_stage(topic_id),&amp;quot; but this failed when trying to execute. After comparing how this page worked to how normal review pages work, we determined the new call to this method is &amp;quot;assignment.current_stage(topic_id).&amp;quot; All calls to this method were replaced in all files.&lt;br /&gt;
&lt;br /&gt;
Another change to methods was the removal of a method from the review_bids_controller named 'create'. This method primarily served as a redirect for an aspect of the feature that was unnecessary and so removed (see the following section), that being the button to show another review. With this feature removed, this method was no longer used, and so it was removed from the controller.&lt;br /&gt;
&lt;br /&gt;
===Errors Corrected===&lt;br /&gt;
A notable period of time was also spent on determining the purpose of a particular local area that caused issues when trying to view the bids, that being a variable named &amp;quot;@number_of_reviews_to_show&amp;quot;. This variable apparently kept track of how many reviews a student needed to be shown, so that they could request another. The issue was that this was created as a local variable within the review_bids_controller, and therefore would never work outside of a manual testing environment, as the variable would need to be different from every student and every assignment. After some investigation, we realized that all this variable did was limit the number of already-assigned reviews the student was able to see (as the review bidding algorithm already assigned all possible reviews). Thus, rather than try to recreate this functionality, we simply removed it.&lt;br /&gt;
&lt;br /&gt;
This means that, when the review bidding algorithm runs, a student is able to see all of the reviews assigned to them, up to the maximum number of reviews for the assignment, and therefore have no reason to ask for any more. It may be the case that this feature could be improved by adding a possibility for students to request any reviews not assigned to any other student, or that still have available slots, using the &amp;quot;normal&amp;quot; review assignment scheme. For the time being, we did not consider this part of the baseline necessary functionality, and so did not implement it.&lt;br /&gt;
&lt;br /&gt;
==Refinement Implementation==&lt;br /&gt;
&lt;br /&gt;
===DRY Principle and Code Duplication Refactoring===&lt;br /&gt;
Per comments and feedbacks on the previous implementation [https://github.com/expertiza/expertiza/pull/1822 E2085], there were 3 sections of the code that potentially were DRY violations. For each of those violations, we have had made appropriate and provided the justification on the results.&lt;br /&gt;
&lt;br /&gt;
====review_bids_controller.rb====&lt;br /&gt;
For the refactoring of review bids controller.eb, the original issue is the DRY principle violation on the internal logic of finding the phase of assignments.&lt;br /&gt;
The original implementation to be refactored and optimized are shown as follow.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # Finding the current phase that we are in&lt;br /&gt;
    due_dates = AssignmentDueDate.where(parent_id: @assignment.id)&lt;br /&gt;
    @very_last_due_date = AssignmentDueDate.where(parent_id: @assignment.id).order(&amp;quot;due_at DESC&amp;quot;).limit(1)&lt;br /&gt;
    next_due_date = @very_last_due_date[0]&lt;br /&gt;
    for due_date in due_dates&lt;br /&gt;
      if due_date.due_at &amp;gt; Time.now&lt;br /&gt;
        next_due_date = due_date if due_date.due_at &amp;lt; next_due_date.due_at&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    @review_phase = next_due_date.deadline_type_id&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Through some discovery process, we have found some related logics that is already implemented from the system which enable the refactoring and reuse of the method. Some code snippets are demonstrated as follow.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.current_due_date(due_dates)&lt;br /&gt;
    #Get the current due date from list of due dates&lt;br /&gt;
    due_dates.each do |due_date|&lt;br /&gt;
      if due_date.due_at &amp;gt; Time.now&lt;br /&gt;
        current_due_date = due_date&lt;br /&gt;
        return current_due_date&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    #in case current due date not found&lt;br /&gt;
    return nil &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.teammate_review_allowed(student)&lt;br /&gt;
    # time when teammate review is allowed&lt;br /&gt;
    due_date = current_due_date(student.assignment.due_dates)&lt;br /&gt;
    student.assignment.find_current_stage == 'Finished' ||&lt;br /&gt;
    due_date &amp;amp;&amp;amp;&lt;br /&gt;
    (due_date.teammate_review_allowed_id == 3 ||&lt;br /&gt;
    due_date.teammate_review_allowed_id == 2) # late(2) or yes(3)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As we can observed above, both methods of &amp;lt;code&amp;gt;current_due_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;teammate_review_allowed&amp;lt;/code&amp;gt; provides the capability of getting the &amp;lt;code&amp;gt;review_phase&amp;lt;/code&amp;gt; without the repetition. Additionally, we can see that those existing implementation still have some difference in implementation and purpose to be fully reusable by the logic that find current phase of a topic because the methods provided are helper methods for broader abstraction.&lt;br /&gt;
&lt;br /&gt;
Furthermore, the section that we attempted to refactoring out have a similar logic that is used to get the current stage as shown below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def find_current_stage(topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(self.id, topic_id)&lt;br /&gt;
    return 'Finished' if next_due_date.nil?&lt;br /&gt;
    next_due_date&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
However, it is worth pointing out that the method is not fully substitutable, particularly the internal functionality that finds the &amp;lt;code&amp;gt;@very_last_due_date&amp;lt;/code&amp;gt;. A similar logic does exist that is meant to use to acquire current due date and assist with finding current stage.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def current_stage_name(topic_id = nil)&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      return (topic_id.nil? ? 'Unknown' : current_stage(topic_id))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    due_date = find_current_stage(topic_id)&lt;br /&gt;
    unless due_date == 'Finished' || due_date.nil? || due_date.deadline_name.nil?&lt;br /&gt;
      return due_date.deadline_name&lt;br /&gt;
    end&lt;br /&gt;
    current_stage(topic_id)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
With all the findings, we have come to conclusion that the portion of the code to be dry is in similar, but required full restructure, form of existing methods. The internal logic flow itself is not fully matching the reusable methods consists across the controllers. Because of the clarity of limited reusability of existing methods, we have come to conclusion that the portions to be refactored are not duplication of any existing methods. Additionally, after a more detailed discovery, it has come to realization that the code portion of getting the current phase of the next due date was, in fact, meant to find the last due date. After further analysis of the purpose of the code, the portion has been deleted from &amp;lt;code&amp;gt;review_bids_controller.rb&amp;lt;/code&amp;gt; because there was no usage observed with the result of the execution.&lt;br /&gt;
&lt;br /&gt;
====review_bid.rb====&lt;br /&gt;
Per the previous iteration's feedback, the review_bid.rb model file presented some DRY violations. These violations are highlighted in the method below:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:review_bid_original.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Refactoring Views (_all_actions.html.erb and _topic_names.html.erb)====&lt;br /&gt;
The last element of the prior implementation that caused DRY violations had to do with its implementation of views. Two primary views are necessary for the review bids functionality: one which shows a table where students can bid on which topic they wish to review (rendered by a file called 'show.html.erb'), and a list of assigned reviews which a student must select from (rendered by a file called 'others_work.html.erb'). &lt;br /&gt;
&lt;br /&gt;
In order to render the elements in 'show.html.erb' in particular, a number of partials must be utilized:&lt;br /&gt;
*a partial for the table's header (_table_header.html.erb)&lt;br /&gt;
*a partial for rendering each of the table's rows, describing a topic to bid on (_table_line.html.erb)&lt;br /&gt;
*a partial to contain information related to what actions are available for a student to do for a review, like edit or view (_all_actions.html.erb)&lt;br /&gt;
*a partial for finding and rendering the name of each topic one must review (_topic_names.html.erb)&lt;br /&gt;
&lt;br /&gt;
Both of these views and all four of these partials were contained within the &amp;quot;review_bids&amp;quot; directory within the views directory. The DRY violation incurred by these views has to do with these partials: in particular, '_topic_names.html.erb' and '_all_actions.html.erb' are near identical code copies to those within the sign_up_sheet views, used for rendering and displaying information for topic bidding and normal reviews.&lt;br /&gt;
&lt;br /&gt;
In order to DRY out this portion of the code, we decided that having a separate set of views for the results related to review bids were unnecessary. Within expertiza's structure, most of the views related to students choosing which topics or reviews to work on are all contained within the sign_up_sheet views. The review_vids views were copying the partials within the sign_up_sheet views because they were using the same fundamental components. Thus, we thought the best solution would be to move the two primary views for review_bids ('show.html.erb' and 'others_work.html.erb') into the sign_up_sheet views, and leave behind all redundant partials. In doing so, the redundancy of '_all_actions.html.erb' and '_topic_names.html.erb' were eliminated.&lt;br /&gt;
&lt;br /&gt;
It could be argued that this implementation could be further DRY-ed by leaving behind the other two partials, '_table_header.html.erb' and '_table_line.html.erb', as they are structurally similar to those used for topic bidding. However, this is not actually permissible, as the header and lines for topics when bidding on them for reviews are significantly different than when bidding on them for assignments. More information needs to be available when bidding on topics for an assignment, such as the number of slots and number on the waitlist, but such an idea is not applicable for bids on reviews. While it would be possible to have a single file which produces one view or another depending upon if it's bidding for topics or reviews, we believed this violated the Expert Pattern, by attempting to create a single view for two distinct purposes. Instead, we thought it better to simply have two separate partials, each which precisely gave the desired functionality. Thus, the other two partials were brought over, being renamed '_review_bids_table_header.html.erb' and '_review_bids_table_line.html.erb'.&lt;br /&gt;
&lt;br /&gt;
==Tests==&lt;br /&gt;
&lt;br /&gt;
Throughout the refactoring and merging of [https://github.com/expertiza/expertiza/pull/1822 E2085] to [https://github.com/expertiza/expertiza/pull/2150 E2151], there were some updates that has been made to the test suits to maintain corrosponding testing automation.&lt;br /&gt;
&lt;br /&gt;
===Video Demonstration===&lt;br /&gt;
[https://www.youtube.com/watch?v=wxXALQNWFcc Click this link] to see a video demonstrating the functionality of the review bidding feature.&lt;br /&gt;
&lt;br /&gt;
===RSpec Testing===&lt;br /&gt;
One of the primary design goals when doing this refactoring was to ensure that all test cases still passed after all changes were made.&lt;br /&gt;
&lt;br /&gt;
There was a single change that needed to be made to the RSpec files for the review bidding algorithm, which was the removal of a test relying on the 'create' method of the review_bids_controller. As previously mentioned, this function was removed because it had become obsolete. Thus, the test case for this function (which simply checked if it redirected to the right page) was no longer necessary, and thus was deleted.&lt;br /&gt;
&lt;br /&gt;
Otherwise, the test cases for both the review_bids_controller and the review_bids model were manually run and found to have no errors, as shown below.&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_test_results.png|800px]]&lt;br /&gt;
&lt;br /&gt;
For details on what these specific tests were, please refer to the previous work referenced before.&lt;br /&gt;
&lt;br /&gt;
==Conclusions and Future Work==&lt;br /&gt;
While the current state of the review bidding code is operational, and is certainly more DRY and stable than the previous incarnation of this work, there are still several issues with the current state of this feature that make it difficult to recommend an immediate merge into expertiza.&lt;br /&gt;
&lt;br /&gt;
===Enhancement of Algorithm Service Stability===&lt;br /&gt;
&lt;br /&gt;
Across the process of refining the refactored front end page view along with more robust edge cases testing towards the algorithm service, we have discovered an underlying issue that could impact the availability of the review bidding algorithm service. Through cause isolation, we have observed a high correlation to flask application crash with the edge case scenario input where the algorithm service is trying to match a student who was not signed up with any topic with other students.&lt;br /&gt;
&lt;br /&gt;
Because the scope of our project was focused on refactoring, we did not have the time or prior warning to need to address these edge cases. However, we will provide the error log for the reference of any future teams who may work on the stability improvement of the algorithm service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;POST /match_topics HTTP/1.1&amp;quot; 500 -&lt;br /&gt;
{'tid': [5133, 5134, 5135, None], 'users': {'45514': {'otid': 5135, 'tid': [5133, 5134], 'time': ['2021-11-30T17:57:20.000-05:00', '2021-11-30T17:57:24.000-05:00'], 'priority': [2, 1]}, '45513': {'otid': 5134, 'tid': [5133, 5135], 'time': ['2021-11-30T17:57:41.000-05:00', '2021-11-30T17:57:43.000-05:00'], 'priority': [2, 1]}, '45512': {'otid': 5133, 'tid': [5134, 5135], 'time': ['2021-11-30T17:57:58.000-05:00', '2021-11-30T17:58:00.000-05:00'], 'priority': [2, 1]}, '45515': {'otid': None, 'tid': [], 'time': [0], 'priority': [3, 1, 4, 2]}}, 'max_accepted_proposals': 3}&lt;br /&gt;
[2021-11-28 18:10:40,576] ERROR in app: Exception on /match_topics [POST]&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 2447, in wsgi_app&lt;br /&gt;
    response = self.full_dispatch_request()&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1952, in full_dispatch_request&lt;br /&gt;
    rv = self.handle_user_exception(e)&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1821, in handle_user_exception&lt;br /&gt;
    reraise(exc_type, exc_value, tb)&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/_compat.py&amp;quot;, line 39, in reraise&lt;br /&gt;
    raise value&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1950, in full_dispatch_request&lt;br /&gt;
    rv = self.dispatch_request()&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1936, in dispatch_request&lt;br /&gt;
    return self.view_functions[rule.endpoint](**req.view_args)&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/app.py&amp;quot;, line 19, in topic_matching&lt;br /&gt;
    return jsonify(assigned_topics_model.get_student_topic_matches())&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/topics_matcher.py&amp;quot;, line 57, in get_student_topic_matches&lt;br /&gt;
    student.accept_proposal()&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/student.py&amp;quot;, line 24, in accept_proposal&lt;br /&gt;
    self.proposals.sort(key=lambda proposal: self.choices.index(proposal))&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/student.py&amp;quot;, line 24, in &amp;lt;lambda&amp;gt;&lt;br /&gt;
    self.proposals.sort(key=lambda proposal: self.choices.index(proposal))&lt;br /&gt;
ValueError: None is not in list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As we can see from the additional information provided above, the error is due to an unhandled edge case of attempting to access missing value. Our further observation also concluded that such missing value is due to the fact that one or more to-be-matched students did not have any topic signed up at the time of algorithm execution. To address the issue, a general enhancement can be implemented on the algorithm service side with Flask to increase the crash recovery stability. Further refinement of interaction flow with user in the front end can also reduce the possibility of algorithm service error.&lt;br /&gt;
&lt;br /&gt;
Additional to the unhandled cases from the algorithm service, we also noticed an inconsistency of the system due to the performance limitation of the Heroku deployment.&lt;br /&gt;
&lt;br /&gt;
[[File:Out_of_scope_External-Issue_E2151.gif|frameless|x1000px]]&lt;br /&gt;
&lt;br /&gt;
As we can see from the above recorded screen capture animation, with the exact same input, the output and algorithm service result are unstable. Because of the performance limitation of the Heroku, sometime the Flask app that deployed were overloaded. Furthermore, we have also attempted to deploy on VCL, however, we notice the limitation of VCL deployment that will become offline once the VCL reservation expired. After all, because of the focus of our tasks is on the DRY principal optimization, the external algorithm service can be improved in the future. To access and deploy the algorithm on local environment or another environment, setup guide and resource are available on [https://github.com/uahamedncsu/IntelligentAssignment IntelligentAssignment] repository.&lt;br /&gt;
&lt;br /&gt;
===Lack of Comprehensive Testing===&lt;br /&gt;
&lt;br /&gt;
A notable contradiction that was noticed when working with this project was that the previously-mentioned failed edge cases existed, yet all tests for this feature passed. This is illustrative of the fact that this feature requires better and more exhaustive testing.&lt;br /&gt;
&lt;br /&gt;
When dealing with an issue with so many factors as how students bid on reviews, an extensive suite of edge cases should be considered. Any future project group working on this function should consider the following edge cases to cover:&lt;br /&gt;
* Does a student who does not bid on any reviews still get reviews?&lt;br /&gt;
* Does a student who did not submit anything for their assignment still have a review to bid on?&lt;br /&gt;
* What if there are less assignments to have reviews for than the minimum number required for all students to have the minimum number of reviews?&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
While we believe the current state of this feature is greatly improved, with many of its DRY violations removed and several noteworthy bugs corrected, we believe the feature of allowing students to bid on what to review still needs further development before it is deployed. While the basic functionality is working under ideal situations, the issues mentioned above should be addressed before this feature is put in the hands of actual instructors, as if this feature fails, it could ruin the entire reviewing process for an assignment.&lt;br /&gt;
&lt;br /&gt;
Still, we think there is notable promise to this feature, and it would be a very engaging and interesting feature if deployed successfully, so we believe develop on it should continue until it is ready for deployment.&lt;br /&gt;
&lt;br /&gt;
==Github==&lt;br /&gt;
The Github corresponding to this task is publicly available here: https://github.com/WeiRui-Wang/expertiza&lt;br /&gt;
&lt;br /&gt;
==Contributors==&lt;br /&gt;
This feature was created as part of Dr. Edward Gehringer's &amp;quot;CSC/ECE 517: Object-Oriented Design and Development&amp;quot; class, Fall 2021. The contributors were: Geoff Garrido, Ayush Luthra, and WeiRui Wang. Our project mentor was Luis Delossantos (lgdeloss@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=142151</id>
		<title>CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=142151"/>
		<updated>2021-11-30T01:09:37Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: /* review_bid.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic Overview==&lt;br /&gt;
===Statement of Problem===&lt;br /&gt;
Reviewing is an important stage of learning and improving, both as a reviewer and a reviewee, and so allowing reviewers more freedom and choice in what they review would result in better reviews and more engaged reviewers. However, currently the only way to choose a topic to review is a first-come-first-served basis, penalizing students who do not sign up quickly by not allowing them to review the topics they would be most interesting in engaging with.&lt;br /&gt;
&lt;br /&gt;
A better alternative would be to implement a bidding system, similar to that used for topics, which would allow students to establish preferences for which topics they would most like to review. A good bidding algorithm implementing with this idea would ensure that all students (who care enough to bid) receive a topic to review that they actively want.&lt;br /&gt;
&lt;br /&gt;
A prior project group created a prototype for this function, allowing students to bid on what topics they wanted to review. While the functionality was as desired, the feature was not able to be merged due to having too many DRY violations. Thus, the goal of this topic was to bring this prior implementation into the current version of the expertiza beta branch, and remove these DRY violations, so that it may be merged.&lt;br /&gt;
&lt;br /&gt;
As development continued, it became clear this prototype also had several bugs and issues that made it unable to work under several conditions. Thus, a secondary goal was to fix any issues which existed such that the feature would generally work with the functionality the prior implementation demonstrated.&lt;br /&gt;
&lt;br /&gt;
===Prior Work===&lt;br /&gt;
The prior work which is the basis for this topic is linked here [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review is linked here]. This work was done in Fall of 2020, and as previously mentioned, achieved much of the desired functionality for this task. This prior work will be referenced several times within this documentation, as it has a more comprehensive explanation of the underlying design principles behind the views, controller, model, algorithm, and RSpec tests implemented. These details will only be briefly summarized here. &lt;br /&gt;
&lt;br /&gt;
As previously noted, this prior implementation was rejected due to DRY violations, and so correcting these violations--and explaining how those corrections were done--will be the major focus of this project documentation.&lt;br /&gt;
&lt;br /&gt;
==Explanation of Feature==&lt;br /&gt;
&lt;br /&gt;
===Existing Bidding Functionality for Topics===&lt;br /&gt;
Currently in expertiza, students may bid on which topics they would like to work on. An image showcasing this functionality is given below:&lt;br /&gt;
&lt;br /&gt;
[[File:expected_review_UI.PNG]]&lt;br /&gt;
&lt;br /&gt;
Students may choose a number of topics to bid on, in order of priority, and once the deadline is reached, all students are given a topic.&lt;br /&gt;
&lt;br /&gt;
Behind the scenes, this works by utilizing a modified version of the Gale-Shapely Algorithm. This algorithm seeks to find a 'stable' matching of each student to each topic, such that in the end, all students have a topic they wanted (at least to some degree), and that the preferences of students is respected as well as possible. To help break situations where there are ties in preferences, each topic assigns a Priority to each student. This Priority is determined by A. whether the student is part of a group bidding for this topic (groups getting higher priority), and B. the time at which the bid for the topic was made (earlier bidders are given Priority). Once this has been determined and the deadline for bidding has ended, the following steps occur:&lt;br /&gt;
# Each student is matched with each topic they most prefer.&lt;br /&gt;
# If the number of students assigned to a topic is above the maximum allowed for that topic, the students with the highest Priority are assigned the topic&lt;br /&gt;
# All maximally filled topics are removed from the pool of available topics&lt;br /&gt;
# All unmatched students begin this cycle again, now choosing the most preferred topic remaining&lt;br /&gt;
# Repeat until all students are assigned a topic&lt;br /&gt;
# If any matches are 'unstable' (two students would have their preferences better met if they were swapped), perform any swaps until matches are as stable as possible.&lt;br /&gt;
&lt;br /&gt;
This algorithm has a time complexity of O(n^2). For more details on this algorithm and its implementation, refer to the previous year's work, where this algorithm was implemented.&lt;br /&gt;
&lt;br /&gt;
===Desired Functionality for Reviews===&lt;br /&gt;
&lt;br /&gt;
The desired feature for reviews should have an almost identical structure to this, with reviews instead of topics. Students should be shown a list of the topics that were worked on, and may bid on which of those topics they would like to review the most. The Priority system could be handled in the same way, with the only caveat being that a student should not be able to review their own work.&lt;br /&gt;
&lt;br /&gt;
In terms of what this feature looks like, it can be enabled as an option when editing/creating a new assignment, under the &amp;quot;Topics&amp;quot; section, using interface drop down show below.&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_interface.png|center|800px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once this option is enabled, during the review phase of an assignment, students will be able to access a new view listing all the topics of all the submitted assignments (except for their own). They will then be able to bid on as many topics as they like, assigning them a preference, in a manner similar to the interface for topic bidding. The table that allows for this drag-and-drop priorities is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_options.png|center|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Whenever the instructor decides they would like to close the window for review bidding, they may return to the options for the given assignment and navigate to &amp;quot;Topics&amp;quot;, where they will see a button marked &amp;quot;Run Review Algorithm&amp;quot;. This will make a call to the external webservice to determine which students are assigned what reviews, and will then assign those reviews to all students. Once this button is pressed, it locks out the ability for students to perform any more bidding, and cannot be pressed again. The button allowing this option is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_run_algorithm.png|center|900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After this point, students may navigate to the &amp;quot;Others Work&amp;quot; option under their assignment and see all of their assigned reviews. They will see up to the maximum number of allowed reviews, but will be informed of how many they are required to do (for example, a student may see 4 reviews, but will be told they are only required to complete 2).&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
The following Use Case Diagram demonstrates the primary functionality explained in the previous section for different types of users.&lt;br /&gt;
&lt;br /&gt;
[[File:Use_Case_Diagram_Rev1_E2151.jpg|center]]&lt;br /&gt;
&lt;br /&gt;
==Plan and List of Work Done==&lt;br /&gt;
&lt;br /&gt;
===General Design Goals===&lt;br /&gt;
&lt;br /&gt;
* Move all prior work for this topic into a new version of the expertiza beta branch, without loss in functionality.&lt;br /&gt;
* Ensure all prior/expected functionality is working correctly, and if not, make any repairs or changes necessary.&lt;br /&gt;
* DRY out prior implementation's controller and model methods which have functionality that already exists within the expertiza system.&lt;br /&gt;
* Remove repetitive views and partials that exist by merging views for review bids into the set of views for sign up sheets, from which it uses partials.&lt;br /&gt;
* Ensure all present test cases still work properly after making the above changes.&lt;br /&gt;
&lt;br /&gt;
===Specific Tasks Completed===&lt;br /&gt;
&lt;br /&gt;
* Transferred over all code files relevant to the review bidding feature&lt;br /&gt;
* Re-deployed the external website which handles the review bidding algorithm&lt;br /&gt;
* Added that website's url to the webservices url's within expertiza&lt;br /&gt;
* Enhanced the stability of the webservice for the bidding algorithm by testing with edge cases and optimize the endpoint by restoring the original access endpoint reference* Analyzed the necessity of the phase finding related logic code section&lt;br /&gt;
* Optimized phase finding related logic by removing unused code segment&lt;br /&gt;
* Removed an instance variable within the ''review_bids_controller'' which would have made any practical deployment fail, removing the unnecessary functionality it was created for&lt;br /&gt;
* Updated method calls to ''assignment.find_current_stage'' to their new form ''assignment.current_stage''&lt;br /&gt;
* Removed the review_bid model method ''self.reviewer_self_topic'' and replaced its usage with the already-existing ''SignedUpTeam.topic_id'' method&lt;br /&gt;
* Removed DRY-violating code used to calculate the current assignment phase which was never utilized by the controller or views&lt;br /&gt;
* Moved several view files from the ''review_bids'' view directory into the ''sign_up_sheet'' view directory. Partials which were duplicates in the two directories (''_all_actions.html.erb'' and ''_topic_names.html.erb'' were no longer necessary and deleted&lt;br /&gt;
* Refactored the naming of the variable that represents the id of the reviewer object from 'reviewer' to 'reviewer_id' for clarity&lt;br /&gt;
* Removed the unnecessary 'create' function within the review_bids_controller&lt;br /&gt;
* Removed the sparse testing files under the 'test' directory in keeping with typical expertiza structure&lt;br /&gt;
* Removed a test case from the unit tests which relied upon the removed 'create' method of the review_bids_controller&lt;br /&gt;
&lt;br /&gt;
==Initial Implementation==&lt;br /&gt;
&lt;br /&gt;
A considerable amount of time and effort was necessary to review, understand, and re-implement the previous implementation of the Review Bidding feature. While the feature was only created a year ago, several underlying functions and methods have since been refactored, and so needed to be changed in the implementation. Additionally, certain parts of how the implementation was designed did not seem to be properly implemented, and so had to be revised.&lt;br /&gt;
&lt;br /&gt;
===Code Transfer===&lt;br /&gt;
First, all files that were added in the original pull request were copied and moved to the new version of the expertiza beta branch. This includes the following files:&lt;br /&gt;
&lt;br /&gt;
*'''controllers/review_bids_controller.rb''': the primary controller that handles calls to review bids functionality from views, managing them itself or directing them to the appropriate model&lt;br /&gt;
*'''helpers/review_bids_helper.rb''': contains helper methods for rendering the rows of topics available to choose a review for&lt;br /&gt;
*'''models/review_bid.rb''': contains the methods that each individual review bid knows and manages, including assigning a review to a student, getting info on the topic it applies to, etc.&lt;br /&gt;
*'''views/review_bids/_all_actions.html.erb''': a view partial used to render the actions available to a student on the review bidding view. Nearly identical to the _all_actions file for topic bidding.&lt;br /&gt;
*'''views/review_bids/_table_header.html.erb''': a view partial used to render the head of the table for review bids. Though structurally similar to that of topics reviews, contains significantly less information, as less needs to be known by a student for particular topics to review.&lt;br /&gt;
*'''views/review_bids/_table_line.html.erb''': a view partial used to render individual rows of the review bids table. Like the table header, is structurally similar to that of topic bidding, but functions differently.&lt;br /&gt;
*'''views/review_bids/show.html.erb''': the view which displays all the available topics to bid on reviewing. Uses the aforementioned partials to render this bidding table.&lt;br /&gt;
*'''views/review_bids/others_work.html.erb''': displays the available review work which has the user has bid for.&lt;br /&gt;
*'''db/migrate/20201107203204_create_review_bids.rb''': the migration which creates the review bid objects within the expertiza database.&lt;br /&gt;
*'''spec/controllers/review_bids_controller_spec.rb''': the unit tests for the review bids controller&lt;br /&gt;
*'''spec/models/review_bid_spec.rb''': the unit tests for the review bids model&lt;br /&gt;
*'''test/controllers/review_bids_controller_test.rb''': a more elaborate feature test for the review bids functionality&lt;br /&gt;
*'''test/fixtures/review_bids.yml''': fixtures that are utilized for the review_bids_controller_test&lt;br /&gt;
*'''test/models/review_bid_test.rb''': A more elaborate feature test of the review bid model.&lt;br /&gt;
&lt;br /&gt;
In addition to adding the previous files, the following files were also added to existing pages as modifications:&lt;br /&gt;
&lt;br /&gt;
*'''controllers/student_review_controller.rb''': the student review controller's &amp;quot;list&amp;quot; method now redirects to the review_bid_controller's &amp;quot;index&amp;quot; method if the assignment in question has a review_choosing_algorithm set to &amp;quot;Bidding&amp;quot; (the option an instructor sets when they wish to allow students to bid on reviews).&lt;br /&gt;
*'''student_task/view.html.erb''': Instead of simply linking directly to the student_review controller's &amp;quot;list&amp;quot; method, the view instead checks if the assignment this view pertains to has their review_choosing_algorithm set to Bidding. If it does, and the assignment allows students to choose the topic to review (meaning the algorithm to assign bids has not yet been run), they are redirected to the 'show' method of the review_bids_controller. Otherwise, they are redirected to the 'index' method (showing them the info on their currently available topics to review).&lt;br /&gt;
*'''config/webservices.yml''': added a new url for the website that is called to run the review bidding algorithm&lt;br /&gt;
*'''config/routes.rb''': routes added for review_bids.&lt;br /&gt;
*'''views/assignments/edit/_topics.html.erb''': Added a new option box which allows an instructor to choose to allow bidding to occur using the review bidding algorithm, rather than the default 'Simple Choose.' Once this option is selected, it also offers a button that, when clicked, runs the review bidding algorithm on all currently bid upon reviews.&lt;br /&gt;
&lt;br /&gt;
===Website Reimplementation===&lt;br /&gt;
In the previous implementation, the algorithm which handles the assigning of reviews was hosted on an external website. This was done for the sake of improved performance. Thus, to get the feature in working condition, we pulled the code necessary to run the algorithm and hosted it on our own website (linked at the end of this documentation). We also made a note in the pull request that the place where this website is referenced (in the &amp;quot;assign_reviews_algorithm&amp;quot; method of the review_bids_controller) should be replaced by a proper external web tool, as is done for similar web tools in other parts of expertiza.&lt;br /&gt;
&lt;br /&gt;
===Modifications to Methods===&lt;br /&gt;
Certain methods utilized in the original version of the webpages were changed or renamed in later versions, and so, needed to be modified. The primary example of this is the method that assignments use to determine what stage of assignment completion they are in. The previous year's implementation called this method as &amp;quot;assignment.find_current_stage(topic_id),&amp;quot; but this failed when trying to execute. After comparing how this page worked to how normal review pages work, we determined the new call to this method is &amp;quot;assignment.current_stage(topic_id).&amp;quot; All calls to this method were replaced in all files.&lt;br /&gt;
&lt;br /&gt;
Another change to methods was the removal of a method from the review_bids_controller named 'create'. This method primarily served as a redirect for an aspect of the feature that was unnecessary and so removed (see the following section), that being the button to show another review. With this feature removed, this method was no longer used, and so it was removed from the controller.&lt;br /&gt;
&lt;br /&gt;
===Errors Corrected===&lt;br /&gt;
A notable period of time was also spent on determining the purpose of a particular local area that caused issues when trying to view the bids, that being a variable named &amp;quot;@number_of_reviews_to_show&amp;quot;. This variable apparently kept track of how many reviews a student needed to be shown, so that they could request another. The issue was that this was created as a local variable within the review_bids_controller, and therefore would never work outside of a manual testing environment, as the variable would need to be different from every student and every assignment. After some investigation, we realized that all this variable did was limit the number of already-assigned reviews the student was able to see (as the review bidding algorithm already assigned all possible reviews). Thus, rather than try to recreate this functionality, we simply removed it.&lt;br /&gt;
&lt;br /&gt;
This means that, when the review bidding algorithm runs, a student is able to see all of the reviews assigned to them, up to the maximum number of reviews for the assignment, and therefore have no reason to ask for any more. It may be the case that this feature could be improved by adding a possibility for students to request any reviews not assigned to any other student, or that still have available slots, using the &amp;quot;normal&amp;quot; review assignment scheme. For the time being, we did not consider this part of the baseline necessary functionality, and so did not implement it.&lt;br /&gt;
&lt;br /&gt;
==Refinement Implementation==&lt;br /&gt;
&lt;br /&gt;
===DRY Principle and Code Duplication Refactoring===&lt;br /&gt;
Per comments and feedbacks on the previous implementation [https://github.com/expertiza/expertiza/pull/1822 E2085], there were 3 sections of the code that potentially were DRY violations. For each of those violations, we have had made appropriate and provided the justification on the results.&lt;br /&gt;
&lt;br /&gt;
====review_bids_controller.rb====&lt;br /&gt;
For the refactoring of review bids controller.eb, the original issue is the DRY principle violation on the internal logic of finding the phase of assignments.&lt;br /&gt;
The original implementation to be refactored and optimized are shown as follow.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # Finding the current phase that we are in&lt;br /&gt;
    due_dates = AssignmentDueDate.where(parent_id: @assignment.id)&lt;br /&gt;
    @very_last_due_date = AssignmentDueDate.where(parent_id: @assignment.id).order(&amp;quot;due_at DESC&amp;quot;).limit(1)&lt;br /&gt;
    next_due_date = @very_last_due_date[0]&lt;br /&gt;
    for due_date in due_dates&lt;br /&gt;
      if due_date.due_at &amp;gt; Time.now&lt;br /&gt;
        next_due_date = due_date if due_date.due_at &amp;lt; next_due_date.due_at&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    @review_phase = next_due_date.deadline_type_id&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Through some discovery process, we have found some related logics that is already implemented from the system which enable the refactoring and reuse of the method. Some code snippets are demonstrated as follow.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.current_due_date(due_dates)&lt;br /&gt;
    #Get the current due date from list of due dates&lt;br /&gt;
    due_dates.each do |due_date|&lt;br /&gt;
      if due_date.due_at &amp;gt; Time.now&lt;br /&gt;
        current_due_date = due_date&lt;br /&gt;
        return current_due_date&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    #in case current due date not found&lt;br /&gt;
    return nil &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.teammate_review_allowed(student)&lt;br /&gt;
    # time when teammate review is allowed&lt;br /&gt;
    due_date = current_due_date(student.assignment.due_dates)&lt;br /&gt;
    student.assignment.find_current_stage == 'Finished' ||&lt;br /&gt;
    due_date &amp;amp;&amp;amp;&lt;br /&gt;
    (due_date.teammate_review_allowed_id == 3 ||&lt;br /&gt;
    due_date.teammate_review_allowed_id == 2) # late(2) or yes(3)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As we can observed above, both methods of &amp;lt;code&amp;gt;current_due_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;teammate_review_allowed&amp;lt;/code&amp;gt; provides the capability of getting the &amp;lt;code&amp;gt;review_phase&amp;lt;/code&amp;gt; without the repetition. Additionally, we can see that those existing implementation still have some difference in implementation and purpose to be fully reusable by the logic that find current phase of a topic because the methods provided are helper methods for broader abstraction.&lt;br /&gt;
&lt;br /&gt;
Furthermore, the section that we attempted to refactoring out have a similar logic that is used to get the current stage as shown below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def find_current_stage(topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(self.id, topic_id)&lt;br /&gt;
    return 'Finished' if next_due_date.nil?&lt;br /&gt;
    next_due_date&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
However, it is worth pointing out that the method is not fully substitutable, particularly the internal functionality that finds the &amp;lt;code&amp;gt;@very_last_due_date&amp;lt;/code&amp;gt;. A similar logic does exist that is meant to use to acquire current due date and assist with finding current stage.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def current_stage_name(topic_id = nil)&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      return (topic_id.nil? ? 'Unknown' : current_stage(topic_id))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    due_date = find_current_stage(topic_id)&lt;br /&gt;
    unless due_date == 'Finished' || due_date.nil? || due_date.deadline_name.nil?&lt;br /&gt;
      return due_date.deadline_name&lt;br /&gt;
    end&lt;br /&gt;
    current_stage(topic_id)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
With all the findings, we have come to conclusion that the portion of the code to be dry is in similar, but required full restructure, form of existing methods. The internal logic flow itself is not fully matching the reusable methods consists across the controllers. Because of the clarity of limited reusability of existing methods, we have come to conclusion that the portions to be refactored are not duplication of any existing methods. Additionally, after a more detailed discovery, it has come to realization that the code portion of getting the current phase of the next due date was, in fact, meant to find the last due date. After further analysis of the purpose of the code, the portion has been deleted from &amp;lt;code&amp;gt;review_bids_controller.rb&amp;lt;/code&amp;gt; because there was no usage observed with the result of the execution.&lt;br /&gt;
&lt;br /&gt;
====review_bid.rb====&lt;br /&gt;
Per the previous iteration's feedback, the review_bid.rb model file presented some DRY violations. These violations are highlighted in the method below:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:File.jpg]]&lt;br /&gt;
&amp;lt;br&lt;br /&gt;
&lt;br /&gt;
====Refactoring Views (_all_actions.html.erb and _topic_names.html.erb)====&lt;br /&gt;
The last element of the prior implementation that caused DRY violations had to do with its implementation of views. Two primary views are necessary for the review bids functionality: one which shows a table where students can bid on which topic they wish to review (rendered by a file called 'show.html.erb'), and a list of assigned reviews which a student must select from (rendered by a file called 'others_work.html.erb'). &lt;br /&gt;
&lt;br /&gt;
In order to render the elements in 'show.html.erb' in particular, a number of partials must be utilized:&lt;br /&gt;
*a partial for the table's header (_table_header.html.erb)&lt;br /&gt;
*a partial for rendering each of the table's rows, describing a topic to bid on (_table_line.html.erb)&lt;br /&gt;
*a partial to contain information related to what actions are available for a student to do for a review, like edit or view (_all_actions.html.erb)&lt;br /&gt;
*a partial for finding and rendering the name of each topic one must review (_topic_names.html.erb)&lt;br /&gt;
&lt;br /&gt;
Both of these views and all four of these partials were contained within the &amp;quot;review_bids&amp;quot; directory within the views directory. The DRY violation incurred by these views has to do with these partials: in particular, '_topic_names.html.erb' and '_all_actions.html.erb' are near identical code copies to those within the sign_up_sheet views, used for rendering and displaying information for topic bidding and normal reviews.&lt;br /&gt;
&lt;br /&gt;
In order to DRY out this portion of the code, we decided that having a separate set of views for the results related to review bids were unnecessary. Within expertiza's structure, most of the views related to students choosing which topics or reviews to work on are all contained within the sign_up_sheet views. The review_vids views were copying the partials within the sign_up_sheet views because they were using the same fundamental components. Thus, we thought the best solution would be to move the two primary views for review_bids ('show.html.erb' and 'others_work.html.erb') into the sign_up_sheet views, and leave behind all redundant partials. In doing so, the redundancy of '_all_actions.html.erb' and '_topic_names.html.erb' were eliminated.&lt;br /&gt;
&lt;br /&gt;
It could be argued that this implementation could be further DRY-ed by leaving behind the other two partials, '_table_header.html.erb' and '_table_line.html.erb', as they are structurally similar to those used for topic bidding. However, this is not actually permissible, as the header and lines for topics when bidding on them for reviews are significantly different than when bidding on them for assignments. More information needs to be available when bidding on topics for an assignment, such as the number of slots and number on the waitlist, but such an idea is not applicable for bids on reviews. While it would be possible to have a single file which produces one view or another depending upon if it's bidding for topics or reviews, we believed this violated the Expert Pattern, by attempting to create a single view for two distinct purposes. Instead, we thought it better to simply have two separate partials, each which precisely gave the desired functionality. Thus, the other two partials were brought over, being renamed '_review_bids_table_header.html.erb' and '_review_bids_table_line.html.erb'.&lt;br /&gt;
&lt;br /&gt;
==Tests==&lt;br /&gt;
&lt;br /&gt;
Throughout the refactoring and merging of [https://github.com/expertiza/expertiza/pull/1822 E2085] to [https://github.com/expertiza/expertiza/pull/2150 E2151], there were some updates that has been made to the test suits to maintain corrosponding testing automation.&lt;br /&gt;
&lt;br /&gt;
===Video Demonstration===&lt;br /&gt;
[https://www.youtube.com/watch?v=wxXALQNWFcc Click this link] to see a video demonstrating the functionality of the review bidding feature.&lt;br /&gt;
&lt;br /&gt;
===RSpec Testing===&lt;br /&gt;
One of the primary design goals when doing this refactoring was to ensure that all test cases still passed after all changes were made.&lt;br /&gt;
&lt;br /&gt;
There was a single change that needed to be made to the RSpec files for the review bidding algorithm, which was the removal of a test relying on the 'create' method of the review_bids_controller. As previously mentioned, this function was removed because it had become obsolete. Thus, the test case for this function (which simply checked if it redirected to the right page) was no longer necessary, and thus was deleted.&lt;br /&gt;
&lt;br /&gt;
Otherwise, the test cases for both the review_bids_controller and the review_bids model were manually run and found to have no errors, as shown below.&lt;br /&gt;
&lt;br /&gt;
[[File:Bidding_test_results.png|800px]]&lt;br /&gt;
&lt;br /&gt;
For details on what these specific tests were, please refer to the previous work referenced before.&lt;br /&gt;
&lt;br /&gt;
==Conclusions and Future Work==&lt;br /&gt;
While the current state of the review bidding code is operational, and is certainly more DRY and stable than the previous incarnation of this work, there are still several issues with the current state of this feature that make it difficult to recommend an immediate merge into expertiza.&lt;br /&gt;
&lt;br /&gt;
===Enhancement of Algorithm Service Stability===&lt;br /&gt;
&lt;br /&gt;
Across the process of refining the refactored front end page view along with more robust edge cases testing towards the algorithm service, we have discovered an underlying issue that could impact the availability of the review bidding algorithm service. Through cause isolation, we have observed a high correlation to flask application crash with the edge case scenario input where the algorithm service is trying to match a student who was not signed up with any topic with other students.&lt;br /&gt;
&lt;br /&gt;
Because the scope of our project was focused on refactoring, we did not have the time or prior warning to need to address these edge cases. However, we will provide the error log for the reference of any future teams who may work on the stability improvement of the algorithm service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;POST /match_topics HTTP/1.1&amp;quot; 500 -&lt;br /&gt;
{'tid': [5133, 5134, 5135, None], 'users': {'45514': {'otid': 5135, 'tid': [5133, 5134], 'time': ['2021-11-30T17:57:20.000-05:00', '2021-11-30T17:57:24.000-05:00'], 'priority': [2, 1]}, '45513': {'otid': 5134, 'tid': [5133, 5135], 'time': ['2021-11-30T17:57:41.000-05:00', '2021-11-30T17:57:43.000-05:00'], 'priority': [2, 1]}, '45512': {'otid': 5133, 'tid': [5134, 5135], 'time': ['2021-11-30T17:57:58.000-05:00', '2021-11-30T17:58:00.000-05:00'], 'priority': [2, 1]}, '45515': {'otid': None, 'tid': [], 'time': [0], 'priority': [3, 1, 4, 2]}}, 'max_accepted_proposals': 3}&lt;br /&gt;
[2021-11-28 18:10:40,576] ERROR in app: Exception on /match_topics [POST]&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 2447, in wsgi_app&lt;br /&gt;
    response = self.full_dispatch_request()&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1952, in full_dispatch_request&lt;br /&gt;
    rv = self.handle_user_exception(e)&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1821, in handle_user_exception&lt;br /&gt;
    reraise(exc_type, exc_value, tb)&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/_compat.py&amp;quot;, line 39, in reraise&lt;br /&gt;
    raise value&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1950, in full_dispatch_request&lt;br /&gt;
    rv = self.dispatch_request()&lt;br /&gt;
  File &amp;quot;/home/usr/.local/lib/python3.5/site-packages/flask/app.py&amp;quot;, line 1936, in dispatch_request&lt;br /&gt;
    return self.view_functions[rule.endpoint](**req.view_args)&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/app.py&amp;quot;, line 19, in topic_matching&lt;br /&gt;
    return jsonify(assigned_topics_model.get_student_topic_matches())&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/topics_matcher.py&amp;quot;, line 57, in get_student_topic_matches&lt;br /&gt;
    student.accept_proposal()&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/student.py&amp;quot;, line 24, in accept_proposal&lt;br /&gt;
    self.proposals.sort(key=lambda proposal: self.choices.index(proposal))&lt;br /&gt;
  File &amp;quot;/home/usr/IntelligentAssignment/app/student.py&amp;quot;, line 24, in &amp;lt;lambda&amp;gt;&lt;br /&gt;
    self.proposals.sort(key=lambda proposal: self.choices.index(proposal))&lt;br /&gt;
ValueError: None is not in list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As we can see from the additional information provided above, the error is due to an unhandled edge case of attempting to access missing value. Our further observation also concluded that such missing value is due to the fact that one or more to-be-matched students did not have any topic signed up at the time of algorithm execution. To address the issue, a general enhancement can be implemented on the algorithm service side with Flask to increase the crash recovery stability. Further refinement of interaction flow with user in the front end can also reduce the possibility of algorithm service error.&lt;br /&gt;
&lt;br /&gt;
Additional to the unhandled cases from the algorithm service, we also noticed an inconsistency of the system due to the performance limitation of the Heroku deployment.&lt;br /&gt;
&lt;br /&gt;
[[File:Out_of_scope_External-Issue_E2151.gif|frameless|x1000px]]&lt;br /&gt;
&lt;br /&gt;
As we can see from the above recorded screen capture animation, with the exact same input, the output and algorithm service result are unstable. Because of the performance limitation of the Heroku, sometime the Flask app that deployed were overloaded. Furthermore, we have also attempted to deploy on VCL, however, we notice the limitation of VCL deployment that will become offline once the VCL reservation expired. After all, because of the focus of our tasks is on the DRY principal optimization, the external algorithm service can be improved in the future. To access and deploy the algorithm on local environment or another environment, setup guide and resource are available on [https://github.com/uahamedncsu/IntelligentAssignment IntelligentAssignment] repository.&lt;br /&gt;
&lt;br /&gt;
===Lack of Comprehensive Testing===&lt;br /&gt;
&lt;br /&gt;
A notable contradiction that was noticed when working with this project was that the previously-mentioned failed edge cases existed, yet all tests for this feature passed. This is illustrative of the fact that this feature requires better and more exhaustive testing.&lt;br /&gt;
&lt;br /&gt;
When dealing with an issue with so many factors as how students bid on reviews, an extensive suite of edge cases should be considered. Any future project group working on this function should consider the following edge cases to cover:&lt;br /&gt;
* Does a student who does not bid on any reviews still get reviews?&lt;br /&gt;
* Does a student who did not submit anything for their assignment still have a review to bid on?&lt;br /&gt;
* What if there are less assignments to have reviews for than the minimum number required for all students to have the minimum number of reviews?&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
While we believe the current state of this feature is greatly improved, with many of its DRY violations removed and several noteworthy bugs corrected, we believe the feature of allowing students to bid on what to review still needs further development before it is deployed. While the basic functionality is working under ideal situations, the issues mentioned above should be addressed before this feature is put in the hands of actual instructors, as if this feature fails, it could ruin the entire reviewing process for an assignment.&lt;br /&gt;
&lt;br /&gt;
Still, we think there is notable promise to this feature, and it would be a very engaging and interesting feature if deployed successfully, so we believe develop on it should continue until it is ready for deployment.&lt;br /&gt;
&lt;br /&gt;
==Github==&lt;br /&gt;
The Github corresponding to this task is publicly available here: https://github.com/WeiRui-Wang/expertiza&lt;br /&gt;
&lt;br /&gt;
==Contributors==&lt;br /&gt;
This feature was created as part of Dr. Edward Gehringer's &amp;quot;CSC/ECE 517: Object-Oriented Design and Development&amp;quot; class, Fall 2021. The contributors were: Geoff Garrido, Ayush Luthra, and WeiRui Wang. Our project mentor was Luis Delossantos (lgdeloss@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review&amp;diff=141780</id>
		<title>CSC/ECE 517 Fall 2020 - E2085. Allow reviewers to bid on what to review</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review&amp;diff=141780"/>
		<updated>2021-11-28T20:34:59Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: /* Method: assign_review_topics */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Project Overview==&lt;br /&gt;
===   ''Background''   ===&lt;br /&gt;
Assigning reviews to users is a complicated process. Currently, reviews are still assigned using a first-come-first-served basis. However, reviews could be bid on like how topics are bid on. This would involve matching multiple students to review a submission up to the maximum reviewers for a submission.The manual selection process can be replaced with an automated bidding approach for this purpose.&lt;br /&gt;
&lt;br /&gt;
===   ''Objectives''   ===&lt;br /&gt;
# Implement top trading cycles on a web service. &lt;br /&gt;
# Add front end code to allow bidding on topics and call the appropriate web service from the lottery controller. &lt;br /&gt;
# Add working test cases to test the new changes.&lt;br /&gt;
# Code should be inclined to the Beta branch&lt;br /&gt;
# Link to run bidding assignment should be on the page associated with the assignment actions.&lt;br /&gt;
# Code such as getter methods should be added to the model and not the controller.&lt;br /&gt;
#The number of reviews created by default needs to be checked. One way of achieving this is creating minimum reviews and then allowing users to request more reviews if required.&lt;br /&gt;
&lt;br /&gt;
===   ''Previous Work''   ===&lt;br /&gt;
There have been two 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] &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]&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/uahamedncsu/expertiza/tree/beta &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/uahamedncsu/IntelligentAssignment &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/1822 &amp;lt;br&amp;gt;&lt;br /&gt;
''Expertiza Server'': http://152.7.99.70:8081/ &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': https://app-csc517.herokuapp.com/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
''Video Demo'': https://www.screencast.com/t/GJNOcfa9Ln &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;
*config/routes.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*config/webservices.yml&lt;br /&gt;
&lt;br /&gt;
*app/controllers/student_review_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/assignments/edit/_topics.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/student_task/list.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/student_task/view.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*spec/factories/factories.rb &amp;lt;br&amp;gt;&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/controllers/review_bids_controller.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/helpers/review_bids_helper.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/models/review_bid.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/_all_actions.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/_table_header.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/_table_line.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/_topic_names.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/others_work.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/show.html.erb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*db/migrate/20201107203204_create_review_bids.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*spec/controllers/review_bids_controller_spec.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*spec/models/review_bid_spec.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Design==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===   ''User Interface''   ===&lt;br /&gt;
&lt;br /&gt;
Currently, the users are offered the entire list of topics to review and are asked to select a topic to begin a review. Topics that cannot be reviewed or have already been reviewed the maximum number of times are greyed out and cannot be selected. There is also a check box in which the student can select &amp;quot;I don't care which topic I review&amp;quot; and will be randomly assigned a topic from the list. The current User Interface (UI) for this is shown below.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:current_review_UI.PNG]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As discussed in the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Project_Overview Project Overview] section, a bidding system similar to the bidding system used in topic selection is preferable to the current review selection system. The UI for this process will mirror the UI for the topic bidding system. The new UI will allow users to drag a topic from a list of all the topics on the left, to their priority list on the right. The ordering of the right list indicates the priority of the users preference. The colors indicate the likelihood of being assigned that topic. By utilizing the same UI, the consistency of the user experience and the DRY-ness of the code are increased. An example of the topic selection bidding UI is shown below.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:expected_review_UI.PNG]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Currently, an instructor has the option while creating or editing an assignment to allow a reviewers to select the topics they want to review. This is done by checking '''Has teams?''' and '''Has topics?''' in the '''General''' tab of an assignment then checking '''Allow reviewer to choose which topic to review?''' in the '''Topics''' tab. This interface can be used for allowing review bidding either by editing the current check box or adding an additional check box for '''Allow reviewer to bid on topics to review?'''.  &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Instructor_ui_for_review_bidding.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== ''Analyzing the problem'' ===&lt;br /&gt;
&lt;br /&gt;
Currently, the student can either pick a topic or is randomly assigned a topic, from among the ones that are currently eligible to be reviewed. &amp;lt;br&amp;gt;In this scenario, it is possible that some good topics are already picked by a lot of students and if someone is late to do the selecting, they miss out on it since it is grayed out.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To solve the above problem of not getting the topics they like, the participants must be assigned topics based on a list of topics they pre-select. &lt;br /&gt;
This is where an algorithm will come in handy. For picking a suitable algorithm, we should first identify the type of the problem.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Type of problem&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Each student should be able to bid on multiple assignments of their choice and the same assignment can be assigned to multiple participants for review.&amp;lt;br&amp;gt;&lt;br /&gt;
This requires a Many to Many mapping.&lt;br /&gt;
&lt;br /&gt;
                                        [[File:many2.png]]&lt;br /&gt;
&lt;br /&gt;
The algorithm of choice for this type of stable allocations is Gale-Shapely algorithm.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the real world, there are cases where we face this problem:&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt; Student choosing their future universities [https://www.jstor.org/stable/3132114?seq=1&amp;amp;cid=pdf-reference#references_tab_content '''School Choice Problem'''] (One-to-Many)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Men and women seeking each other to create families [https://en.wikipedia.org/wiki/Stable_marriage_problem '''Stable Marriage Problem'''] (One-to-One)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Internet services that need to be connected with users with the smallest amount of time &amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===''Algorithm Implementation for matching students and topics''===&lt;br /&gt;
The Gale-Shapely Algorithm has steps to make sure it is a Stable marriage/allocation.&lt;br /&gt;
An unstable allocation is when the participant does not like the topic assigned to them. &lt;br /&gt;
But it can happen that the participant 1 might like the review topic assigned to participant 2 and participant 2 likes the topic assigned to participant 1.&lt;br /&gt;
This is the unstable case. To make it stable, the topics need to be exchanged between these 2 participants so that both of them get the topic they wanted.&lt;br /&gt;
&lt;br /&gt;
[[File:Snippy2.png]]&lt;br /&gt;
Source: [https://www.journalajrcos.com/index.php/AJRCOS/article/view/24749/46281 Stable Marriage Algorithm]&lt;br /&gt;
&lt;br /&gt;
===''Assignment of priority ''===&lt;br /&gt;
When a student places a bid, the timestamp is recorded. Priority will be given to the earlier bidder. If the student had chosen only very few bids, then this person will be given a higher priority. Any topics that were not selected by the participant are added to bottom of their preference list in a random preference order to create a situation where &amp;lt;b&amp;gt;the number of students and number of topics is equal. &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===''Algorithm Steps ''===&lt;br /&gt;
&amp;lt;li&amp;gt; For the first round, the Algorithm will assign topics to each student based on the Priority and each topic is assigned to a limited number of students based on the Limit. It picks one topic and begins assigning students to it. (Note: The Algorithm makes sure the participant is not in a group that worked on this particular topic.) &lt;br /&gt;
&amp;lt;li&amp;gt;If the one topic is assigned to enough participants already, then it is removed from the queue and the same process is repeated for the next topic. &lt;br /&gt;
&amp;lt;li&amp;gt; As this goes on, all students are matched even if all matches are not stable at this point.&lt;br /&gt;
&amp;lt;li&amp;gt; The Algorithm terminates when all Topics that have not reached the maximum assignment level have tried to accept every student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;The time complexity of this algorithm is O(n^2) &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===''Simulation ''===&lt;br /&gt;
&lt;br /&gt;
[[File:gale-shapeley-1.png]]&lt;br /&gt;
[[File:gale-shapeley-2.png]]&lt;br /&gt;
&lt;br /&gt;
In the simulation above, we have equal number of Students (S1, S2, S3) and Review topics to assign (R1, R2, R3). The students preference of topics is to left of student. The Review topics does not have any preferences. To have preferences, the timestamps are used to determine which student bid on each topic first to create such a Preference list for topics.&lt;br /&gt;
&lt;br /&gt;
# Phase 1: Both Students S1 and S2 have selected R2 as their highest preference. Since there is a conflict, The preference of R2 is checked which shows that S2 had bid earlier than S1. Thus, the topic R2 is assigned to student S2.&lt;br /&gt;
# Phase 2: Now, S1 and S3 both want to review R1 but R1 was first bid on by S1 as shown in the preference. Hence, R1 is assigned to S1.&lt;br /&gt;
# Phase 3: The only topic remaining in this case is R3 which is also on the preference list of Student S3. Therefore S3 is assigned the topic R3.&lt;br /&gt;
#By the end of the 3 phases, All students are assigned to a Review. The same process needs to be repeated till the required number of reviews are assigned to each student. In each iteration, if a review is assigned to max number of students already, the review is removed from consideration.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
This section details the implementation of the code and will highlight each component of the design in the code and its intended purpose, as well as any modifications or testing. As the implementation progresses this section will be updated.&lt;br /&gt;
&lt;br /&gt;
===   ''Overview''   ===&lt;br /&gt;
&lt;br /&gt;
This project was split into 2 objectives, the Expertiza MVC implementation and the webservice algorithm. The Expertiza MVC follows the MVC standard such that the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Controller controller] handles directing the users to the correct views, as well as handling the communication with the webservice. The [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Model model] performs all necessary computations and data handling like the creation and storing of bids on reviews and assigning reviews to students. The [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Views views] render the corresponding webpage based on the actions of the user. The [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Webservice webservice] contains the algorithm outlined in the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Algorithm_Implementation_for_matching_students_and_topics Algorithm Implementation] section of Design. Our Expertiza controller sends this webservice bidding information and the algorithm returns the matched topics to be assigned. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== ''Controller'' ===&lt;br /&gt;
The controller contains 6 methods that perform all the necessary functions. The first method, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_action_allowed? &amp;quot;action_allowed?&amp;quot;] performs authentication checks The second, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_index &amp;quot;index&amp;quot;], is used to redirect the user to a list of assigned reviews after the algorithm has been run. The third, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_show &amp;quot;show&amp;quot;], is used in conjunction with fourth, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_set_priority &amp;quot;set_priority&amp;quot;], to update and store the bids when users make changes in the bidding page. The fifth, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_assign_bidding &amp;quot;assign_bidding&amp;quot;], utilizes the sixth, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_run_bidding_algorithm &amp;quot;run_bidding_algorithm&amp;quot;], to connect to the webservice, send and receive the correct bidding information for the algorithm. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: action_allowed? ======&lt;br /&gt;
This method performs authentication by allowing only certain types of users to access controller methods. The first portion of this method allows users 'Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator', and 'Student' to access the methods 'show', 'set_priority', and 'index'. These are the methods that render the bidding pages and review listings. The other methods are restricted for 'Student' users. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller action allowed..PNG]] &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: index ======&lt;br /&gt;
This method collects all the necessary information about the user, Assignment details, and Review Mapping details to render the 'review_bids/others_work', which lists the reviews that are assigned to the user. This page also includes a button to request more reviews which will add reviews up to the maximum number of reviews. To see the view rendered by this method, please go to [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#View:_others_work.html.erb &amp;quot;others_work&amp;quot;].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_index.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: show ======&lt;br /&gt;
This method renders the bidding page in which participants can select from a table of topics the topics they would prefer to review. It collects the necessary information about the user, Assignment, Topics, and current Review Bids to render this page. It is used in conjunction with [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_set_priority set_priority] where the users bidding information is stored, and the page updated. To see the bidding page that this function renders, visit the view [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#View:_show.html.erb &amp;quot;show&amp;quot;] &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_show.PNG]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: set_priority ======&lt;br /&gt;
In the view file [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#view:_show.html.erb &amp;quot;show&amp;quot;] there exists a line the calls this method when the page is updated or accessed. This method stores the user's bidding information in the schema database. This allows the model to access this information when collecting all the bidding information, as well as allowing users to refresh or return to this page with their selections staying in the bid table. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_set_priority.PNG]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_bidding ======&lt;br /&gt;
This method utilizes methods in the model, as well as the method [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_run_bidding_algorithm &amp;quot;run_bidding_algorithm&amp;quot;] to collect the bidding information of all students of a particular Assignment, send it to the webservice algorithm, store the matched topics that are returned, and pass these matched topics to the model to be assigned. After this method is run, the students should have assigned reviews and bidding should be turned off.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_assign_bidding.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: run_bidding_algorithm ======&lt;br /&gt;
This method connects to the webservice using RestClient API, which is part of the 'require's at the top of the Controller. It will return a false if the connection fails for ay reason such as connection is not established or the algorithm has an internal error, otherwise it returns the matched topics from the algorithm as a 'json'. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_requirements.PNG]] &amp;lt;br&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_run_bidding_algorithm.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== ''Model '' ===&lt;br /&gt;
The model contains 5 methods that are utilized by the controller to save bidding information per user or all users, retrieve bidding information per user or for all users, and assign topics to review to participants.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: get_bidding_data ======&lt;br /&gt;
This method is called by the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_assign_bidding &amp;quot;assign_bidding&amp;quot;] controller method. It receives the Assignment ID and a list of reviewers, which are student IDs. It creates a Hash to store bidding data into and iterates through all of the reviewers, calling [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_reviewer_bidding_data &amp;quot;reviewer_bidding_data&amp;quot;] to get each students bidding data and store it in the Hash. It returns a Hash with all the bidding data needed for the Webservice Algorithm to run.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Model_get_bidding_data.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_review_topics ======&lt;br /&gt;
This method is called by the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_assign_bidding &amp;quot;assign_bidding&amp;quot;] controller method. Given the Assignment ID, list of reviewers, and the matched topics returned by the webservice algorithm, it first clears any previously assigned reviews for that Assignment to prevent multiple assigns, then iterates through each reviewer and assigns them to the topics that the algorithm selected for them.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Model_assign_review_topics.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_topic_to_reviewer ======&lt;br /&gt;
This method is called by the method [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_assign_review_topics &amp;quot;assign_review_topics&amp;quot;] and assigns a single topic to a single user to review given an Assignment ID. &lt;br /&gt;
[[File:Model_assign_topic_to_reviewer.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: reviewer_self_topic ======&lt;br /&gt;
This method returns the topic id of the reviewer that is passed in. This method is utilized to retrieve the reviewers' Topic ID, which is needed for the webservice algorithm to prevent users from being assigned to review their own topic. This is also prevented in views, but this is an additional safety precaution. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Model_reviewer_self_topic.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: reviewer_bidding_data ======&lt;br /&gt;
This method is called by [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_get_bidding_data &amp;quot;get_bidding_data&amp;quot;]. It creates a hash to store all the reviewer's bidding information. It iterates through all the bids for a reviewer given the Assignment ID and it returns a Hash of the bidding data.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Model_reviewer_bidding_data.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== ''Views'' ===&lt;br /&gt;
There are two main views for this project. They are for bidding and for showing assigned reviews after the bidding algorithm has been run. &lt;br /&gt;
====== View: others_work.html.erb ======&lt;br /&gt;
This file renders the view where students see a list of the reviews they've been assigned, with appropriate links and related messages. It includes a &amp;quot;Request Additional Review&amp;quot; button that will allow students to view more reviews up to the max number of reviews allowed. &lt;br /&gt;
[[File:Views_others_work_pt1.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_others_work_pt2.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_others_work_pt3.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_others_work_pt4.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
View rendered by above:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_others_work_rendered.PNG]]&lt;br /&gt;
&lt;br /&gt;
====== View: show.html.erb ======&lt;br /&gt;
This view file renders the Review Bidding page where participants can select which topics to review. It renders partials which are included below, and includes coloring effects from helper methods indicating likelihood of receiving that particular topic to review. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_show_pt1.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_show_pt2.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Page rendered by above: (This rendering is an instructor view, the student view is the same without the &amp;quot;Edit Topics&amp;quot; column.) &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_show_rendered.PNG|900px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&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. This json will have a list of all topics, list of all students and the topics each student selected and also the maximum number of review topics per student. Also, it has the timestamp information of the bidding time to give preference to early bidders. The input json is passed to the JsonParser class to create a Dictionary.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:tab.jpg]]&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 parser also creates a preferences dictionary for the Student to store their topic preferences and &lt;br /&gt;
one for Topics to store list of topics which have been selected by students and also the priority for the selection using the Timestamps.&lt;br /&gt;
The json parser does one more task of finding Popular topics. This is needed because topics that are in demand should be preserved for students who bid on it and to avoid assigning it to students who did not bid on anything. High demand topics are assigned a lower priority for such students so that there are other topics they can be assigned.&lt;br /&gt;
&lt;br /&gt;
[[File:json1.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:json2.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:json3.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''Class Topic'' =====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Topic class is the one that does the proposing to the students during the runtime. &lt;br /&gt;
There are 2 cases. In case 1 when the particular topic is asked by more students than the limit of number of students the one topic can be assigned to. In this case, it uses the priorities it already has in the dictionary to make sure the topic proposes only to those students who chose it and those who bid earlier.&lt;br /&gt;
In Case 2, There are less students who asked for the topic. Hence, the topic can propose to all the students who asked for it and still be under the limit. In the end of this step. All topics make their proposals to be assigned to some students.&lt;br /&gt;
&lt;br /&gt;
[[File:json11.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''Class Student'' =====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Once the Topics propose to students, the Student has to accept some of the proposals.&lt;br /&gt;
First, each student sorts the proposals based on the students preferences. Now, the student accepts all the proposals they can upto the number of slots remaining for them. The max slots for the student is determined by the max_proposals_accepted field in the json. Once the acceptance is complete, the Topics are all updated so that the topics can adjust their remaining slots accordingly.&lt;br /&gt;
&lt;br /&gt;
[[File:json12.png]]&lt;br /&gt;
&lt;br /&gt;
===== ''Topic Matcher'' =====&lt;br /&gt;
&lt;br /&gt;
Next, The Topics Matcher class is called which is the main class that runs the Algorithm.&lt;br /&gt;
Before running the algorithm, it creates a list of Student and Topic objects by using instances of Student and Topic class. Each student and Topic now has its own class so that it can be used to make proposals for assignment of topics.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:json4.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The get_student_topic_matches() method kicks off the Algorithm.&lt;br /&gt;
Each topic proposes to students based on the topic priorities as covered in the Topics section. It uses a max_topic_assignment_limit (say 4 for example) to make sure the same topic is not assigned to too many students. &lt;br /&gt;
Once the proposals are made, we iterate over students so that they can accept proposals as long as they have slots remaining to be assigned to.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
The round is now complete. To determine if we need a next round, we ask the topics if they are done proposing using is_topics_done_proposing() method. As long as each topic has not reached its assignment limit and there are still students to propose to, the proposing continues for the next round. &lt;br /&gt;
Once every topic is done, it breaks out of the loop and we now have the list of students with equal number of assigned topics ( 3-4 for example) and this list is returned back to Expertiza as the Stable matching to do the assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:json5.png]]&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;
&amp;lt;code&amp;gt;{&lt;br /&gt;
  &amp;quot;tid&amp;quot;: [&lt;br /&gt;
    3969,3970,3971,3972,3973,3974,3975,3976,3977&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;users&amp;quot;: {&lt;br /&gt;
    &amp;quot;36239&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [&lt;br /&gt;
        3970, 3972&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3977,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [&lt;br /&gt;
        2,1&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;time&amp;quot;: [&lt;br /&gt;
        &amp;quot;Thu, 12 Nov 2020 12:01:06 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 12:01:07 EST -05:00&amp;quot;&lt;br /&gt;
      ]&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;36240&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3976,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [],&lt;br /&gt;
      &amp;quot;time&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;36241&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [&lt;br /&gt;
        3969,3971,3972&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3975,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [&lt;br /&gt;
        1,3,2&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;time&amp;quot;: [&lt;br /&gt;
        &amp;quot;Thu, 12 Nov 2020 12:00:22 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 12:00:25 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 12:00:27 EST -05:00&amp;quot;&lt;br /&gt;
      ]&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;36242&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [&lt;br /&gt;
        3969,3971,3973&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3974,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [&lt;br /&gt;
        3,2,1&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;time&amp;quot;: [&lt;br /&gt;
        &amp;quot;Wed, 11 Nov 2020 12:15:43 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 11:59:40 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 13:07:53 EST -05:00&amp;quot;&lt;br /&gt;
      ]&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;36243&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [&lt;br /&gt;
        3971,3969,3970,3976&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3972,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [&lt;br /&gt;
        4,3,2,1,5&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;time&amp;quot;: [&lt;br /&gt;
        &amp;quot;Wed, 11 Nov 2020 11:34:50 EST -05:00&amp;quot;,&amp;quot;Wed, 11 Nov 2020 12:30:16 EST -05:00&amp;quot;,&amp;quot;Wed, 11 Nov 2020 12:30:19 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 13:02:02 EST -05:00&amp;quot;&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  },&lt;br /&gt;
  &amp;quot;max_accepted_proposals&amp;quot;: 3&lt;br /&gt;
} &amp;lt;/code&amp;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;
&amp;lt;code&amp;gt; {&lt;br /&gt;
  &amp;quot;36239&amp;quot;: [&lt;br /&gt;
    3970,&lt;br /&gt;
    3972,&lt;br /&gt;
    3975&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;36240&amp;quot;: [&lt;br /&gt;
    3973,&lt;br /&gt;
    3974,&lt;br /&gt;
    3972&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;36241&amp;quot;: [&lt;br /&gt;
    3969,&lt;br /&gt;
    3971,&lt;br /&gt;
    3972&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;36242&amp;quot;: [&lt;br /&gt;
    3969,&lt;br /&gt;
    3971,&lt;br /&gt;
    3973&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;36243&amp;quot;: [&lt;br /&gt;
    3969,&lt;br /&gt;
    3970,&lt;br /&gt;
    3971&lt;br /&gt;
  ]&lt;br /&gt;
}&amp;lt;/code&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;
===   ''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/RSpec Testing ''   ===&lt;br /&gt;
RSpec tests will need to be written to related controller(s) and model(s). &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== RSpec Testing Plan ====&lt;br /&gt;
These RSpec tests:&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;
:# [https://docs.google.com/document/d/1tXmwju6R7KQbvycku-bdXxa6rXSUN4BMyvjY3ROmMSw/edit Set up Expertiza] on personal device using [https://github.com/uahamedncsu/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;
==Team==&lt;br /&gt;
Ummu Kolusum Yasmin Ahamed Adam (uahamed) &amp;lt;br&amp;gt;&lt;br /&gt;
Ryan Grainger (rpgraing) &amp;lt;br&amp;gt;&lt;br /&gt;
Luis Delossantos (lgdeloss) &amp;lt;br&amp;gt;&lt;br /&gt;
Colleen &amp;quot;Bria&amp;quot; Engen (ceengen) &amp;lt;br&amp;gt;&lt;br /&gt;
'''Mentor:''' Saurabh Shingte (svshingt)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
''Previous Implementations'': [[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review 1]], [[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/uahamedncsu/expertiza/tree/beta &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/uahamedncsu/IntelligentAssignment &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/1822 &amp;lt;br&amp;gt;&lt;br /&gt;
''Expertiza Server'': http://152.7.99.70:8081/ &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': https://app-csc517.herokuapp.com/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
''Video Demo'': https://www.screencast.com/t/GJNOcfa9Ln &amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review&amp;diff=141779</id>
		<title>CSC/ECE 517 Fall 2020 - E2085. Allow reviewers to bid on what to review</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review&amp;diff=141779"/>
		<updated>2021-11-28T20:34:44Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: /* Method: get_bidding_data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Project Overview==&lt;br /&gt;
===   ''Background''   ===&lt;br /&gt;
Assigning reviews to users is a complicated process. Currently, reviews are still assigned using a first-come-first-served basis. However, reviews could be bid on like how topics are bid on. This would involve matching multiple students to review a submission up to the maximum reviewers for a submission.The manual selection process can be replaced with an automated bidding approach for this purpose.&lt;br /&gt;
&lt;br /&gt;
===   ''Objectives''   ===&lt;br /&gt;
# Implement top trading cycles on a web service. &lt;br /&gt;
# Add front end code to allow bidding on topics and call the appropriate web service from the lottery controller. &lt;br /&gt;
# Add working test cases to test the new changes.&lt;br /&gt;
# Code should be inclined to the Beta branch&lt;br /&gt;
# Link to run bidding assignment should be on the page associated with the assignment actions.&lt;br /&gt;
# Code such as getter methods should be added to the model and not the controller.&lt;br /&gt;
#The number of reviews created by default needs to be checked. One way of achieving this is creating minimum reviews and then allowing users to request more reviews if required.&lt;br /&gt;
&lt;br /&gt;
===   ''Previous Work''   ===&lt;br /&gt;
There have been two 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] &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]&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/uahamedncsu/expertiza/tree/beta &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/uahamedncsu/IntelligentAssignment &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/1822 &amp;lt;br&amp;gt;&lt;br /&gt;
''Expertiza Server'': http://152.7.99.70:8081/ &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': https://app-csc517.herokuapp.com/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
''Video Demo'': https://www.screencast.com/t/GJNOcfa9Ln &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;
*config/routes.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*config/webservices.yml&lt;br /&gt;
&lt;br /&gt;
*app/controllers/student_review_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/assignments/edit/_topics.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/student_task/list.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/student_task/view.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*spec/factories/factories.rb &amp;lt;br&amp;gt;&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/controllers/review_bids_controller.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/helpers/review_bids_helper.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/models/review_bid.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/_all_actions.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/_table_header.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/_table_line.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/_topic_names.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/others_work.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/show.html.erb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*db/migrate/20201107203204_create_review_bids.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*spec/controllers/review_bids_controller_spec.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*spec/models/review_bid_spec.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Design==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===   ''User Interface''   ===&lt;br /&gt;
&lt;br /&gt;
Currently, the users are offered the entire list of topics to review and are asked to select a topic to begin a review. Topics that cannot be reviewed or have already been reviewed the maximum number of times are greyed out and cannot be selected. There is also a check box in which the student can select &amp;quot;I don't care which topic I review&amp;quot; and will be randomly assigned a topic from the list. The current User Interface (UI) for this is shown below.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:current_review_UI.PNG]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As discussed in the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Project_Overview Project Overview] section, a bidding system similar to the bidding system used in topic selection is preferable to the current review selection system. The UI for this process will mirror the UI for the topic bidding system. The new UI will allow users to drag a topic from a list of all the topics on the left, to their priority list on the right. The ordering of the right list indicates the priority of the users preference. The colors indicate the likelihood of being assigned that topic. By utilizing the same UI, the consistency of the user experience and the DRY-ness of the code are increased. An example of the topic selection bidding UI is shown below.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:expected_review_UI.PNG]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Currently, an instructor has the option while creating or editing an assignment to allow a reviewers to select the topics they want to review. This is done by checking '''Has teams?''' and '''Has topics?''' in the '''General''' tab of an assignment then checking '''Allow reviewer to choose which topic to review?''' in the '''Topics''' tab. This interface can be used for allowing review bidding either by editing the current check box or adding an additional check box for '''Allow reviewer to bid on topics to review?'''.  &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Instructor_ui_for_review_bidding.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== ''Analyzing the problem'' ===&lt;br /&gt;
&lt;br /&gt;
Currently, the student can either pick a topic or is randomly assigned a topic, from among the ones that are currently eligible to be reviewed. &amp;lt;br&amp;gt;In this scenario, it is possible that some good topics are already picked by a lot of students and if someone is late to do the selecting, they miss out on it since it is grayed out.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To solve the above problem of not getting the topics they like, the participants must be assigned topics based on a list of topics they pre-select. &lt;br /&gt;
This is where an algorithm will come in handy. For picking a suitable algorithm, we should first identify the type of the problem.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Type of problem&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Each student should be able to bid on multiple assignments of their choice and the same assignment can be assigned to multiple participants for review.&amp;lt;br&amp;gt;&lt;br /&gt;
This requires a Many to Many mapping.&lt;br /&gt;
&lt;br /&gt;
                                        [[File:many2.png]]&lt;br /&gt;
&lt;br /&gt;
The algorithm of choice for this type of stable allocations is Gale-Shapely algorithm.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the real world, there are cases where we face this problem:&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt; Student choosing their future universities [https://www.jstor.org/stable/3132114?seq=1&amp;amp;cid=pdf-reference#references_tab_content '''School Choice Problem'''] (One-to-Many)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Men and women seeking each other to create families [https://en.wikipedia.org/wiki/Stable_marriage_problem '''Stable Marriage Problem'''] (One-to-One)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Internet services that need to be connected with users with the smallest amount of time &amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===''Algorithm Implementation for matching students and topics''===&lt;br /&gt;
The Gale-Shapely Algorithm has steps to make sure it is a Stable marriage/allocation.&lt;br /&gt;
An unstable allocation is when the participant does not like the topic assigned to them. &lt;br /&gt;
But it can happen that the participant 1 might like the review topic assigned to participant 2 and participant 2 likes the topic assigned to participant 1.&lt;br /&gt;
This is the unstable case. To make it stable, the topics need to be exchanged between these 2 participants so that both of them get the topic they wanted.&lt;br /&gt;
&lt;br /&gt;
[[File:Snippy2.png]]&lt;br /&gt;
Source: [https://www.journalajrcos.com/index.php/AJRCOS/article/view/24749/46281 Stable Marriage Algorithm]&lt;br /&gt;
&lt;br /&gt;
===''Assignment of priority ''===&lt;br /&gt;
When a student places a bid, the timestamp is recorded. Priority will be given to the earlier bidder. If the student had chosen only very few bids, then this person will be given a higher priority. Any topics that were not selected by the participant are added to bottom of their preference list in a random preference order to create a situation where &amp;lt;b&amp;gt;the number of students and number of topics is equal. &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===''Algorithm Steps ''===&lt;br /&gt;
&amp;lt;li&amp;gt; For the first round, the Algorithm will assign topics to each student based on the Priority and each topic is assigned to a limited number of students based on the Limit. It picks one topic and begins assigning students to it. (Note: The Algorithm makes sure the participant is not in a group that worked on this particular topic.) &lt;br /&gt;
&amp;lt;li&amp;gt;If the one topic is assigned to enough participants already, then it is removed from the queue and the same process is repeated for the next topic. &lt;br /&gt;
&amp;lt;li&amp;gt; As this goes on, all students are matched even if all matches are not stable at this point.&lt;br /&gt;
&amp;lt;li&amp;gt; The Algorithm terminates when all Topics that have not reached the maximum assignment level have tried to accept every student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;The time complexity of this algorithm is O(n^2) &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===''Simulation ''===&lt;br /&gt;
&lt;br /&gt;
[[File:gale-shapeley-1.png]]&lt;br /&gt;
[[File:gale-shapeley-2.png]]&lt;br /&gt;
&lt;br /&gt;
In the simulation above, we have equal number of Students (S1, S2, S3) and Review topics to assign (R1, R2, R3). The students preference of topics is to left of student. The Review topics does not have any preferences. To have preferences, the timestamps are used to determine which student bid on each topic first to create such a Preference list for topics.&lt;br /&gt;
&lt;br /&gt;
# Phase 1: Both Students S1 and S2 have selected R2 as their highest preference. Since there is a conflict, The preference of R2 is checked which shows that S2 had bid earlier than S1. Thus, the topic R2 is assigned to student S2.&lt;br /&gt;
# Phase 2: Now, S1 and S3 both want to review R1 but R1 was first bid on by S1 as shown in the preference. Hence, R1 is assigned to S1.&lt;br /&gt;
# Phase 3: The only topic remaining in this case is R3 which is also on the preference list of Student S3. Therefore S3 is assigned the topic R3.&lt;br /&gt;
#By the end of the 3 phases, All students are assigned to a Review. The same process needs to be repeated till the required number of reviews are assigned to each student. In each iteration, if a review is assigned to max number of students already, the review is removed from consideration.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
This section details the implementation of the code and will highlight each component of the design in the code and its intended purpose, as well as any modifications or testing. As the implementation progresses this section will be updated.&lt;br /&gt;
&lt;br /&gt;
===   ''Overview''   ===&lt;br /&gt;
&lt;br /&gt;
This project was split into 2 objectives, the Expertiza MVC implementation and the webservice algorithm. The Expertiza MVC follows the MVC standard such that the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Controller controller] handles directing the users to the correct views, as well as handling the communication with the webservice. The [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Model model] performs all necessary computations and data handling like the creation and storing of bids on reviews and assigning reviews to students. The [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Views views] render the corresponding webpage based on the actions of the user. The [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Webservice webservice] contains the algorithm outlined in the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Algorithm_Implementation_for_matching_students_and_topics Algorithm Implementation] section of Design. Our Expertiza controller sends this webservice bidding information and the algorithm returns the matched topics to be assigned. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== ''Controller'' ===&lt;br /&gt;
The controller contains 6 methods that perform all the necessary functions. The first method, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_action_allowed? &amp;quot;action_allowed?&amp;quot;] performs authentication checks The second, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_index &amp;quot;index&amp;quot;], is used to redirect the user to a list of assigned reviews after the algorithm has been run. The third, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_show &amp;quot;show&amp;quot;], is used in conjunction with fourth, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_set_priority &amp;quot;set_priority&amp;quot;], to update and store the bids when users make changes in the bidding page. The fifth, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_assign_bidding &amp;quot;assign_bidding&amp;quot;], utilizes the sixth, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_run_bidding_algorithm &amp;quot;run_bidding_algorithm&amp;quot;], to connect to the webservice, send and receive the correct bidding information for the algorithm. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: action_allowed? ======&lt;br /&gt;
This method performs authentication by allowing only certain types of users to access controller methods. The first portion of this method allows users 'Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator', and 'Student' to access the methods 'show', 'set_priority', and 'index'. These are the methods that render the bidding pages and review listings. The other methods are restricted for 'Student' users. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller action allowed..PNG]] &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: index ======&lt;br /&gt;
This method collects all the necessary information about the user, Assignment details, and Review Mapping details to render the 'review_bids/others_work', which lists the reviews that are assigned to the user. This page also includes a button to request more reviews which will add reviews up to the maximum number of reviews. To see the view rendered by this method, please go to [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#View:_others_work.html.erb &amp;quot;others_work&amp;quot;].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_index.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: show ======&lt;br /&gt;
This method renders the bidding page in which participants can select from a table of topics the topics they would prefer to review. It collects the necessary information about the user, Assignment, Topics, and current Review Bids to render this page. It is used in conjunction with [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_set_priority set_priority] where the users bidding information is stored, and the page updated. To see the bidding page that this function renders, visit the view [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#View:_show.html.erb &amp;quot;show&amp;quot;] &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_show.PNG]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: set_priority ======&lt;br /&gt;
In the view file [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#view:_show.html.erb &amp;quot;show&amp;quot;] there exists a line the calls this method when the page is updated or accessed. This method stores the user's bidding information in the schema database. This allows the model to access this information when collecting all the bidding information, as well as allowing users to refresh or return to this page with their selections staying in the bid table. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_set_priority.PNG]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_bidding ======&lt;br /&gt;
This method utilizes methods in the model, as well as the method [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_run_bidding_algorithm &amp;quot;run_bidding_algorithm&amp;quot;] to collect the bidding information of all students of a particular Assignment, send it to the webservice algorithm, store the matched topics that are returned, and pass these matched topics to the model to be assigned. After this method is run, the students should have assigned reviews and bidding should be turned off.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_assign_bidding.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: run_bidding_algorithm ======&lt;br /&gt;
This method connects to the webservice using RestClient API, which is part of the 'require's at the top of the Controller. It will return a false if the connection fails for ay reason such as connection is not established or the algorithm has an internal error, otherwise it returns the matched topics from the algorithm as a 'json'. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_requirements.PNG]] &amp;lt;br&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_run_bidding_algorithm.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== ''Model '' ===&lt;br /&gt;
The model contains 5 methods that are utilized by the controller to save bidding information per user or all users, retrieve bidding information per user or for all users, and assign topics to review to participants.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: get_bidding_data ======&lt;br /&gt;
This method is called by the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_assign_bidding &amp;quot;assign_bidding&amp;quot;] controller method. It receives the Assignment ID and a list of reviewers, which are student IDs. It creates a Hash to store bidding data into and iterates through all of the reviewers, calling [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_reviewer_bidding_data &amp;quot;reviewer_bidding_data&amp;quot;] to get each students bidding data and store it in the Hash. It returns a Hash with all the bidding data needed for the Webservice Algorithm to run.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Model_get_bidding_data.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_review_topics ======&lt;br /&gt;
This method is called by the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_assign_bidding &amp;quot;assign_bidding&amp;quot;] controller method. Given the Assignment ID, list of reviewers, and the matched topics returned by the webservice algorithm, it first clears any previously assigned reviews for that Assignment to prevent multiple assigns, then iterates through each reviewer and assigns them to the topics that the algorithm selected for them.&lt;br /&gt;
[[File:Model_assign_review_topics.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_topic_to_reviewer ======&lt;br /&gt;
This method is called by the method [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_assign_review_topics &amp;quot;assign_review_topics&amp;quot;] and assigns a single topic to a single user to review given an Assignment ID. &lt;br /&gt;
[[File:Model_assign_topic_to_reviewer.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: reviewer_self_topic ======&lt;br /&gt;
This method returns the topic id of the reviewer that is passed in. This method is utilized to retrieve the reviewers' Topic ID, which is needed for the webservice algorithm to prevent users from being assigned to review their own topic. This is also prevented in views, but this is an additional safety precaution. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Model_reviewer_self_topic.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: reviewer_bidding_data ======&lt;br /&gt;
This method is called by [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_get_bidding_data &amp;quot;get_bidding_data&amp;quot;]. It creates a hash to store all the reviewer's bidding information. It iterates through all the bids for a reviewer given the Assignment ID and it returns a Hash of the bidding data.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Model_reviewer_bidding_data.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== ''Views'' ===&lt;br /&gt;
There are two main views for this project. They are for bidding and for showing assigned reviews after the bidding algorithm has been run. &lt;br /&gt;
====== View: others_work.html.erb ======&lt;br /&gt;
This file renders the view where students see a list of the reviews they've been assigned, with appropriate links and related messages. It includes a &amp;quot;Request Additional Review&amp;quot; button that will allow students to view more reviews up to the max number of reviews allowed. &lt;br /&gt;
[[File:Views_others_work_pt1.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_others_work_pt2.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_others_work_pt3.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_others_work_pt4.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
View rendered by above:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_others_work_rendered.PNG]]&lt;br /&gt;
&lt;br /&gt;
====== View: show.html.erb ======&lt;br /&gt;
This view file renders the Review Bidding page where participants can select which topics to review. It renders partials which are included below, and includes coloring effects from helper methods indicating likelihood of receiving that particular topic to review. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_show_pt1.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_show_pt2.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Page rendered by above: (This rendering is an instructor view, the student view is the same without the &amp;quot;Edit Topics&amp;quot; column.) &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_show_rendered.PNG|900px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&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. This json will have a list of all topics, list of all students and the topics each student selected and also the maximum number of review topics per student. Also, it has the timestamp information of the bidding time to give preference to early bidders. The input json is passed to the JsonParser class to create a Dictionary.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:tab.jpg]]&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 parser also creates a preferences dictionary for the Student to store their topic preferences and &lt;br /&gt;
one for Topics to store list of topics which have been selected by students and also the priority for the selection using the Timestamps.&lt;br /&gt;
The json parser does one more task of finding Popular topics. This is needed because topics that are in demand should be preserved for students who bid on it and to avoid assigning it to students who did not bid on anything. High demand topics are assigned a lower priority for such students so that there are other topics they can be assigned.&lt;br /&gt;
&lt;br /&gt;
[[File:json1.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:json2.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:json3.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''Class Topic'' =====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Topic class is the one that does the proposing to the students during the runtime. &lt;br /&gt;
There are 2 cases. In case 1 when the particular topic is asked by more students than the limit of number of students the one topic can be assigned to. In this case, it uses the priorities it already has in the dictionary to make sure the topic proposes only to those students who chose it and those who bid earlier.&lt;br /&gt;
In Case 2, There are less students who asked for the topic. Hence, the topic can propose to all the students who asked for it and still be under the limit. In the end of this step. All topics make their proposals to be assigned to some students.&lt;br /&gt;
&lt;br /&gt;
[[File:json11.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''Class Student'' =====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Once the Topics propose to students, the Student has to accept some of the proposals.&lt;br /&gt;
First, each student sorts the proposals based on the students preferences. Now, the student accepts all the proposals they can upto the number of slots remaining for them. The max slots for the student is determined by the max_proposals_accepted field in the json. Once the acceptance is complete, the Topics are all updated so that the topics can adjust their remaining slots accordingly.&lt;br /&gt;
&lt;br /&gt;
[[File:json12.png]]&lt;br /&gt;
&lt;br /&gt;
===== ''Topic Matcher'' =====&lt;br /&gt;
&lt;br /&gt;
Next, The Topics Matcher class is called which is the main class that runs the Algorithm.&lt;br /&gt;
Before running the algorithm, it creates a list of Student and Topic objects by using instances of Student and Topic class. Each student and Topic now has its own class so that it can be used to make proposals for assignment of topics.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:json4.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The get_student_topic_matches() method kicks off the Algorithm.&lt;br /&gt;
Each topic proposes to students based on the topic priorities as covered in the Topics section. It uses a max_topic_assignment_limit (say 4 for example) to make sure the same topic is not assigned to too many students. &lt;br /&gt;
Once the proposals are made, we iterate over students so that they can accept proposals as long as they have slots remaining to be assigned to.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
The round is now complete. To determine if we need a next round, we ask the topics if they are done proposing using is_topics_done_proposing() method. As long as each topic has not reached its assignment limit and there are still students to propose to, the proposing continues for the next round. &lt;br /&gt;
Once every topic is done, it breaks out of the loop and we now have the list of students with equal number of assigned topics ( 3-4 for example) and this list is returned back to Expertiza as the Stable matching to do the assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:json5.png]]&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;
&amp;lt;code&amp;gt;{&lt;br /&gt;
  &amp;quot;tid&amp;quot;: [&lt;br /&gt;
    3969,3970,3971,3972,3973,3974,3975,3976,3977&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;users&amp;quot;: {&lt;br /&gt;
    &amp;quot;36239&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [&lt;br /&gt;
        3970, 3972&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3977,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [&lt;br /&gt;
        2,1&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;time&amp;quot;: [&lt;br /&gt;
        &amp;quot;Thu, 12 Nov 2020 12:01:06 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 12:01:07 EST -05:00&amp;quot;&lt;br /&gt;
      ]&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;36240&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3976,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [],&lt;br /&gt;
      &amp;quot;time&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;36241&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [&lt;br /&gt;
        3969,3971,3972&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3975,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [&lt;br /&gt;
        1,3,2&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;time&amp;quot;: [&lt;br /&gt;
        &amp;quot;Thu, 12 Nov 2020 12:00:22 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 12:00:25 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 12:00:27 EST -05:00&amp;quot;&lt;br /&gt;
      ]&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;36242&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [&lt;br /&gt;
        3969,3971,3973&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3974,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [&lt;br /&gt;
        3,2,1&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;time&amp;quot;: [&lt;br /&gt;
        &amp;quot;Wed, 11 Nov 2020 12:15:43 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 11:59:40 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 13:07:53 EST -05:00&amp;quot;&lt;br /&gt;
      ]&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;36243&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [&lt;br /&gt;
        3971,3969,3970,3976&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3972,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [&lt;br /&gt;
        4,3,2,1,5&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;time&amp;quot;: [&lt;br /&gt;
        &amp;quot;Wed, 11 Nov 2020 11:34:50 EST -05:00&amp;quot;,&amp;quot;Wed, 11 Nov 2020 12:30:16 EST -05:00&amp;quot;,&amp;quot;Wed, 11 Nov 2020 12:30:19 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 13:02:02 EST -05:00&amp;quot;&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  },&lt;br /&gt;
  &amp;quot;max_accepted_proposals&amp;quot;: 3&lt;br /&gt;
} &amp;lt;/code&amp;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;
&amp;lt;code&amp;gt; {&lt;br /&gt;
  &amp;quot;36239&amp;quot;: [&lt;br /&gt;
    3970,&lt;br /&gt;
    3972,&lt;br /&gt;
    3975&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;36240&amp;quot;: [&lt;br /&gt;
    3973,&lt;br /&gt;
    3974,&lt;br /&gt;
    3972&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;36241&amp;quot;: [&lt;br /&gt;
    3969,&lt;br /&gt;
    3971,&lt;br /&gt;
    3972&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;36242&amp;quot;: [&lt;br /&gt;
    3969,&lt;br /&gt;
    3971,&lt;br /&gt;
    3973&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;36243&amp;quot;: [&lt;br /&gt;
    3969,&lt;br /&gt;
    3970,&lt;br /&gt;
    3971&lt;br /&gt;
  ]&lt;br /&gt;
}&amp;lt;/code&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;
===   ''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/RSpec Testing ''   ===&lt;br /&gt;
RSpec tests will need to be written to related controller(s) and model(s). &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== RSpec Testing Plan ====&lt;br /&gt;
These RSpec tests:&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;
:# [https://docs.google.com/document/d/1tXmwju6R7KQbvycku-bdXxa6rXSUN4BMyvjY3ROmMSw/edit Set up Expertiza] on personal device using [https://github.com/uahamedncsu/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;
==Team==&lt;br /&gt;
Ummu Kolusum Yasmin Ahamed Adam (uahamed) &amp;lt;br&amp;gt;&lt;br /&gt;
Ryan Grainger (rpgraing) &amp;lt;br&amp;gt;&lt;br /&gt;
Luis Delossantos (lgdeloss) &amp;lt;br&amp;gt;&lt;br /&gt;
Colleen &amp;quot;Bria&amp;quot; Engen (ceengen) &amp;lt;br&amp;gt;&lt;br /&gt;
'''Mentor:''' Saurabh Shingte (svshingt)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
''Previous Implementations'': [[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review 1]], [[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/uahamedncsu/expertiza/tree/beta &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/uahamedncsu/IntelligentAssignment &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/1822 &amp;lt;br&amp;gt;&lt;br /&gt;
''Expertiza Server'': http://152.7.99.70:8081/ &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': https://app-csc517.herokuapp.com/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
''Video Demo'': https://www.screencast.com/t/GJNOcfa9Ln &amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review&amp;diff=141778</id>
		<title>CSC/ECE 517 Fall 2020 - E2085. Allow reviewers to bid on what to review</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review&amp;diff=141778"/>
		<updated>2021-11-28T20:32:47Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: /* Method: assign_bidding */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Project Overview==&lt;br /&gt;
===   ''Background''   ===&lt;br /&gt;
Assigning reviews to users is a complicated process. Currently, reviews are still assigned using a first-come-first-served basis. However, reviews could be bid on like how topics are bid on. This would involve matching multiple students to review a submission up to the maximum reviewers for a submission.The manual selection process can be replaced with an automated bidding approach for this purpose.&lt;br /&gt;
&lt;br /&gt;
===   ''Objectives''   ===&lt;br /&gt;
# Implement top trading cycles on a web service. &lt;br /&gt;
# Add front end code to allow bidding on topics and call the appropriate web service from the lottery controller. &lt;br /&gt;
# Add working test cases to test the new changes.&lt;br /&gt;
# Code should be inclined to the Beta branch&lt;br /&gt;
# Link to run bidding assignment should be on the page associated with the assignment actions.&lt;br /&gt;
# Code such as getter methods should be added to the model and not the controller.&lt;br /&gt;
#The number of reviews created by default needs to be checked. One way of achieving this is creating minimum reviews and then allowing users to request more reviews if required.&lt;br /&gt;
&lt;br /&gt;
===   ''Previous Work''   ===&lt;br /&gt;
There have been two 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] &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]&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/uahamedncsu/expertiza/tree/beta &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/uahamedncsu/IntelligentAssignment &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/1822 &amp;lt;br&amp;gt;&lt;br /&gt;
''Expertiza Server'': http://152.7.99.70:8081/ &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': https://app-csc517.herokuapp.com/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
''Video Demo'': https://www.screencast.com/t/GJNOcfa9Ln &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;
*config/routes.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*config/webservices.yml&lt;br /&gt;
&lt;br /&gt;
*app/controllers/student_review_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/assignments/edit/_topics.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/student_task/list.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/student_task/view.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*spec/factories/factories.rb &amp;lt;br&amp;gt;&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/controllers/review_bids_controller.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/helpers/review_bids_helper.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/models/review_bid.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/_all_actions.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/_table_header.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/_table_line.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/_topic_names.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/others_work.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/show.html.erb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*db/migrate/20201107203204_create_review_bids.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*spec/controllers/review_bids_controller_spec.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*spec/models/review_bid_spec.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Design==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===   ''User Interface''   ===&lt;br /&gt;
&lt;br /&gt;
Currently, the users are offered the entire list of topics to review and are asked to select a topic to begin a review. Topics that cannot be reviewed or have already been reviewed the maximum number of times are greyed out and cannot be selected. There is also a check box in which the student can select &amp;quot;I don't care which topic I review&amp;quot; and will be randomly assigned a topic from the list. The current User Interface (UI) for this is shown below.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:current_review_UI.PNG]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As discussed in the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Project_Overview Project Overview] section, a bidding system similar to the bidding system used in topic selection is preferable to the current review selection system. The UI for this process will mirror the UI for the topic bidding system. The new UI will allow users to drag a topic from a list of all the topics on the left, to their priority list on the right. The ordering of the right list indicates the priority of the users preference. The colors indicate the likelihood of being assigned that topic. By utilizing the same UI, the consistency of the user experience and the DRY-ness of the code are increased. An example of the topic selection bidding UI is shown below.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:expected_review_UI.PNG]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Currently, an instructor has the option while creating or editing an assignment to allow a reviewers to select the topics they want to review. This is done by checking '''Has teams?''' and '''Has topics?''' in the '''General''' tab of an assignment then checking '''Allow reviewer to choose which topic to review?''' in the '''Topics''' tab. This interface can be used for allowing review bidding either by editing the current check box or adding an additional check box for '''Allow reviewer to bid on topics to review?'''.  &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Instructor_ui_for_review_bidding.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== ''Analyzing the problem'' ===&lt;br /&gt;
&lt;br /&gt;
Currently, the student can either pick a topic or is randomly assigned a topic, from among the ones that are currently eligible to be reviewed. &amp;lt;br&amp;gt;In this scenario, it is possible that some good topics are already picked by a lot of students and if someone is late to do the selecting, they miss out on it since it is grayed out.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To solve the above problem of not getting the topics they like, the participants must be assigned topics based on a list of topics they pre-select. &lt;br /&gt;
This is where an algorithm will come in handy. For picking a suitable algorithm, we should first identify the type of the problem.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Type of problem&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Each student should be able to bid on multiple assignments of their choice and the same assignment can be assigned to multiple participants for review.&amp;lt;br&amp;gt;&lt;br /&gt;
This requires a Many to Many mapping.&lt;br /&gt;
&lt;br /&gt;
                                        [[File:many2.png]]&lt;br /&gt;
&lt;br /&gt;
The algorithm of choice for this type of stable allocations is Gale-Shapely algorithm.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the real world, there are cases where we face this problem:&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt; Student choosing their future universities [https://www.jstor.org/stable/3132114?seq=1&amp;amp;cid=pdf-reference#references_tab_content '''School Choice Problem'''] (One-to-Many)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Men and women seeking each other to create families [https://en.wikipedia.org/wiki/Stable_marriage_problem '''Stable Marriage Problem'''] (One-to-One)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Internet services that need to be connected with users with the smallest amount of time &amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===''Algorithm Implementation for matching students and topics''===&lt;br /&gt;
The Gale-Shapely Algorithm has steps to make sure it is a Stable marriage/allocation.&lt;br /&gt;
An unstable allocation is when the participant does not like the topic assigned to them. &lt;br /&gt;
But it can happen that the participant 1 might like the review topic assigned to participant 2 and participant 2 likes the topic assigned to participant 1.&lt;br /&gt;
This is the unstable case. To make it stable, the topics need to be exchanged between these 2 participants so that both of them get the topic they wanted.&lt;br /&gt;
&lt;br /&gt;
[[File:Snippy2.png]]&lt;br /&gt;
Source: [https://www.journalajrcos.com/index.php/AJRCOS/article/view/24749/46281 Stable Marriage Algorithm]&lt;br /&gt;
&lt;br /&gt;
===''Assignment of priority ''===&lt;br /&gt;
When a student places a bid, the timestamp is recorded. Priority will be given to the earlier bidder. If the student had chosen only very few bids, then this person will be given a higher priority. Any topics that were not selected by the participant are added to bottom of their preference list in a random preference order to create a situation where &amp;lt;b&amp;gt;the number of students and number of topics is equal. &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===''Algorithm Steps ''===&lt;br /&gt;
&amp;lt;li&amp;gt; For the first round, the Algorithm will assign topics to each student based on the Priority and each topic is assigned to a limited number of students based on the Limit. It picks one topic and begins assigning students to it. (Note: The Algorithm makes sure the participant is not in a group that worked on this particular topic.) &lt;br /&gt;
&amp;lt;li&amp;gt;If the one topic is assigned to enough participants already, then it is removed from the queue and the same process is repeated for the next topic. &lt;br /&gt;
&amp;lt;li&amp;gt; As this goes on, all students are matched even if all matches are not stable at this point.&lt;br /&gt;
&amp;lt;li&amp;gt; The Algorithm terminates when all Topics that have not reached the maximum assignment level have tried to accept every student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;The time complexity of this algorithm is O(n^2) &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===''Simulation ''===&lt;br /&gt;
&lt;br /&gt;
[[File:gale-shapeley-1.png]]&lt;br /&gt;
[[File:gale-shapeley-2.png]]&lt;br /&gt;
&lt;br /&gt;
In the simulation above, we have equal number of Students (S1, S2, S3) and Review topics to assign (R1, R2, R3). The students preference of topics is to left of student. The Review topics does not have any preferences. To have preferences, the timestamps are used to determine which student bid on each topic first to create such a Preference list for topics.&lt;br /&gt;
&lt;br /&gt;
# Phase 1: Both Students S1 and S2 have selected R2 as their highest preference. Since there is a conflict, The preference of R2 is checked which shows that S2 had bid earlier than S1. Thus, the topic R2 is assigned to student S2.&lt;br /&gt;
# Phase 2: Now, S1 and S3 both want to review R1 but R1 was first bid on by S1 as shown in the preference. Hence, R1 is assigned to S1.&lt;br /&gt;
# Phase 3: The only topic remaining in this case is R3 which is also on the preference list of Student S3. Therefore S3 is assigned the topic R3.&lt;br /&gt;
#By the end of the 3 phases, All students are assigned to a Review. The same process needs to be repeated till the required number of reviews are assigned to each student. In each iteration, if a review is assigned to max number of students already, the review is removed from consideration.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
This section details the implementation of the code and will highlight each component of the design in the code and its intended purpose, as well as any modifications or testing. As the implementation progresses this section will be updated.&lt;br /&gt;
&lt;br /&gt;
===   ''Overview''   ===&lt;br /&gt;
&lt;br /&gt;
This project was split into 2 objectives, the Expertiza MVC implementation and the webservice algorithm. The Expertiza MVC follows the MVC standard such that the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Controller controller] handles directing the users to the correct views, as well as handling the communication with the webservice. The [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Model model] performs all necessary computations and data handling like the creation and storing of bids on reviews and assigning reviews to students. The [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Views views] render the corresponding webpage based on the actions of the user. The [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Webservice webservice] contains the algorithm outlined in the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Algorithm_Implementation_for_matching_students_and_topics Algorithm Implementation] section of Design. Our Expertiza controller sends this webservice bidding information and the algorithm returns the matched topics to be assigned. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== ''Controller'' ===&lt;br /&gt;
The controller contains 6 methods that perform all the necessary functions. The first method, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_action_allowed? &amp;quot;action_allowed?&amp;quot;] performs authentication checks The second, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_index &amp;quot;index&amp;quot;], is used to redirect the user to a list of assigned reviews after the algorithm has been run. The third, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_show &amp;quot;show&amp;quot;], is used in conjunction with fourth, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_set_priority &amp;quot;set_priority&amp;quot;], to update and store the bids when users make changes in the bidding page. The fifth, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_assign_bidding &amp;quot;assign_bidding&amp;quot;], utilizes the sixth, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_run_bidding_algorithm &amp;quot;run_bidding_algorithm&amp;quot;], to connect to the webservice, send and receive the correct bidding information for the algorithm. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: action_allowed? ======&lt;br /&gt;
This method performs authentication by allowing only certain types of users to access controller methods. The first portion of this method allows users 'Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator', and 'Student' to access the methods 'show', 'set_priority', and 'index'. These are the methods that render the bidding pages and review listings. The other methods are restricted for 'Student' users. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller action allowed..PNG]] &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: index ======&lt;br /&gt;
This method collects all the necessary information about the user, Assignment details, and Review Mapping details to render the 'review_bids/others_work', which lists the reviews that are assigned to the user. This page also includes a button to request more reviews which will add reviews up to the maximum number of reviews. To see the view rendered by this method, please go to [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#View:_others_work.html.erb &amp;quot;others_work&amp;quot;].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_index.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: show ======&lt;br /&gt;
This method renders the bidding page in which participants can select from a table of topics the topics they would prefer to review. It collects the necessary information about the user, Assignment, Topics, and current Review Bids to render this page. It is used in conjunction with [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_set_priority set_priority] where the users bidding information is stored, and the page updated. To see the bidding page that this function renders, visit the view [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#View:_show.html.erb &amp;quot;show&amp;quot;] &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_show.PNG]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: set_priority ======&lt;br /&gt;
In the view file [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#view:_show.html.erb &amp;quot;show&amp;quot;] there exists a line the calls this method when the page is updated or accessed. This method stores the user's bidding information in the schema database. This allows the model to access this information when collecting all the bidding information, as well as allowing users to refresh or return to this page with their selections staying in the bid table. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_set_priority.PNG]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_bidding ======&lt;br /&gt;
This method utilizes methods in the model, as well as the method [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_run_bidding_algorithm &amp;quot;run_bidding_algorithm&amp;quot;] to collect the bidding information of all students of a particular Assignment, send it to the webservice algorithm, store the matched topics that are returned, and pass these matched topics to the model to be assigned. After this method is run, the students should have assigned reviews and bidding should be turned off.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_assign_bidding.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: run_bidding_algorithm ======&lt;br /&gt;
This method connects to the webservice using RestClient API, which is part of the 'require's at the top of the Controller. It will return a false if the connection fails for ay reason such as connection is not established or the algorithm has an internal error, otherwise it returns the matched topics from the algorithm as a 'json'. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_requirements.PNG]] &amp;lt;br&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_run_bidding_algorithm.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== ''Model '' ===&lt;br /&gt;
The model contains 5 methods that are utilized by the controller to save bidding information per user or all users, retrieve bidding information per user or for all users, and assign topics to review to participants.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: get_bidding_data ======&lt;br /&gt;
This method is called by the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_assign_bidding &amp;quot;assign_bidding&amp;quot;] controller method. It receives the Assignment ID and a list of reviewers, which are student IDs. It creates a Hash to store bidding data into and iterates through all of the reviewers, calling [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_reviewer_bidding_data &amp;quot;reviewer_bidding_data&amp;quot;] to get each students bidding data and store it in the Hash. It returns a Hash with all the bidding data needed for the Webservice Algorithm to run.&lt;br /&gt;
[[File:Model_get_bidding_data.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_review_topics ======&lt;br /&gt;
This method is called by the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_assign_bidding &amp;quot;assign_bidding&amp;quot;] controller method. Given the Assignment ID, list of reviewers, and the matched topics returned by the webservice algorithm, it first clears any previously assigned reviews for that Assignment to prevent multiple assigns, then iterates through each reviewer and assigns them to the topics that the algorithm selected for them.&lt;br /&gt;
[[File:Model_assign_review_topics.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_topic_to_reviewer ======&lt;br /&gt;
This method is called by the method [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_assign_review_topics &amp;quot;assign_review_topics&amp;quot;] and assigns a single topic to a single user to review given an Assignment ID. &lt;br /&gt;
[[File:Model_assign_topic_to_reviewer.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: reviewer_self_topic ======&lt;br /&gt;
This method returns the topic id of the reviewer that is passed in. This method is utilized to retrieve the reviewers' Topic ID, which is needed for the webservice algorithm to prevent users from being assigned to review their own topic. This is also prevented in views, but this is an additional safety precaution. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Model_reviewer_self_topic.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: reviewer_bidding_data ======&lt;br /&gt;
This method is called by [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_get_bidding_data &amp;quot;get_bidding_data&amp;quot;]. It creates a hash to store all the reviewer's bidding information. It iterates through all the bids for a reviewer given the Assignment ID and it returns a Hash of the bidding data.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Model_reviewer_bidding_data.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== ''Views'' ===&lt;br /&gt;
There are two main views for this project. They are for bidding and for showing assigned reviews after the bidding algorithm has been run. &lt;br /&gt;
====== View: others_work.html.erb ======&lt;br /&gt;
This file renders the view where students see a list of the reviews they've been assigned, with appropriate links and related messages. It includes a &amp;quot;Request Additional Review&amp;quot; button that will allow students to view more reviews up to the max number of reviews allowed. &lt;br /&gt;
[[File:Views_others_work_pt1.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_others_work_pt2.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_others_work_pt3.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_others_work_pt4.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
View rendered by above:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_others_work_rendered.PNG]]&lt;br /&gt;
&lt;br /&gt;
====== View: show.html.erb ======&lt;br /&gt;
This view file renders the Review Bidding page where participants can select which topics to review. It renders partials which are included below, and includes coloring effects from helper methods indicating likelihood of receiving that particular topic to review. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_show_pt1.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_show_pt2.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Page rendered by above: (This rendering is an instructor view, the student view is the same without the &amp;quot;Edit Topics&amp;quot; column.) &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_show_rendered.PNG|900px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&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. This json will have a list of all topics, list of all students and the topics each student selected and also the maximum number of review topics per student. Also, it has the timestamp information of the bidding time to give preference to early bidders. The input json is passed to the JsonParser class to create a Dictionary.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:tab.jpg]]&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 parser also creates a preferences dictionary for the Student to store their topic preferences and &lt;br /&gt;
one for Topics to store list of topics which have been selected by students and also the priority for the selection using the Timestamps.&lt;br /&gt;
The json parser does one more task of finding Popular topics. This is needed because topics that are in demand should be preserved for students who bid on it and to avoid assigning it to students who did not bid on anything. High demand topics are assigned a lower priority for such students so that there are other topics they can be assigned.&lt;br /&gt;
&lt;br /&gt;
[[File:json1.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:json2.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:json3.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''Class Topic'' =====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Topic class is the one that does the proposing to the students during the runtime. &lt;br /&gt;
There are 2 cases. In case 1 when the particular topic is asked by more students than the limit of number of students the one topic can be assigned to. In this case, it uses the priorities it already has in the dictionary to make sure the topic proposes only to those students who chose it and those who bid earlier.&lt;br /&gt;
In Case 2, There are less students who asked for the topic. Hence, the topic can propose to all the students who asked for it and still be under the limit. In the end of this step. All topics make their proposals to be assigned to some students.&lt;br /&gt;
&lt;br /&gt;
[[File:json11.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''Class Student'' =====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Once the Topics propose to students, the Student has to accept some of the proposals.&lt;br /&gt;
First, each student sorts the proposals based on the students preferences. Now, the student accepts all the proposals they can upto the number of slots remaining for them. The max slots for the student is determined by the max_proposals_accepted field in the json. Once the acceptance is complete, the Topics are all updated so that the topics can adjust their remaining slots accordingly.&lt;br /&gt;
&lt;br /&gt;
[[File:json12.png]]&lt;br /&gt;
&lt;br /&gt;
===== ''Topic Matcher'' =====&lt;br /&gt;
&lt;br /&gt;
Next, The Topics Matcher class is called which is the main class that runs the Algorithm.&lt;br /&gt;
Before running the algorithm, it creates a list of Student and Topic objects by using instances of Student and Topic class. Each student and Topic now has its own class so that it can be used to make proposals for assignment of topics.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:json4.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The get_student_topic_matches() method kicks off the Algorithm.&lt;br /&gt;
Each topic proposes to students based on the topic priorities as covered in the Topics section. It uses a max_topic_assignment_limit (say 4 for example) to make sure the same topic is not assigned to too many students. &lt;br /&gt;
Once the proposals are made, we iterate over students so that they can accept proposals as long as they have slots remaining to be assigned to.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
The round is now complete. To determine if we need a next round, we ask the topics if they are done proposing using is_topics_done_proposing() method. As long as each topic has not reached its assignment limit and there are still students to propose to, the proposing continues for the next round. &lt;br /&gt;
Once every topic is done, it breaks out of the loop and we now have the list of students with equal number of assigned topics ( 3-4 for example) and this list is returned back to Expertiza as the Stable matching to do the assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:json5.png]]&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;
&amp;lt;code&amp;gt;{&lt;br /&gt;
  &amp;quot;tid&amp;quot;: [&lt;br /&gt;
    3969,3970,3971,3972,3973,3974,3975,3976,3977&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;users&amp;quot;: {&lt;br /&gt;
    &amp;quot;36239&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [&lt;br /&gt;
        3970, 3972&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3977,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [&lt;br /&gt;
        2,1&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;time&amp;quot;: [&lt;br /&gt;
        &amp;quot;Thu, 12 Nov 2020 12:01:06 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 12:01:07 EST -05:00&amp;quot;&lt;br /&gt;
      ]&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;36240&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3976,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [],&lt;br /&gt;
      &amp;quot;time&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;36241&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [&lt;br /&gt;
        3969,3971,3972&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3975,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [&lt;br /&gt;
        1,3,2&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;time&amp;quot;: [&lt;br /&gt;
        &amp;quot;Thu, 12 Nov 2020 12:00:22 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 12:00:25 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 12:00:27 EST -05:00&amp;quot;&lt;br /&gt;
      ]&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;36242&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [&lt;br /&gt;
        3969,3971,3973&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3974,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [&lt;br /&gt;
        3,2,1&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;time&amp;quot;: [&lt;br /&gt;
        &amp;quot;Wed, 11 Nov 2020 12:15:43 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 11:59:40 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 13:07:53 EST -05:00&amp;quot;&lt;br /&gt;
      ]&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;36243&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [&lt;br /&gt;
        3971,3969,3970,3976&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3972,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [&lt;br /&gt;
        4,3,2,1,5&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;time&amp;quot;: [&lt;br /&gt;
        &amp;quot;Wed, 11 Nov 2020 11:34:50 EST -05:00&amp;quot;,&amp;quot;Wed, 11 Nov 2020 12:30:16 EST -05:00&amp;quot;,&amp;quot;Wed, 11 Nov 2020 12:30:19 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 13:02:02 EST -05:00&amp;quot;&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  },&lt;br /&gt;
  &amp;quot;max_accepted_proposals&amp;quot;: 3&lt;br /&gt;
} &amp;lt;/code&amp;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;
&amp;lt;code&amp;gt; {&lt;br /&gt;
  &amp;quot;36239&amp;quot;: [&lt;br /&gt;
    3970,&lt;br /&gt;
    3972,&lt;br /&gt;
    3975&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;36240&amp;quot;: [&lt;br /&gt;
    3973,&lt;br /&gt;
    3974,&lt;br /&gt;
    3972&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;36241&amp;quot;: [&lt;br /&gt;
    3969,&lt;br /&gt;
    3971,&lt;br /&gt;
    3972&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;36242&amp;quot;: [&lt;br /&gt;
    3969,&lt;br /&gt;
    3971,&lt;br /&gt;
    3973&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;36243&amp;quot;: [&lt;br /&gt;
    3969,&lt;br /&gt;
    3970,&lt;br /&gt;
    3971&lt;br /&gt;
  ]&lt;br /&gt;
}&amp;lt;/code&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;
===   ''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/RSpec Testing ''   ===&lt;br /&gt;
RSpec tests will need to be written to related controller(s) and model(s). &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== RSpec Testing Plan ====&lt;br /&gt;
These RSpec tests:&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;
:# [https://docs.google.com/document/d/1tXmwju6R7KQbvycku-bdXxa6rXSUN4BMyvjY3ROmMSw/edit Set up Expertiza] on personal device using [https://github.com/uahamedncsu/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;
==Team==&lt;br /&gt;
Ummu Kolusum Yasmin Ahamed Adam (uahamed) &amp;lt;br&amp;gt;&lt;br /&gt;
Ryan Grainger (rpgraing) &amp;lt;br&amp;gt;&lt;br /&gt;
Luis Delossantos (lgdeloss) &amp;lt;br&amp;gt;&lt;br /&gt;
Colleen &amp;quot;Bria&amp;quot; Engen (ceengen) &amp;lt;br&amp;gt;&lt;br /&gt;
'''Mentor:''' Saurabh Shingte (svshingt)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
''Previous Implementations'': [[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review 1]], [[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/uahamedncsu/expertiza/tree/beta &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/uahamedncsu/IntelligentAssignment &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/1822 &amp;lt;br&amp;gt;&lt;br /&gt;
''Expertiza Server'': http://152.7.99.70:8081/ &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': https://app-csc517.herokuapp.com/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
''Video Demo'': https://www.screencast.com/t/GJNOcfa9Ln &amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review&amp;diff=141777</id>
		<title>CSC/ECE 517 Fall 2020 - E2085. Allow reviewers to bid on what to review</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review&amp;diff=141777"/>
		<updated>2021-11-28T20:32:34Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: /* Method: set_priority */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Project Overview==&lt;br /&gt;
===   ''Background''   ===&lt;br /&gt;
Assigning reviews to users is a complicated process. Currently, reviews are still assigned using a first-come-first-served basis. However, reviews could be bid on like how topics are bid on. This would involve matching multiple students to review a submission up to the maximum reviewers for a submission.The manual selection process can be replaced with an automated bidding approach for this purpose.&lt;br /&gt;
&lt;br /&gt;
===   ''Objectives''   ===&lt;br /&gt;
# Implement top trading cycles on a web service. &lt;br /&gt;
# Add front end code to allow bidding on topics and call the appropriate web service from the lottery controller. &lt;br /&gt;
# Add working test cases to test the new changes.&lt;br /&gt;
# Code should be inclined to the Beta branch&lt;br /&gt;
# Link to run bidding assignment should be on the page associated with the assignment actions.&lt;br /&gt;
# Code such as getter methods should be added to the model and not the controller.&lt;br /&gt;
#The number of reviews created by default needs to be checked. One way of achieving this is creating minimum reviews and then allowing users to request more reviews if required.&lt;br /&gt;
&lt;br /&gt;
===   ''Previous Work''   ===&lt;br /&gt;
There have been two 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] &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]&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/uahamedncsu/expertiza/tree/beta &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/uahamedncsu/IntelligentAssignment &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/1822 &amp;lt;br&amp;gt;&lt;br /&gt;
''Expertiza Server'': http://152.7.99.70:8081/ &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': https://app-csc517.herokuapp.com/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
''Video Demo'': https://www.screencast.com/t/GJNOcfa9Ln &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;
*config/routes.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*config/webservices.yml&lt;br /&gt;
&lt;br /&gt;
*app/controllers/student_review_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/assignments/edit/_topics.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/student_task/list.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/student_task/view.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*spec/factories/factories.rb &amp;lt;br&amp;gt;&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/controllers/review_bids_controller.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/helpers/review_bids_helper.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/models/review_bid.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/_all_actions.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/_table_header.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/_table_line.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/_topic_names.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/others_work.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/show.html.erb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*db/migrate/20201107203204_create_review_bids.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*spec/controllers/review_bids_controller_spec.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*spec/models/review_bid_spec.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Design==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===   ''User Interface''   ===&lt;br /&gt;
&lt;br /&gt;
Currently, the users are offered the entire list of topics to review and are asked to select a topic to begin a review. Topics that cannot be reviewed or have already been reviewed the maximum number of times are greyed out and cannot be selected. There is also a check box in which the student can select &amp;quot;I don't care which topic I review&amp;quot; and will be randomly assigned a topic from the list. The current User Interface (UI) for this is shown below.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:current_review_UI.PNG]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As discussed in the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Project_Overview Project Overview] section, a bidding system similar to the bidding system used in topic selection is preferable to the current review selection system. The UI for this process will mirror the UI for the topic bidding system. The new UI will allow users to drag a topic from a list of all the topics on the left, to their priority list on the right. The ordering of the right list indicates the priority of the users preference. The colors indicate the likelihood of being assigned that topic. By utilizing the same UI, the consistency of the user experience and the DRY-ness of the code are increased. An example of the topic selection bidding UI is shown below.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:expected_review_UI.PNG]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Currently, an instructor has the option while creating or editing an assignment to allow a reviewers to select the topics they want to review. This is done by checking '''Has teams?''' and '''Has topics?''' in the '''General''' tab of an assignment then checking '''Allow reviewer to choose which topic to review?''' in the '''Topics''' tab. This interface can be used for allowing review bidding either by editing the current check box or adding an additional check box for '''Allow reviewer to bid on topics to review?'''.  &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Instructor_ui_for_review_bidding.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== ''Analyzing the problem'' ===&lt;br /&gt;
&lt;br /&gt;
Currently, the student can either pick a topic or is randomly assigned a topic, from among the ones that are currently eligible to be reviewed. &amp;lt;br&amp;gt;In this scenario, it is possible that some good topics are already picked by a lot of students and if someone is late to do the selecting, they miss out on it since it is grayed out.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To solve the above problem of not getting the topics they like, the participants must be assigned topics based on a list of topics they pre-select. &lt;br /&gt;
This is where an algorithm will come in handy. For picking a suitable algorithm, we should first identify the type of the problem.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Type of problem&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Each student should be able to bid on multiple assignments of their choice and the same assignment can be assigned to multiple participants for review.&amp;lt;br&amp;gt;&lt;br /&gt;
This requires a Many to Many mapping.&lt;br /&gt;
&lt;br /&gt;
                                        [[File:many2.png]]&lt;br /&gt;
&lt;br /&gt;
The algorithm of choice for this type of stable allocations is Gale-Shapely algorithm.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the real world, there are cases where we face this problem:&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt; Student choosing their future universities [https://www.jstor.org/stable/3132114?seq=1&amp;amp;cid=pdf-reference#references_tab_content '''School Choice Problem'''] (One-to-Many)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Men and women seeking each other to create families [https://en.wikipedia.org/wiki/Stable_marriage_problem '''Stable Marriage Problem'''] (One-to-One)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Internet services that need to be connected with users with the smallest amount of time &amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===''Algorithm Implementation for matching students and topics''===&lt;br /&gt;
The Gale-Shapely Algorithm has steps to make sure it is a Stable marriage/allocation.&lt;br /&gt;
An unstable allocation is when the participant does not like the topic assigned to them. &lt;br /&gt;
But it can happen that the participant 1 might like the review topic assigned to participant 2 and participant 2 likes the topic assigned to participant 1.&lt;br /&gt;
This is the unstable case. To make it stable, the topics need to be exchanged between these 2 participants so that both of them get the topic they wanted.&lt;br /&gt;
&lt;br /&gt;
[[File:Snippy2.png]]&lt;br /&gt;
Source: [https://www.journalajrcos.com/index.php/AJRCOS/article/view/24749/46281 Stable Marriage Algorithm]&lt;br /&gt;
&lt;br /&gt;
===''Assignment of priority ''===&lt;br /&gt;
When a student places a bid, the timestamp is recorded. Priority will be given to the earlier bidder. If the student had chosen only very few bids, then this person will be given a higher priority. Any topics that were not selected by the participant are added to bottom of their preference list in a random preference order to create a situation where &amp;lt;b&amp;gt;the number of students and number of topics is equal. &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===''Algorithm Steps ''===&lt;br /&gt;
&amp;lt;li&amp;gt; For the first round, the Algorithm will assign topics to each student based on the Priority and each topic is assigned to a limited number of students based on the Limit. It picks one topic and begins assigning students to it. (Note: The Algorithm makes sure the participant is not in a group that worked on this particular topic.) &lt;br /&gt;
&amp;lt;li&amp;gt;If the one topic is assigned to enough participants already, then it is removed from the queue and the same process is repeated for the next topic. &lt;br /&gt;
&amp;lt;li&amp;gt; As this goes on, all students are matched even if all matches are not stable at this point.&lt;br /&gt;
&amp;lt;li&amp;gt; The Algorithm terminates when all Topics that have not reached the maximum assignment level have tried to accept every student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;The time complexity of this algorithm is O(n^2) &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===''Simulation ''===&lt;br /&gt;
&lt;br /&gt;
[[File:gale-shapeley-1.png]]&lt;br /&gt;
[[File:gale-shapeley-2.png]]&lt;br /&gt;
&lt;br /&gt;
In the simulation above, we have equal number of Students (S1, S2, S3) and Review topics to assign (R1, R2, R3). The students preference of topics is to left of student. The Review topics does not have any preferences. To have preferences, the timestamps are used to determine which student bid on each topic first to create such a Preference list for topics.&lt;br /&gt;
&lt;br /&gt;
# Phase 1: Both Students S1 and S2 have selected R2 as their highest preference. Since there is a conflict, The preference of R2 is checked which shows that S2 had bid earlier than S1. Thus, the topic R2 is assigned to student S2.&lt;br /&gt;
# Phase 2: Now, S1 and S3 both want to review R1 but R1 was first bid on by S1 as shown in the preference. Hence, R1 is assigned to S1.&lt;br /&gt;
# Phase 3: The only topic remaining in this case is R3 which is also on the preference list of Student S3. Therefore S3 is assigned the topic R3.&lt;br /&gt;
#By the end of the 3 phases, All students are assigned to a Review. The same process needs to be repeated till the required number of reviews are assigned to each student. In each iteration, if a review is assigned to max number of students already, the review is removed from consideration.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
This section details the implementation of the code and will highlight each component of the design in the code and its intended purpose, as well as any modifications or testing. As the implementation progresses this section will be updated.&lt;br /&gt;
&lt;br /&gt;
===   ''Overview''   ===&lt;br /&gt;
&lt;br /&gt;
This project was split into 2 objectives, the Expertiza MVC implementation and the webservice algorithm. The Expertiza MVC follows the MVC standard such that the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Controller controller] handles directing the users to the correct views, as well as handling the communication with the webservice. The [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Model model] performs all necessary computations and data handling like the creation and storing of bids on reviews and assigning reviews to students. The [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Views views] render the corresponding webpage based on the actions of the user. The [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Webservice webservice] contains the algorithm outlined in the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Algorithm_Implementation_for_matching_students_and_topics Algorithm Implementation] section of Design. Our Expertiza controller sends this webservice bidding information and the algorithm returns the matched topics to be assigned. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== ''Controller'' ===&lt;br /&gt;
The controller contains 6 methods that perform all the necessary functions. The first method, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_action_allowed? &amp;quot;action_allowed?&amp;quot;] performs authentication checks The second, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_index &amp;quot;index&amp;quot;], is used to redirect the user to a list of assigned reviews after the algorithm has been run. The third, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_show &amp;quot;show&amp;quot;], is used in conjunction with fourth, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_set_priority &amp;quot;set_priority&amp;quot;], to update and store the bids when users make changes in the bidding page. The fifth, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_assign_bidding &amp;quot;assign_bidding&amp;quot;], utilizes the sixth, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_run_bidding_algorithm &amp;quot;run_bidding_algorithm&amp;quot;], to connect to the webservice, send and receive the correct bidding information for the algorithm. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: action_allowed? ======&lt;br /&gt;
This method performs authentication by allowing only certain types of users to access controller methods. The first portion of this method allows users 'Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator', and 'Student' to access the methods 'show', 'set_priority', and 'index'. These are the methods that render the bidding pages and review listings. The other methods are restricted for 'Student' users. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller action allowed..PNG]] &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: index ======&lt;br /&gt;
This method collects all the necessary information about the user, Assignment details, and Review Mapping details to render the 'review_bids/others_work', which lists the reviews that are assigned to the user. This page also includes a button to request more reviews which will add reviews up to the maximum number of reviews. To see the view rendered by this method, please go to [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#View:_others_work.html.erb &amp;quot;others_work&amp;quot;].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_index.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: show ======&lt;br /&gt;
This method renders the bidding page in which participants can select from a table of topics the topics they would prefer to review. It collects the necessary information about the user, Assignment, Topics, and current Review Bids to render this page. It is used in conjunction with [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_set_priority set_priority] where the users bidding information is stored, and the page updated. To see the bidding page that this function renders, visit the view [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#View:_show.html.erb &amp;quot;show&amp;quot;] &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_show.PNG]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: set_priority ======&lt;br /&gt;
In the view file [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#view:_show.html.erb &amp;quot;show&amp;quot;] there exists a line the calls this method when the page is updated or accessed. This method stores the user's bidding information in the schema database. This allows the model to access this information when collecting all the bidding information, as well as allowing users to refresh or return to this page with their selections staying in the bid table. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_set_priority.PNG]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_bidding ======&lt;br /&gt;
This method utilizes methods in the model, as well as the method [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_run_bidding_algorithm &amp;quot;run_bidding_algorithm&amp;quot;] to collect the bidding information of all students of a particular Assignment, send it to the webservice algorithm, store the matched topics that are returned, and pass these matched topics to the model to be assigned. After this method is run, the students should have assigned reviews and bidding should be turned off.&lt;br /&gt;
[[File:Controller_assign_bidding.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: run_bidding_algorithm ======&lt;br /&gt;
This method connects to the webservice using RestClient API, which is part of the 'require's at the top of the Controller. It will return a false if the connection fails for ay reason such as connection is not established or the algorithm has an internal error, otherwise it returns the matched topics from the algorithm as a 'json'. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_requirements.PNG]] &amp;lt;br&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_run_bidding_algorithm.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== ''Model '' ===&lt;br /&gt;
The model contains 5 methods that are utilized by the controller to save bidding information per user or all users, retrieve bidding information per user or for all users, and assign topics to review to participants.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: get_bidding_data ======&lt;br /&gt;
This method is called by the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_assign_bidding &amp;quot;assign_bidding&amp;quot;] controller method. It receives the Assignment ID and a list of reviewers, which are student IDs. It creates a Hash to store bidding data into and iterates through all of the reviewers, calling [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_reviewer_bidding_data &amp;quot;reviewer_bidding_data&amp;quot;] to get each students bidding data and store it in the Hash. It returns a Hash with all the bidding data needed for the Webservice Algorithm to run.&lt;br /&gt;
[[File:Model_get_bidding_data.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_review_topics ======&lt;br /&gt;
This method is called by the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_assign_bidding &amp;quot;assign_bidding&amp;quot;] controller method. Given the Assignment ID, list of reviewers, and the matched topics returned by the webservice algorithm, it first clears any previously assigned reviews for that Assignment to prevent multiple assigns, then iterates through each reviewer and assigns them to the topics that the algorithm selected for them.&lt;br /&gt;
[[File:Model_assign_review_topics.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_topic_to_reviewer ======&lt;br /&gt;
This method is called by the method [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_assign_review_topics &amp;quot;assign_review_topics&amp;quot;] and assigns a single topic to a single user to review given an Assignment ID. &lt;br /&gt;
[[File:Model_assign_topic_to_reviewer.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: reviewer_self_topic ======&lt;br /&gt;
This method returns the topic id of the reviewer that is passed in. This method is utilized to retrieve the reviewers' Topic ID, which is needed for the webservice algorithm to prevent users from being assigned to review their own topic. This is also prevented in views, but this is an additional safety precaution. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Model_reviewer_self_topic.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: reviewer_bidding_data ======&lt;br /&gt;
This method is called by [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_get_bidding_data &amp;quot;get_bidding_data&amp;quot;]. It creates a hash to store all the reviewer's bidding information. It iterates through all the bids for a reviewer given the Assignment ID and it returns a Hash of the bidding data.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Model_reviewer_bidding_data.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== ''Views'' ===&lt;br /&gt;
There are two main views for this project. They are for bidding and for showing assigned reviews after the bidding algorithm has been run. &lt;br /&gt;
====== View: others_work.html.erb ======&lt;br /&gt;
This file renders the view where students see a list of the reviews they've been assigned, with appropriate links and related messages. It includes a &amp;quot;Request Additional Review&amp;quot; button that will allow students to view more reviews up to the max number of reviews allowed. &lt;br /&gt;
[[File:Views_others_work_pt1.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_others_work_pt2.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_others_work_pt3.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_others_work_pt4.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
View rendered by above:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_others_work_rendered.PNG]]&lt;br /&gt;
&lt;br /&gt;
====== View: show.html.erb ======&lt;br /&gt;
This view file renders the Review Bidding page where participants can select which topics to review. It renders partials which are included below, and includes coloring effects from helper methods indicating likelihood of receiving that particular topic to review. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_show_pt1.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_show_pt2.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Page rendered by above: (This rendering is an instructor view, the student view is the same without the &amp;quot;Edit Topics&amp;quot; column.) &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_show_rendered.PNG|900px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&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. This json will have a list of all topics, list of all students and the topics each student selected and also the maximum number of review topics per student. Also, it has the timestamp information of the bidding time to give preference to early bidders. The input json is passed to the JsonParser class to create a Dictionary.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:tab.jpg]]&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 parser also creates a preferences dictionary for the Student to store their topic preferences and &lt;br /&gt;
one for Topics to store list of topics which have been selected by students and also the priority for the selection using the Timestamps.&lt;br /&gt;
The json parser does one more task of finding Popular topics. This is needed because topics that are in demand should be preserved for students who bid on it and to avoid assigning it to students who did not bid on anything. High demand topics are assigned a lower priority for such students so that there are other topics they can be assigned.&lt;br /&gt;
&lt;br /&gt;
[[File:json1.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:json2.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:json3.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''Class Topic'' =====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Topic class is the one that does the proposing to the students during the runtime. &lt;br /&gt;
There are 2 cases. In case 1 when the particular topic is asked by more students than the limit of number of students the one topic can be assigned to. In this case, it uses the priorities it already has in the dictionary to make sure the topic proposes only to those students who chose it and those who bid earlier.&lt;br /&gt;
In Case 2, There are less students who asked for the topic. Hence, the topic can propose to all the students who asked for it and still be under the limit. In the end of this step. All topics make their proposals to be assigned to some students.&lt;br /&gt;
&lt;br /&gt;
[[File:json11.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''Class Student'' =====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Once the Topics propose to students, the Student has to accept some of the proposals.&lt;br /&gt;
First, each student sorts the proposals based on the students preferences. Now, the student accepts all the proposals they can upto the number of slots remaining for them. The max slots for the student is determined by the max_proposals_accepted field in the json. Once the acceptance is complete, the Topics are all updated so that the topics can adjust their remaining slots accordingly.&lt;br /&gt;
&lt;br /&gt;
[[File:json12.png]]&lt;br /&gt;
&lt;br /&gt;
===== ''Topic Matcher'' =====&lt;br /&gt;
&lt;br /&gt;
Next, The Topics Matcher class is called which is the main class that runs the Algorithm.&lt;br /&gt;
Before running the algorithm, it creates a list of Student and Topic objects by using instances of Student and Topic class. Each student and Topic now has its own class so that it can be used to make proposals for assignment of topics.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:json4.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The get_student_topic_matches() method kicks off the Algorithm.&lt;br /&gt;
Each topic proposes to students based on the topic priorities as covered in the Topics section. It uses a max_topic_assignment_limit (say 4 for example) to make sure the same topic is not assigned to too many students. &lt;br /&gt;
Once the proposals are made, we iterate over students so that they can accept proposals as long as they have slots remaining to be assigned to.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
The round is now complete. To determine if we need a next round, we ask the topics if they are done proposing using is_topics_done_proposing() method. As long as each topic has not reached its assignment limit and there are still students to propose to, the proposing continues for the next round. &lt;br /&gt;
Once every topic is done, it breaks out of the loop and we now have the list of students with equal number of assigned topics ( 3-4 for example) and this list is returned back to Expertiza as the Stable matching to do the assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:json5.png]]&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;
&amp;lt;code&amp;gt;{&lt;br /&gt;
  &amp;quot;tid&amp;quot;: [&lt;br /&gt;
    3969,3970,3971,3972,3973,3974,3975,3976,3977&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;users&amp;quot;: {&lt;br /&gt;
    &amp;quot;36239&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [&lt;br /&gt;
        3970, 3972&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3977,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [&lt;br /&gt;
        2,1&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;time&amp;quot;: [&lt;br /&gt;
        &amp;quot;Thu, 12 Nov 2020 12:01:06 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 12:01:07 EST -05:00&amp;quot;&lt;br /&gt;
      ]&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;36240&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3976,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [],&lt;br /&gt;
      &amp;quot;time&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;36241&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [&lt;br /&gt;
        3969,3971,3972&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3975,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [&lt;br /&gt;
        1,3,2&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;time&amp;quot;: [&lt;br /&gt;
        &amp;quot;Thu, 12 Nov 2020 12:00:22 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 12:00:25 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 12:00:27 EST -05:00&amp;quot;&lt;br /&gt;
      ]&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;36242&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [&lt;br /&gt;
        3969,3971,3973&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3974,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [&lt;br /&gt;
        3,2,1&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;time&amp;quot;: [&lt;br /&gt;
        &amp;quot;Wed, 11 Nov 2020 12:15:43 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 11:59:40 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 13:07:53 EST -05:00&amp;quot;&lt;br /&gt;
      ]&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;36243&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [&lt;br /&gt;
        3971,3969,3970,3976&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3972,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [&lt;br /&gt;
        4,3,2,1,5&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;time&amp;quot;: [&lt;br /&gt;
        &amp;quot;Wed, 11 Nov 2020 11:34:50 EST -05:00&amp;quot;,&amp;quot;Wed, 11 Nov 2020 12:30:16 EST -05:00&amp;quot;,&amp;quot;Wed, 11 Nov 2020 12:30:19 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 13:02:02 EST -05:00&amp;quot;&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  },&lt;br /&gt;
  &amp;quot;max_accepted_proposals&amp;quot;: 3&lt;br /&gt;
} &amp;lt;/code&amp;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;
&amp;lt;code&amp;gt; {&lt;br /&gt;
  &amp;quot;36239&amp;quot;: [&lt;br /&gt;
    3970,&lt;br /&gt;
    3972,&lt;br /&gt;
    3975&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;36240&amp;quot;: [&lt;br /&gt;
    3973,&lt;br /&gt;
    3974,&lt;br /&gt;
    3972&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;36241&amp;quot;: [&lt;br /&gt;
    3969,&lt;br /&gt;
    3971,&lt;br /&gt;
    3972&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;36242&amp;quot;: [&lt;br /&gt;
    3969,&lt;br /&gt;
    3971,&lt;br /&gt;
    3973&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;36243&amp;quot;: [&lt;br /&gt;
    3969,&lt;br /&gt;
    3970,&lt;br /&gt;
    3971&lt;br /&gt;
  ]&lt;br /&gt;
}&amp;lt;/code&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;
===   ''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/RSpec Testing ''   ===&lt;br /&gt;
RSpec tests will need to be written to related controller(s) and model(s). &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== RSpec Testing Plan ====&lt;br /&gt;
These RSpec tests:&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;
:# [https://docs.google.com/document/d/1tXmwju6R7KQbvycku-bdXxa6rXSUN4BMyvjY3ROmMSw/edit Set up Expertiza] on personal device using [https://github.com/uahamedncsu/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;
==Team==&lt;br /&gt;
Ummu Kolusum Yasmin Ahamed Adam (uahamed) &amp;lt;br&amp;gt;&lt;br /&gt;
Ryan Grainger (rpgraing) &amp;lt;br&amp;gt;&lt;br /&gt;
Luis Delossantos (lgdeloss) &amp;lt;br&amp;gt;&lt;br /&gt;
Colleen &amp;quot;Bria&amp;quot; Engen (ceengen) &amp;lt;br&amp;gt;&lt;br /&gt;
'''Mentor:''' Saurabh Shingte (svshingt)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
''Previous Implementations'': [[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review 1]], [[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/uahamedncsu/expertiza/tree/beta &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/uahamedncsu/IntelligentAssignment &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/1822 &amp;lt;br&amp;gt;&lt;br /&gt;
''Expertiza Server'': http://152.7.99.70:8081/ &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': https://app-csc517.herokuapp.com/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
''Video Demo'': https://www.screencast.com/t/GJNOcfa9Ln &amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review&amp;diff=141776</id>
		<title>CSC/ECE 517 Fall 2020 - E2085. Allow reviewers to bid on what to review</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review&amp;diff=141776"/>
		<updated>2021-11-28T20:32:20Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: /* Method: index */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Project Overview==&lt;br /&gt;
===   ''Background''   ===&lt;br /&gt;
Assigning reviews to users is a complicated process. Currently, reviews are still assigned using a first-come-first-served basis. However, reviews could be bid on like how topics are bid on. This would involve matching multiple students to review a submission up to the maximum reviewers for a submission.The manual selection process can be replaced with an automated bidding approach for this purpose.&lt;br /&gt;
&lt;br /&gt;
===   ''Objectives''   ===&lt;br /&gt;
# Implement top trading cycles on a web service. &lt;br /&gt;
# Add front end code to allow bidding on topics and call the appropriate web service from the lottery controller. &lt;br /&gt;
# Add working test cases to test the new changes.&lt;br /&gt;
# Code should be inclined to the Beta branch&lt;br /&gt;
# Link to run bidding assignment should be on the page associated with the assignment actions.&lt;br /&gt;
# Code such as getter methods should be added to the model and not the controller.&lt;br /&gt;
#The number of reviews created by default needs to be checked. One way of achieving this is creating minimum reviews and then allowing users to request more reviews if required.&lt;br /&gt;
&lt;br /&gt;
===   ''Previous Work''   ===&lt;br /&gt;
There have been two 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] &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]&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/uahamedncsu/expertiza/tree/beta &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/uahamedncsu/IntelligentAssignment &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/1822 &amp;lt;br&amp;gt;&lt;br /&gt;
''Expertiza Server'': http://152.7.99.70:8081/ &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': https://app-csc517.herokuapp.com/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
''Video Demo'': https://www.screencast.com/t/GJNOcfa9Ln &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;
*config/routes.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*config/webservices.yml&lt;br /&gt;
&lt;br /&gt;
*app/controllers/student_review_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/assignments/edit/_topics.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/student_task/list.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/student_task/view.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*spec/factories/factories.rb &amp;lt;br&amp;gt;&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/controllers/review_bids_controller.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/helpers/review_bids_helper.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/models/review_bid.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/_all_actions.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/_table_header.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/_table_line.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/_topic_names.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/others_work.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/show.html.erb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*db/migrate/20201107203204_create_review_bids.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*spec/controllers/review_bids_controller_spec.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*spec/models/review_bid_spec.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Design==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===   ''User Interface''   ===&lt;br /&gt;
&lt;br /&gt;
Currently, the users are offered the entire list of topics to review and are asked to select a topic to begin a review. Topics that cannot be reviewed or have already been reviewed the maximum number of times are greyed out and cannot be selected. There is also a check box in which the student can select &amp;quot;I don't care which topic I review&amp;quot; and will be randomly assigned a topic from the list. The current User Interface (UI) for this is shown below.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:current_review_UI.PNG]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As discussed in the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Project_Overview Project Overview] section, a bidding system similar to the bidding system used in topic selection is preferable to the current review selection system. The UI for this process will mirror the UI for the topic bidding system. The new UI will allow users to drag a topic from a list of all the topics on the left, to their priority list on the right. The ordering of the right list indicates the priority of the users preference. The colors indicate the likelihood of being assigned that topic. By utilizing the same UI, the consistency of the user experience and the DRY-ness of the code are increased. An example of the topic selection bidding UI is shown below.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:expected_review_UI.PNG]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Currently, an instructor has the option while creating or editing an assignment to allow a reviewers to select the topics they want to review. This is done by checking '''Has teams?''' and '''Has topics?''' in the '''General''' tab of an assignment then checking '''Allow reviewer to choose which topic to review?''' in the '''Topics''' tab. This interface can be used for allowing review bidding either by editing the current check box or adding an additional check box for '''Allow reviewer to bid on topics to review?'''.  &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Instructor_ui_for_review_bidding.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== ''Analyzing the problem'' ===&lt;br /&gt;
&lt;br /&gt;
Currently, the student can either pick a topic or is randomly assigned a topic, from among the ones that are currently eligible to be reviewed. &amp;lt;br&amp;gt;In this scenario, it is possible that some good topics are already picked by a lot of students and if someone is late to do the selecting, they miss out on it since it is grayed out.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To solve the above problem of not getting the topics they like, the participants must be assigned topics based on a list of topics they pre-select. &lt;br /&gt;
This is where an algorithm will come in handy. For picking a suitable algorithm, we should first identify the type of the problem.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Type of problem&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Each student should be able to bid on multiple assignments of their choice and the same assignment can be assigned to multiple participants for review.&amp;lt;br&amp;gt;&lt;br /&gt;
This requires a Many to Many mapping.&lt;br /&gt;
&lt;br /&gt;
                                        [[File:many2.png]]&lt;br /&gt;
&lt;br /&gt;
The algorithm of choice for this type of stable allocations is Gale-Shapely algorithm.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the real world, there are cases where we face this problem:&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt; Student choosing their future universities [https://www.jstor.org/stable/3132114?seq=1&amp;amp;cid=pdf-reference#references_tab_content '''School Choice Problem'''] (One-to-Many)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Men and women seeking each other to create families [https://en.wikipedia.org/wiki/Stable_marriage_problem '''Stable Marriage Problem'''] (One-to-One)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Internet services that need to be connected with users with the smallest amount of time &amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===''Algorithm Implementation for matching students and topics''===&lt;br /&gt;
The Gale-Shapely Algorithm has steps to make sure it is a Stable marriage/allocation.&lt;br /&gt;
An unstable allocation is when the participant does not like the topic assigned to them. &lt;br /&gt;
But it can happen that the participant 1 might like the review topic assigned to participant 2 and participant 2 likes the topic assigned to participant 1.&lt;br /&gt;
This is the unstable case. To make it stable, the topics need to be exchanged between these 2 participants so that both of them get the topic they wanted.&lt;br /&gt;
&lt;br /&gt;
[[File:Snippy2.png]]&lt;br /&gt;
Source: [https://www.journalajrcos.com/index.php/AJRCOS/article/view/24749/46281 Stable Marriage Algorithm]&lt;br /&gt;
&lt;br /&gt;
===''Assignment of priority ''===&lt;br /&gt;
When a student places a bid, the timestamp is recorded. Priority will be given to the earlier bidder. If the student had chosen only very few bids, then this person will be given a higher priority. Any topics that were not selected by the participant are added to bottom of their preference list in a random preference order to create a situation where &amp;lt;b&amp;gt;the number of students and number of topics is equal. &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===''Algorithm Steps ''===&lt;br /&gt;
&amp;lt;li&amp;gt; For the first round, the Algorithm will assign topics to each student based on the Priority and each topic is assigned to a limited number of students based on the Limit. It picks one topic and begins assigning students to it. (Note: The Algorithm makes sure the participant is not in a group that worked on this particular topic.) &lt;br /&gt;
&amp;lt;li&amp;gt;If the one topic is assigned to enough participants already, then it is removed from the queue and the same process is repeated for the next topic. &lt;br /&gt;
&amp;lt;li&amp;gt; As this goes on, all students are matched even if all matches are not stable at this point.&lt;br /&gt;
&amp;lt;li&amp;gt; The Algorithm terminates when all Topics that have not reached the maximum assignment level have tried to accept every student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;The time complexity of this algorithm is O(n^2) &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===''Simulation ''===&lt;br /&gt;
&lt;br /&gt;
[[File:gale-shapeley-1.png]]&lt;br /&gt;
[[File:gale-shapeley-2.png]]&lt;br /&gt;
&lt;br /&gt;
In the simulation above, we have equal number of Students (S1, S2, S3) and Review topics to assign (R1, R2, R3). The students preference of topics is to left of student. The Review topics does not have any preferences. To have preferences, the timestamps are used to determine which student bid on each topic first to create such a Preference list for topics.&lt;br /&gt;
&lt;br /&gt;
# Phase 1: Both Students S1 and S2 have selected R2 as their highest preference. Since there is a conflict, The preference of R2 is checked which shows that S2 had bid earlier than S1. Thus, the topic R2 is assigned to student S2.&lt;br /&gt;
# Phase 2: Now, S1 and S3 both want to review R1 but R1 was first bid on by S1 as shown in the preference. Hence, R1 is assigned to S1.&lt;br /&gt;
# Phase 3: The only topic remaining in this case is R3 which is also on the preference list of Student S3. Therefore S3 is assigned the topic R3.&lt;br /&gt;
#By the end of the 3 phases, All students are assigned to a Review. The same process needs to be repeated till the required number of reviews are assigned to each student. In each iteration, if a review is assigned to max number of students already, the review is removed from consideration.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
This section details the implementation of the code and will highlight each component of the design in the code and its intended purpose, as well as any modifications or testing. As the implementation progresses this section will be updated.&lt;br /&gt;
&lt;br /&gt;
===   ''Overview''   ===&lt;br /&gt;
&lt;br /&gt;
This project was split into 2 objectives, the Expertiza MVC implementation and the webservice algorithm. The Expertiza MVC follows the MVC standard such that the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Controller controller] handles directing the users to the correct views, as well as handling the communication with the webservice. The [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Model model] performs all necessary computations and data handling like the creation and storing of bids on reviews and assigning reviews to students. The [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Views views] render the corresponding webpage based on the actions of the user. The [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Webservice webservice] contains the algorithm outlined in the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Algorithm_Implementation_for_matching_students_and_topics Algorithm Implementation] section of Design. Our Expertiza controller sends this webservice bidding information and the algorithm returns the matched topics to be assigned. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== ''Controller'' ===&lt;br /&gt;
The controller contains 6 methods that perform all the necessary functions. The first method, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_action_allowed? &amp;quot;action_allowed?&amp;quot;] performs authentication checks The second, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_index &amp;quot;index&amp;quot;], is used to redirect the user to a list of assigned reviews after the algorithm has been run. The third, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_show &amp;quot;show&amp;quot;], is used in conjunction with fourth, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_set_priority &amp;quot;set_priority&amp;quot;], to update and store the bids when users make changes in the bidding page. The fifth, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_assign_bidding &amp;quot;assign_bidding&amp;quot;], utilizes the sixth, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_run_bidding_algorithm &amp;quot;run_bidding_algorithm&amp;quot;], to connect to the webservice, send and receive the correct bidding information for the algorithm. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: action_allowed? ======&lt;br /&gt;
This method performs authentication by allowing only certain types of users to access controller methods. The first portion of this method allows users 'Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator', and 'Student' to access the methods 'show', 'set_priority', and 'index'. These are the methods that render the bidding pages and review listings. The other methods are restricted for 'Student' users. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller action allowed..PNG]] &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: index ======&lt;br /&gt;
This method collects all the necessary information about the user, Assignment details, and Review Mapping details to render the 'review_bids/others_work', which lists the reviews that are assigned to the user. This page also includes a button to request more reviews which will add reviews up to the maximum number of reviews. To see the view rendered by this method, please go to [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#View:_others_work.html.erb &amp;quot;others_work&amp;quot;].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_index.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: show ======&lt;br /&gt;
This method renders the bidding page in which participants can select from a table of topics the topics they would prefer to review. It collects the necessary information about the user, Assignment, Topics, and current Review Bids to render this page. It is used in conjunction with [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_set_priority set_priority] where the users bidding information is stored, and the page updated. To see the bidding page that this function renders, visit the view [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#View:_show.html.erb &amp;quot;show&amp;quot;] &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_show.PNG]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: set_priority ======&lt;br /&gt;
In the view file [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#view:_show.html.erb &amp;quot;show&amp;quot;] there exists a line the calls this method when the page is updated or accessed. This method stores the user's bidding information in the schema database. This allows the model to access this information when collecting all the bidding information, as well as allowing users to refresh or return to this page with their selections staying in the bid table. &lt;br /&gt;
[[File:Controller_set_priority.PNG]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_bidding ======&lt;br /&gt;
This method utilizes methods in the model, as well as the method [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_run_bidding_algorithm &amp;quot;run_bidding_algorithm&amp;quot;] to collect the bidding information of all students of a particular Assignment, send it to the webservice algorithm, store the matched topics that are returned, and pass these matched topics to the model to be assigned. After this method is run, the students should have assigned reviews and bidding should be turned off.&lt;br /&gt;
[[File:Controller_assign_bidding.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: run_bidding_algorithm ======&lt;br /&gt;
This method connects to the webservice using RestClient API, which is part of the 'require's at the top of the Controller. It will return a false if the connection fails for ay reason such as connection is not established or the algorithm has an internal error, otherwise it returns the matched topics from the algorithm as a 'json'. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_requirements.PNG]] &amp;lt;br&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_run_bidding_algorithm.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== ''Model '' ===&lt;br /&gt;
The model contains 5 methods that are utilized by the controller to save bidding information per user or all users, retrieve bidding information per user or for all users, and assign topics to review to participants.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: get_bidding_data ======&lt;br /&gt;
This method is called by the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_assign_bidding &amp;quot;assign_bidding&amp;quot;] controller method. It receives the Assignment ID and a list of reviewers, which are student IDs. It creates a Hash to store bidding data into and iterates through all of the reviewers, calling [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_reviewer_bidding_data &amp;quot;reviewer_bidding_data&amp;quot;] to get each students bidding data and store it in the Hash. It returns a Hash with all the bidding data needed for the Webservice Algorithm to run.&lt;br /&gt;
[[File:Model_get_bidding_data.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_review_topics ======&lt;br /&gt;
This method is called by the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_assign_bidding &amp;quot;assign_bidding&amp;quot;] controller method. Given the Assignment ID, list of reviewers, and the matched topics returned by the webservice algorithm, it first clears any previously assigned reviews for that Assignment to prevent multiple assigns, then iterates through each reviewer and assigns them to the topics that the algorithm selected for them.&lt;br /&gt;
[[File:Model_assign_review_topics.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_topic_to_reviewer ======&lt;br /&gt;
This method is called by the method [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_assign_review_topics &amp;quot;assign_review_topics&amp;quot;] and assigns a single topic to a single user to review given an Assignment ID. &lt;br /&gt;
[[File:Model_assign_topic_to_reviewer.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: reviewer_self_topic ======&lt;br /&gt;
This method returns the topic id of the reviewer that is passed in. This method is utilized to retrieve the reviewers' Topic ID, which is needed for the webservice algorithm to prevent users from being assigned to review their own topic. This is also prevented in views, but this is an additional safety precaution. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Model_reviewer_self_topic.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: reviewer_bidding_data ======&lt;br /&gt;
This method is called by [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_get_bidding_data &amp;quot;get_bidding_data&amp;quot;]. It creates a hash to store all the reviewer's bidding information. It iterates through all the bids for a reviewer given the Assignment ID and it returns a Hash of the bidding data.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Model_reviewer_bidding_data.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== ''Views'' ===&lt;br /&gt;
There are two main views for this project. They are for bidding and for showing assigned reviews after the bidding algorithm has been run. &lt;br /&gt;
====== View: others_work.html.erb ======&lt;br /&gt;
This file renders the view where students see a list of the reviews they've been assigned, with appropriate links and related messages. It includes a &amp;quot;Request Additional Review&amp;quot; button that will allow students to view more reviews up to the max number of reviews allowed. &lt;br /&gt;
[[File:Views_others_work_pt1.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_others_work_pt2.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_others_work_pt3.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_others_work_pt4.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
View rendered by above:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_others_work_rendered.PNG]]&lt;br /&gt;
&lt;br /&gt;
====== View: show.html.erb ======&lt;br /&gt;
This view file renders the Review Bidding page where participants can select which topics to review. It renders partials which are included below, and includes coloring effects from helper methods indicating likelihood of receiving that particular topic to review. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_show_pt1.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_show_pt2.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Page rendered by above: (This rendering is an instructor view, the student view is the same without the &amp;quot;Edit Topics&amp;quot; column.) &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_show_rendered.PNG|900px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&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. This json will have a list of all topics, list of all students and the topics each student selected and also the maximum number of review topics per student. Also, it has the timestamp information of the bidding time to give preference to early bidders. The input json is passed to the JsonParser class to create a Dictionary.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:tab.jpg]]&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 parser also creates a preferences dictionary for the Student to store their topic preferences and &lt;br /&gt;
one for Topics to store list of topics which have been selected by students and also the priority for the selection using the Timestamps.&lt;br /&gt;
The json parser does one more task of finding Popular topics. This is needed because topics that are in demand should be preserved for students who bid on it and to avoid assigning it to students who did not bid on anything. High demand topics are assigned a lower priority for such students so that there are other topics they can be assigned.&lt;br /&gt;
&lt;br /&gt;
[[File:json1.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:json2.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:json3.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''Class Topic'' =====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Topic class is the one that does the proposing to the students during the runtime. &lt;br /&gt;
There are 2 cases. In case 1 when the particular topic is asked by more students than the limit of number of students the one topic can be assigned to. In this case, it uses the priorities it already has in the dictionary to make sure the topic proposes only to those students who chose it and those who bid earlier.&lt;br /&gt;
In Case 2, There are less students who asked for the topic. Hence, the topic can propose to all the students who asked for it and still be under the limit. In the end of this step. All topics make their proposals to be assigned to some students.&lt;br /&gt;
&lt;br /&gt;
[[File:json11.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''Class Student'' =====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Once the Topics propose to students, the Student has to accept some of the proposals.&lt;br /&gt;
First, each student sorts the proposals based on the students preferences. Now, the student accepts all the proposals they can upto the number of slots remaining for them. The max slots for the student is determined by the max_proposals_accepted field in the json. Once the acceptance is complete, the Topics are all updated so that the topics can adjust their remaining slots accordingly.&lt;br /&gt;
&lt;br /&gt;
[[File:json12.png]]&lt;br /&gt;
&lt;br /&gt;
===== ''Topic Matcher'' =====&lt;br /&gt;
&lt;br /&gt;
Next, The Topics Matcher class is called which is the main class that runs the Algorithm.&lt;br /&gt;
Before running the algorithm, it creates a list of Student and Topic objects by using instances of Student and Topic class. Each student and Topic now has its own class so that it can be used to make proposals for assignment of topics.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:json4.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The get_student_topic_matches() method kicks off the Algorithm.&lt;br /&gt;
Each topic proposes to students based on the topic priorities as covered in the Topics section. It uses a max_topic_assignment_limit (say 4 for example) to make sure the same topic is not assigned to too many students. &lt;br /&gt;
Once the proposals are made, we iterate over students so that they can accept proposals as long as they have slots remaining to be assigned to.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
The round is now complete. To determine if we need a next round, we ask the topics if they are done proposing using is_topics_done_proposing() method. As long as each topic has not reached its assignment limit and there are still students to propose to, the proposing continues for the next round. &lt;br /&gt;
Once every topic is done, it breaks out of the loop and we now have the list of students with equal number of assigned topics ( 3-4 for example) and this list is returned back to Expertiza as the Stable matching to do the assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:json5.png]]&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;
&amp;lt;code&amp;gt;{&lt;br /&gt;
  &amp;quot;tid&amp;quot;: [&lt;br /&gt;
    3969,3970,3971,3972,3973,3974,3975,3976,3977&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;users&amp;quot;: {&lt;br /&gt;
    &amp;quot;36239&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [&lt;br /&gt;
        3970, 3972&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3977,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [&lt;br /&gt;
        2,1&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;time&amp;quot;: [&lt;br /&gt;
        &amp;quot;Thu, 12 Nov 2020 12:01:06 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 12:01:07 EST -05:00&amp;quot;&lt;br /&gt;
      ]&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;36240&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3976,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [],&lt;br /&gt;
      &amp;quot;time&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;36241&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [&lt;br /&gt;
        3969,3971,3972&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3975,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [&lt;br /&gt;
        1,3,2&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;time&amp;quot;: [&lt;br /&gt;
        &amp;quot;Thu, 12 Nov 2020 12:00:22 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 12:00:25 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 12:00:27 EST -05:00&amp;quot;&lt;br /&gt;
      ]&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;36242&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [&lt;br /&gt;
        3969,3971,3973&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3974,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [&lt;br /&gt;
        3,2,1&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;time&amp;quot;: [&lt;br /&gt;
        &amp;quot;Wed, 11 Nov 2020 12:15:43 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 11:59:40 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 13:07:53 EST -05:00&amp;quot;&lt;br /&gt;
      ]&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;36243&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [&lt;br /&gt;
        3971,3969,3970,3976&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3972,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [&lt;br /&gt;
        4,3,2,1,5&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;time&amp;quot;: [&lt;br /&gt;
        &amp;quot;Wed, 11 Nov 2020 11:34:50 EST -05:00&amp;quot;,&amp;quot;Wed, 11 Nov 2020 12:30:16 EST -05:00&amp;quot;,&amp;quot;Wed, 11 Nov 2020 12:30:19 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 13:02:02 EST -05:00&amp;quot;&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  },&lt;br /&gt;
  &amp;quot;max_accepted_proposals&amp;quot;: 3&lt;br /&gt;
} &amp;lt;/code&amp;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;
&amp;lt;code&amp;gt; {&lt;br /&gt;
  &amp;quot;36239&amp;quot;: [&lt;br /&gt;
    3970,&lt;br /&gt;
    3972,&lt;br /&gt;
    3975&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;36240&amp;quot;: [&lt;br /&gt;
    3973,&lt;br /&gt;
    3974,&lt;br /&gt;
    3972&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;36241&amp;quot;: [&lt;br /&gt;
    3969,&lt;br /&gt;
    3971,&lt;br /&gt;
    3972&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;36242&amp;quot;: [&lt;br /&gt;
    3969,&lt;br /&gt;
    3971,&lt;br /&gt;
    3973&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;36243&amp;quot;: [&lt;br /&gt;
    3969,&lt;br /&gt;
    3970,&lt;br /&gt;
    3971&lt;br /&gt;
  ]&lt;br /&gt;
}&amp;lt;/code&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;
===   ''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/RSpec Testing ''   ===&lt;br /&gt;
RSpec tests will need to be written to related controller(s) and model(s). &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== RSpec Testing Plan ====&lt;br /&gt;
These RSpec tests:&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;
:# [https://docs.google.com/document/d/1tXmwju6R7KQbvycku-bdXxa6rXSUN4BMyvjY3ROmMSw/edit Set up Expertiza] on personal device using [https://github.com/uahamedncsu/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;
==Team==&lt;br /&gt;
Ummu Kolusum Yasmin Ahamed Adam (uahamed) &amp;lt;br&amp;gt;&lt;br /&gt;
Ryan Grainger (rpgraing) &amp;lt;br&amp;gt;&lt;br /&gt;
Luis Delossantos (lgdeloss) &amp;lt;br&amp;gt;&lt;br /&gt;
Colleen &amp;quot;Bria&amp;quot; Engen (ceengen) &amp;lt;br&amp;gt;&lt;br /&gt;
'''Mentor:''' Saurabh Shingte (svshingt)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
''Previous Implementations'': [[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review 1]], [[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/uahamedncsu/expertiza/tree/beta &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/uahamedncsu/IntelligentAssignment &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/1822 &amp;lt;br&amp;gt;&lt;br /&gt;
''Expertiza Server'': http://152.7.99.70:8081/ &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': https://app-csc517.herokuapp.com/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
''Video Demo'': https://www.screencast.com/t/GJNOcfa9Ln &amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review&amp;diff=141775</id>
		<title>CSC/ECE 517 Fall 2020 - E2085. Allow reviewers to bid on what to review</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review&amp;diff=141775"/>
		<updated>2021-11-28T20:31:57Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: /* Controller */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Project Overview==&lt;br /&gt;
===   ''Background''   ===&lt;br /&gt;
Assigning reviews to users is a complicated process. Currently, reviews are still assigned using a first-come-first-served basis. However, reviews could be bid on like how topics are bid on. This would involve matching multiple students to review a submission up to the maximum reviewers for a submission.The manual selection process can be replaced with an automated bidding approach for this purpose.&lt;br /&gt;
&lt;br /&gt;
===   ''Objectives''   ===&lt;br /&gt;
# Implement top trading cycles on a web service. &lt;br /&gt;
# Add front end code to allow bidding on topics and call the appropriate web service from the lottery controller. &lt;br /&gt;
# Add working test cases to test the new changes.&lt;br /&gt;
# Code should be inclined to the Beta branch&lt;br /&gt;
# Link to run bidding assignment should be on the page associated with the assignment actions.&lt;br /&gt;
# Code such as getter methods should be added to the model and not the controller.&lt;br /&gt;
#The number of reviews created by default needs to be checked. One way of achieving this is creating minimum reviews and then allowing users to request more reviews if required.&lt;br /&gt;
&lt;br /&gt;
===   ''Previous Work''   ===&lt;br /&gt;
There have been two 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] &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]&lt;br /&gt;
&lt;br /&gt;
===   ''Relevant Links''   ===&lt;br /&gt;
''Github Repository for Expertiza'': https://github.com/uahamedncsu/expertiza/tree/beta &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/uahamedncsu/IntelligentAssignment &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/1822 &amp;lt;br&amp;gt;&lt;br /&gt;
''Expertiza Server'': http://152.7.99.70:8081/ &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': https://app-csc517.herokuapp.com/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
''Video Demo'': https://www.screencast.com/t/GJNOcfa9Ln &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;
*config/routes.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*config/webservices.yml&lt;br /&gt;
&lt;br /&gt;
*app/controllers/student_review_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/assignments/edit/_topics.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/student_task/list.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/student_task/view.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*spec/factories/factories.rb &amp;lt;br&amp;gt;&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/controllers/review_bids_controller.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/helpers/review_bids_helper.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/models/review_bid.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/_all_actions.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/_table_header.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/_table_line.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/_topic_names.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/others_work.html.erb&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*app/views/review_bids/show.html.erb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*db/migrate/20201107203204_create_review_bids.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*spec/controllers/review_bids_controller_spec.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*spec/models/review_bid_spec.rb &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Design==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===   ''User Interface''   ===&lt;br /&gt;
&lt;br /&gt;
Currently, the users are offered the entire list of topics to review and are asked to select a topic to begin a review. Topics that cannot be reviewed or have already been reviewed the maximum number of times are greyed out and cannot be selected. There is also a check box in which the student can select &amp;quot;I don't care which topic I review&amp;quot; and will be randomly assigned a topic from the list. The current User Interface (UI) for this is shown below.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:current_review_UI.PNG]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As discussed in the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Project_Overview Project Overview] section, a bidding system similar to the bidding system used in topic selection is preferable to the current review selection system. The UI for this process will mirror the UI for the topic bidding system. The new UI will allow users to drag a topic from a list of all the topics on the left, to their priority list on the right. The ordering of the right list indicates the priority of the users preference. The colors indicate the likelihood of being assigned that topic. By utilizing the same UI, the consistency of the user experience and the DRY-ness of the code are increased. An example of the topic selection bidding UI is shown below.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:expected_review_UI.PNG]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Currently, an instructor has the option while creating or editing an assignment to allow a reviewers to select the topics they want to review. This is done by checking '''Has teams?''' and '''Has topics?''' in the '''General''' tab of an assignment then checking '''Allow reviewer to choose which topic to review?''' in the '''Topics''' tab. This interface can be used for allowing review bidding either by editing the current check box or adding an additional check box for '''Allow reviewer to bid on topics to review?'''.  &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Instructor_ui_for_review_bidding.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== ''Analyzing the problem'' ===&lt;br /&gt;
&lt;br /&gt;
Currently, the student can either pick a topic or is randomly assigned a topic, from among the ones that are currently eligible to be reviewed. &amp;lt;br&amp;gt;In this scenario, it is possible that some good topics are already picked by a lot of students and if someone is late to do the selecting, they miss out on it since it is grayed out.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To solve the above problem of not getting the topics they like, the participants must be assigned topics based on a list of topics they pre-select. &lt;br /&gt;
This is where an algorithm will come in handy. For picking a suitable algorithm, we should first identify the type of the problem.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Type of problem&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Each student should be able to bid on multiple assignments of their choice and the same assignment can be assigned to multiple participants for review.&amp;lt;br&amp;gt;&lt;br /&gt;
This requires a Many to Many mapping.&lt;br /&gt;
&lt;br /&gt;
                                        [[File:many2.png]]&lt;br /&gt;
&lt;br /&gt;
The algorithm of choice for this type of stable allocations is Gale-Shapely algorithm.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the real world, there are cases where we face this problem:&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt; Student choosing their future universities [https://www.jstor.org/stable/3132114?seq=1&amp;amp;cid=pdf-reference#references_tab_content '''School Choice Problem'''] (One-to-Many)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Men and women seeking each other to create families [https://en.wikipedia.org/wiki/Stable_marriage_problem '''Stable Marriage Problem'''] (One-to-One)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Internet services that need to be connected with users with the smallest amount of time &amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===''Algorithm Implementation for matching students and topics''===&lt;br /&gt;
The Gale-Shapely Algorithm has steps to make sure it is a Stable marriage/allocation.&lt;br /&gt;
An unstable allocation is when the participant does not like the topic assigned to them. &lt;br /&gt;
But it can happen that the participant 1 might like the review topic assigned to participant 2 and participant 2 likes the topic assigned to participant 1.&lt;br /&gt;
This is the unstable case. To make it stable, the topics need to be exchanged between these 2 participants so that both of them get the topic they wanted.&lt;br /&gt;
&lt;br /&gt;
[[File:Snippy2.png]]&lt;br /&gt;
Source: [https://www.journalajrcos.com/index.php/AJRCOS/article/view/24749/46281 Stable Marriage Algorithm]&lt;br /&gt;
&lt;br /&gt;
===''Assignment of priority ''===&lt;br /&gt;
When a student places a bid, the timestamp is recorded. Priority will be given to the earlier bidder. If the student had chosen only very few bids, then this person will be given a higher priority. Any topics that were not selected by the participant are added to bottom of their preference list in a random preference order to create a situation where &amp;lt;b&amp;gt;the number of students and number of topics is equal. &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===''Algorithm Steps ''===&lt;br /&gt;
&amp;lt;li&amp;gt; For the first round, the Algorithm will assign topics to each student based on the Priority and each topic is assigned to a limited number of students based on the Limit. It picks one topic and begins assigning students to it. (Note: The Algorithm makes sure the participant is not in a group that worked on this particular topic.) &lt;br /&gt;
&amp;lt;li&amp;gt;If the one topic is assigned to enough participants already, then it is removed from the queue and the same process is repeated for the next topic. &lt;br /&gt;
&amp;lt;li&amp;gt; As this goes on, all students are matched even if all matches are not stable at this point.&lt;br /&gt;
&amp;lt;li&amp;gt; The Algorithm terminates when all Topics that have not reached the maximum assignment level have tried to accept every student.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;The time complexity of this algorithm is O(n^2) &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===''Simulation ''===&lt;br /&gt;
&lt;br /&gt;
[[File:gale-shapeley-1.png]]&lt;br /&gt;
[[File:gale-shapeley-2.png]]&lt;br /&gt;
&lt;br /&gt;
In the simulation above, we have equal number of Students (S1, S2, S3) and Review topics to assign (R1, R2, R3). The students preference of topics is to left of student. The Review topics does not have any preferences. To have preferences, the timestamps are used to determine which student bid on each topic first to create such a Preference list for topics.&lt;br /&gt;
&lt;br /&gt;
# Phase 1: Both Students S1 and S2 have selected R2 as their highest preference. Since there is a conflict, The preference of R2 is checked which shows that S2 had bid earlier than S1. Thus, the topic R2 is assigned to student S2.&lt;br /&gt;
# Phase 2: Now, S1 and S3 both want to review R1 but R1 was first bid on by S1 as shown in the preference. Hence, R1 is assigned to S1.&lt;br /&gt;
# Phase 3: The only topic remaining in this case is R3 which is also on the preference list of Student S3. Therefore S3 is assigned the topic R3.&lt;br /&gt;
#By the end of the 3 phases, All students are assigned to a Review. The same process needs to be repeated till the required number of reviews are assigned to each student. In each iteration, if a review is assigned to max number of students already, the review is removed from consideration.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
This section details the implementation of the code and will highlight each component of the design in the code and its intended purpose, as well as any modifications or testing. As the implementation progresses this section will be updated.&lt;br /&gt;
&lt;br /&gt;
===   ''Overview''   ===&lt;br /&gt;
&lt;br /&gt;
This project was split into 2 objectives, the Expertiza MVC implementation and the webservice algorithm. The Expertiza MVC follows the MVC standard such that the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Controller controller] handles directing the users to the correct views, as well as handling the communication with the webservice. The [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Model model] performs all necessary computations and data handling like the creation and storing of bids on reviews and assigning reviews to students. The [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Views views] render the corresponding webpage based on the actions of the user. The [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Webservice webservice] contains the algorithm outlined in the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Algorithm_Implementation_for_matching_students_and_topics Algorithm Implementation] section of Design. Our Expertiza controller sends this webservice bidding information and the algorithm returns the matched topics to be assigned. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== ''Controller'' ===&lt;br /&gt;
The controller contains 6 methods that perform all the necessary functions. The first method, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_action_allowed? &amp;quot;action_allowed?&amp;quot;] performs authentication checks The second, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_index &amp;quot;index&amp;quot;], is used to redirect the user to a list of assigned reviews after the algorithm has been run. The third, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_show &amp;quot;show&amp;quot;], is used in conjunction with fourth, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_set_priority &amp;quot;set_priority&amp;quot;], to update and store the bids when users make changes in the bidding page. The fifth, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_assign_bidding &amp;quot;assign_bidding&amp;quot;], utilizes the sixth, [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_run_bidding_algorithm &amp;quot;run_bidding_algorithm&amp;quot;], to connect to the webservice, send and receive the correct bidding information for the algorithm. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: action_allowed? ======&lt;br /&gt;
This method performs authentication by allowing only certain types of users to access controller methods. The first portion of this method allows users 'Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator', and 'Student' to access the methods 'show', 'set_priority', and 'index'. These are the methods that render the bidding pages and review listings. The other methods are restricted for 'Student' users. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller action allowed..PNG]] &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: index ======&lt;br /&gt;
This method collects all the necessary information about the user, Assignment details, and Review Mapping details to render the 'review_bids/others_work', which lists the reviews that are assigned to the user. This page also includes a button to request more reviews which will add reviews up to the maximum number of reviews. To see the view rendered by this method, please go to [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#View:_others_work.html.erb &amp;quot;others_work&amp;quot;].&lt;br /&gt;
&amp;lt;/br&amp;gt;&lt;br /&gt;
[[File:Controller_index.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: show ======&lt;br /&gt;
This method renders the bidding page in which participants can select from a table of topics the topics they would prefer to review. It collects the necessary information about the user, Assignment, Topics, and current Review Bids to render this page. It is used in conjunction with [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_set_priority set_priority] where the users bidding information is stored, and the page updated. To see the bidding page that this function renders, visit the view [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#View:_show.html.erb &amp;quot;show&amp;quot;] &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_show.PNG]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: set_priority ======&lt;br /&gt;
In the view file [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#view:_show.html.erb &amp;quot;show&amp;quot;] there exists a line the calls this method when the page is updated or accessed. This method stores the user's bidding information in the schema database. This allows the model to access this information when collecting all the bidding information, as well as allowing users to refresh or return to this page with their selections staying in the bid table. &lt;br /&gt;
[[File:Controller_set_priority.PNG]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_bidding ======&lt;br /&gt;
This method utilizes methods in the model, as well as the method [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_run_bidding_algorithm &amp;quot;run_bidding_algorithm&amp;quot;] to collect the bidding information of all students of a particular Assignment, send it to the webservice algorithm, store the matched topics that are returned, and pass these matched topics to the model to be assigned. After this method is run, the students should have assigned reviews and bidding should be turned off.&lt;br /&gt;
[[File:Controller_assign_bidding.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: run_bidding_algorithm ======&lt;br /&gt;
This method connects to the webservice using RestClient API, which is part of the 'require's at the top of the Controller. It will return a false if the connection fails for ay reason such as connection is not established or the algorithm has an internal error, otherwise it returns the matched topics from the algorithm as a 'json'. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_requirements.PNG]] &amp;lt;br&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Controller_run_bidding_algorithm.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== ''Model '' ===&lt;br /&gt;
The model contains 5 methods that are utilized by the controller to save bidding information per user or all users, retrieve bidding information per user or for all users, and assign topics to review to participants.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: get_bidding_data ======&lt;br /&gt;
This method is called by the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_assign_bidding &amp;quot;assign_bidding&amp;quot;] controller method. It receives the Assignment ID and a list of reviewers, which are student IDs. It creates a Hash to store bidding data into and iterates through all of the reviewers, calling [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_reviewer_bidding_data &amp;quot;reviewer_bidding_data&amp;quot;] to get each students bidding data and store it in the Hash. It returns a Hash with all the bidding data needed for the Webservice Algorithm to run.&lt;br /&gt;
[[File:Model_get_bidding_data.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_review_topics ======&lt;br /&gt;
This method is called by the [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_assign_bidding &amp;quot;assign_bidding&amp;quot;] controller method. Given the Assignment ID, list of reviewers, and the matched topics returned by the webservice algorithm, it first clears any previously assigned reviews for that Assignment to prevent multiple assigns, then iterates through each reviewer and assigns them to the topics that the algorithm selected for them.&lt;br /&gt;
[[File:Model_assign_review_topics.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: assign_topic_to_reviewer ======&lt;br /&gt;
This method is called by the method [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_assign_review_topics &amp;quot;assign_review_topics&amp;quot;] and assigns a single topic to a single user to review given an Assignment ID. &lt;br /&gt;
[[File:Model_assign_topic_to_reviewer.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: reviewer_self_topic ======&lt;br /&gt;
This method returns the topic id of the reviewer that is passed in. This method is utilized to retrieve the reviewers' Topic ID, which is needed for the webservice algorithm to prevent users from being assigned to review their own topic. This is also prevented in views, but this is an additional safety precaution. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Model_reviewer_self_topic.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Method: reviewer_bidding_data ======&lt;br /&gt;
This method is called by [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Method:_get_bidding_data &amp;quot;get_bidding_data&amp;quot;]. It creates a hash to store all the reviewer's bidding information. It iterates through all the bids for a reviewer given the Assignment ID and it returns a Hash of the bidding data.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Model_reviewer_bidding_data.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== ''Views'' ===&lt;br /&gt;
There are two main views for this project. They are for bidding and for showing assigned reviews after the bidding algorithm has been run. &lt;br /&gt;
====== View: others_work.html.erb ======&lt;br /&gt;
This file renders the view where students see a list of the reviews they've been assigned, with appropriate links and related messages. It includes a &amp;quot;Request Additional Review&amp;quot; button that will allow students to view more reviews up to the max number of reviews allowed. &lt;br /&gt;
[[File:Views_others_work_pt1.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_others_work_pt2.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_others_work_pt3.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_others_work_pt4.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
View rendered by above:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_others_work_rendered.PNG]]&lt;br /&gt;
&lt;br /&gt;
====== View: show.html.erb ======&lt;br /&gt;
This view file renders the Review Bidding page where participants can select which topics to review. It renders partials which are included below, and includes coloring effects from helper methods indicating likelihood of receiving that particular topic to review. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_show_pt1.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_show_pt2.PNG]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Page rendered by above: (This rendering is an instructor view, the student view is the same without the &amp;quot;Edit Topics&amp;quot; column.) &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Views_show_rendered.PNG|900px]]&lt;br /&gt;
&amp;lt;br&amp;gt;&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. This json will have a list of all topics, list of all students and the topics each student selected and also the maximum number of review topics per student. Also, it has the timestamp information of the bidding time to give preference to early bidders. The input json is passed to the JsonParser class to create a Dictionary.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:tab.jpg]]&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 parser also creates a preferences dictionary for the Student to store their topic preferences and &lt;br /&gt;
one for Topics to store list of topics which have been selected by students and also the priority for the selection using the Timestamps.&lt;br /&gt;
The json parser does one more task of finding Popular topics. This is needed because topics that are in demand should be preserved for students who bid on it and to avoid assigning it to students who did not bid on anything. High demand topics are assigned a lower priority for such students so that there are other topics they can be assigned.&lt;br /&gt;
&lt;br /&gt;
[[File:json1.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:json2.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:json3.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''Class Topic'' =====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Topic class is the one that does the proposing to the students during the runtime. &lt;br /&gt;
There are 2 cases. In case 1 when the particular topic is asked by more students than the limit of number of students the one topic can be assigned to. In this case, it uses the priorities it already has in the dictionary to make sure the topic proposes only to those students who chose it and those who bid earlier.&lt;br /&gt;
In Case 2, There are less students who asked for the topic. Hence, the topic can propose to all the students who asked for it and still be under the limit. In the end of this step. All topics make their proposals to be assigned to some students.&lt;br /&gt;
&lt;br /&gt;
[[File:json11.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== ''Class Student'' =====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Once the Topics propose to students, the Student has to accept some of the proposals.&lt;br /&gt;
First, each student sorts the proposals based on the students preferences. Now, the student accepts all the proposals they can upto the number of slots remaining for them. The max slots for the student is determined by the max_proposals_accepted field in the json. Once the acceptance is complete, the Topics are all updated so that the topics can adjust their remaining slots accordingly.&lt;br /&gt;
&lt;br /&gt;
[[File:json12.png]]&lt;br /&gt;
&lt;br /&gt;
===== ''Topic Matcher'' =====&lt;br /&gt;
&lt;br /&gt;
Next, The Topics Matcher class is called which is the main class that runs the Algorithm.&lt;br /&gt;
Before running the algorithm, it creates a list of Student and Topic objects by using instances of Student and Topic class. Each student and Topic now has its own class so that it can be used to make proposals for assignment of topics.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:json4.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The get_student_topic_matches() method kicks off the Algorithm.&lt;br /&gt;
Each topic proposes to students based on the topic priorities as covered in the Topics section. It uses a max_topic_assignment_limit (say 4 for example) to make sure the same topic is not assigned to too many students. &lt;br /&gt;
Once the proposals are made, we iterate over students so that they can accept proposals as long as they have slots remaining to be assigned to.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
The round is now complete. To determine if we need a next round, we ask the topics if they are done proposing using is_topics_done_proposing() method. As long as each topic has not reached its assignment limit and there are still students to propose to, the proposing continues for the next round. &lt;br /&gt;
Once every topic is done, it breaks out of the loop and we now have the list of students with equal number of assigned topics ( 3-4 for example) and this list is returned back to Expertiza as the Stable matching to do the assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:json5.png]]&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;
&amp;lt;code&amp;gt;{&lt;br /&gt;
  &amp;quot;tid&amp;quot;: [&lt;br /&gt;
    3969,3970,3971,3972,3973,3974,3975,3976,3977&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;users&amp;quot;: {&lt;br /&gt;
    &amp;quot;36239&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [&lt;br /&gt;
        3970, 3972&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3977,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [&lt;br /&gt;
        2,1&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;time&amp;quot;: [&lt;br /&gt;
        &amp;quot;Thu, 12 Nov 2020 12:01:06 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 12:01:07 EST -05:00&amp;quot;&lt;br /&gt;
      ]&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;36240&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3976,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [],&lt;br /&gt;
      &amp;quot;time&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;36241&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [&lt;br /&gt;
        3969,3971,3972&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3975,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [&lt;br /&gt;
        1,3,2&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;time&amp;quot;: [&lt;br /&gt;
        &amp;quot;Thu, 12 Nov 2020 12:00:22 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 12:00:25 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 12:00:27 EST -05:00&amp;quot;&lt;br /&gt;
      ]&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;36242&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [&lt;br /&gt;
        3969,3971,3973&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3974,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [&lt;br /&gt;
        3,2,1&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;time&amp;quot;: [&lt;br /&gt;
        &amp;quot;Wed, 11 Nov 2020 12:15:43 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 11:59:40 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 13:07:53 EST -05:00&amp;quot;&lt;br /&gt;
      ]&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;36243&amp;quot;: {&lt;br /&gt;
      &amp;quot;tid&amp;quot;: [&lt;br /&gt;
        3971,3969,3970,3976&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;otid&amp;quot;: 3972,&lt;br /&gt;
      &amp;quot;priority&amp;quot;: [&lt;br /&gt;
        4,3,2,1,5&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;time&amp;quot;: [&lt;br /&gt;
        &amp;quot;Wed, 11 Nov 2020 11:34:50 EST -05:00&amp;quot;,&amp;quot;Wed, 11 Nov 2020 12:30:16 EST -05:00&amp;quot;,&amp;quot;Wed, 11 Nov 2020 12:30:19 EST -05:00&amp;quot;,&amp;quot;Thu, 12 Nov 2020 13:02:02 EST -05:00&amp;quot;&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
  },&lt;br /&gt;
  &amp;quot;max_accepted_proposals&amp;quot;: 3&lt;br /&gt;
} &amp;lt;/code&amp;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;
&amp;lt;code&amp;gt; {&lt;br /&gt;
  &amp;quot;36239&amp;quot;: [&lt;br /&gt;
    3970,&lt;br /&gt;
    3972,&lt;br /&gt;
    3975&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;36240&amp;quot;: [&lt;br /&gt;
    3973,&lt;br /&gt;
    3974,&lt;br /&gt;
    3972&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;36241&amp;quot;: [&lt;br /&gt;
    3969,&lt;br /&gt;
    3971,&lt;br /&gt;
    3972&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;36242&amp;quot;: [&lt;br /&gt;
    3969,&lt;br /&gt;
    3971,&lt;br /&gt;
    3973&lt;br /&gt;
  ],&lt;br /&gt;
  &amp;quot;36243&amp;quot;: [&lt;br /&gt;
    3969,&lt;br /&gt;
    3970,&lt;br /&gt;
    3971&lt;br /&gt;
  ]&lt;br /&gt;
}&amp;lt;/code&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;
===   ''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/RSpec Testing ''   ===&lt;br /&gt;
RSpec tests will need to be written to related controller(s) and model(s). &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== RSpec Testing Plan ====&lt;br /&gt;
These RSpec tests:&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;
:# [https://docs.google.com/document/d/1tXmwju6R7KQbvycku-bdXxa6rXSUN4BMyvjY3ROmMSw/edit Set up Expertiza] on personal device using [https://github.com/uahamedncsu/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;
==Team==&lt;br /&gt;
Ummu Kolusum Yasmin Ahamed Adam (uahamed) &amp;lt;br&amp;gt;&lt;br /&gt;
Ryan Grainger (rpgraing) &amp;lt;br&amp;gt;&lt;br /&gt;
Luis Delossantos (lgdeloss) &amp;lt;br&amp;gt;&lt;br /&gt;
Colleen &amp;quot;Bria&amp;quot; Engen (ceengen) &amp;lt;br&amp;gt;&lt;br /&gt;
'''Mentor:''' Saurabh Shingte (svshingt)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
''Previous Implementations'': [[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1986._Allow_reviewers_to_bid_on_what_to_review 1]], [[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/uahamedncsu/expertiza/tree/beta &amp;lt;br&amp;gt;&lt;br /&gt;
''Github Repository for Web service'': https://github.com/uahamedncsu/IntelligentAssignment &amp;lt;br&amp;gt;&lt;br /&gt;
''Pull Request'': https://github.com/expertiza/expertiza/pull/1822 &amp;lt;br&amp;gt;&lt;br /&gt;
''Expertiza Server'': http://152.7.99.70:8081/ &amp;lt;br&amp;gt;&lt;br /&gt;
''Web Service Server'': https://app-csc517.herokuapp.com/match_topics &amp;lt;br&amp;gt;&lt;br /&gt;
''Video Demo'': https://www.screencast.com/t/GJNOcfa9Ln &amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=140766</id>
		<title>CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=140766"/>
		<updated>2021-11-04T01:02:08Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: /* Previous Implementation VS New Implementation (may change as project continues) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic Overview==&lt;br /&gt;
===Statement of Problem===&lt;br /&gt;
Assigning reviews to users is a complicated process. Currently, reviews are still assigned using a first-come-first-served basis. However, reviews could be bid on like how topics are bid on. This would involve matching multiple students to review a submission up to the maximum reviewers for a submission. A similar feature is present in bidding for topics.&lt;br /&gt;
&lt;br /&gt;
The goal of this topic is to allow both reviews and topics to be bid on by students following a bidding algorithm, and for both of these features to come from the same root functionality. This will involve refactoring the current bidding functionality of expertiza, as well as incorporating new code to allow this functionality to also be utilized for reviews.&lt;br /&gt;
&lt;br /&gt;
==Prior Work==&lt;br /&gt;
Before starting, it is vital to note the substantial amount of prior work done on this task. The prior work done in Fall of 2020 (linked here [[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Design]]) achieved much of the desired functionality for this task, and contains a comprehensive explanation of the underlying design principles behind the algorithm implemented. However, the implementation was rejected due to DRY violations. Thus, the primary goal of this project topic will be to rebuild and refactor this prior work to make it consistent with DRY principles and able to be merged into the expertiza environment.&lt;br /&gt;
&lt;br /&gt;
A brief review will be given of the underlying design for the bidding algorithm. For a more exhaustive explanation, please see the aforementioned link to the prior year's work.&lt;br /&gt;
&lt;br /&gt;
===Goals of this Topic===&lt;br /&gt;
&lt;br /&gt;
# Update the prior work for this topic to be in line with the current state of the expertiza beta branch.&lt;br /&gt;
# DRY out prior implementation's controller methods by creating a single controller which handles bidding for both topics and reviews.&lt;br /&gt;
# DRY out prior implementation's views by implementing a view from scratch (rather than a code copy of topic bidding view).&lt;br /&gt;
# Create exhaustive tests for newly DRY-ed methods, including edge cases.&lt;br /&gt;
# Retain all functionality from prior work.&lt;br /&gt;
&lt;br /&gt;
==Feature==&lt;br /&gt;
In the current state of implementation the reviews are still assigned using a first-come-first-served basis. Current state of the feature implementation contains bad code smell and needs improvement to resolve merge conflict and follow DRY principle in order to finalize the implementation. With the current state in mind, the new implementation will enable the capability that reviews could be bid on like how topics are bid on. Behind the scene, the process would involve matching multiple students to review a submission up to the maximum reviewers for a submission.&lt;br /&gt;
&lt;br /&gt;
==Planned Changes==&lt;br /&gt;
&lt;br /&gt;
===General Design Goals===&lt;br /&gt;
&lt;br /&gt;
* Update the prior work for this topic to be in line with the current state of the expertiza beta branch.&lt;br /&gt;
* DRY out prior implementation's controller methods by creating a single controller which handles bidding for both topics and reviews.&lt;br /&gt;
* DRY out prior implementation's views by implementing a view from scratch (rather than a code copy of topic bidding view).&lt;br /&gt;
* Create exhaustive tests for newly DRY-ed methods, including edge cases.&lt;br /&gt;
* Retain all functionality from prior work.&lt;br /&gt;
&lt;br /&gt;
===Specific Design Goals (may be expanded as project continues)===&lt;br /&gt;
&lt;br /&gt;
* Inspect implementation structure to refactor out duplicated code&lt;br /&gt;
* Review ''def self.reviewer_self_topic'' in ''review_bid'' for refacotring to address DRY violation&lt;br /&gt;
* Modify ''app/views/review_bids/_all_actions.html.erb'' as fitted to integrate reafactored controller modules&lt;br /&gt;
* Update tests to test the refactored DRYed-out methods&lt;br /&gt;
&lt;br /&gt;
===Previous Implementation VS New Implementation (may change as project continues)===&lt;br /&gt;
The before diagram describes the current implementation of the review bidding system. Currently, the available topics are pulled from different controllers, depending on if the user is bidding for topics or topics to review. The new implementation involves created a single controller that will populate both the topic and review bidding features. &lt;br /&gt;
&lt;br /&gt;
[[File:Before-diagram.png]] [[File:After-diagram.png]]&lt;br /&gt;
&lt;br /&gt;
==Github==&lt;br /&gt;
The Github corresponding to this task is publicly available here: https://github.com/WeiRui-Wang/expertiza&lt;br /&gt;
&lt;br /&gt;
==Contributors==&lt;br /&gt;
This feature was created as part of Dr. Edward Gehringer's &amp;quot;CSC/ECE 517: Object-Oriented Design and Development&amp;quot; class, Fall 2021. The contributors were: WeiRui Wang, Geoff Garrido, and Ayush Luthra. Our project mentor was Luis Delossantos (lgdeloss@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=140765</id>
		<title>CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=140765"/>
		<updated>2021-11-04T01:01:57Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: /* Before vs After Diagrams (may change as project continues) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic Overview==&lt;br /&gt;
===Statement of Problem===&lt;br /&gt;
Assigning reviews to users is a complicated process. Currently, reviews are still assigned using a first-come-first-served basis. However, reviews could be bid on like how topics are bid on. This would involve matching multiple students to review a submission up to the maximum reviewers for a submission. A similar feature is present in bidding for topics.&lt;br /&gt;
&lt;br /&gt;
The goal of this topic is to allow both reviews and topics to be bid on by students following a bidding algorithm, and for both of these features to come from the same root functionality. This will involve refactoring the current bidding functionality of expertiza, as well as incorporating new code to allow this functionality to also be utilized for reviews.&lt;br /&gt;
&lt;br /&gt;
==Prior Work==&lt;br /&gt;
Before starting, it is vital to note the substantial amount of prior work done on this task. The prior work done in Fall of 2020 (linked here [[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Design]]) achieved much of the desired functionality for this task, and contains a comprehensive explanation of the underlying design principles behind the algorithm implemented. However, the implementation was rejected due to DRY violations. Thus, the primary goal of this project topic will be to rebuild and refactor this prior work to make it consistent with DRY principles and able to be merged into the expertiza environment.&lt;br /&gt;
&lt;br /&gt;
A brief review will be given of the underlying design for the bidding algorithm. For a more exhaustive explanation, please see the aforementioned link to the prior year's work.&lt;br /&gt;
&lt;br /&gt;
===Goals of this Topic===&lt;br /&gt;
&lt;br /&gt;
# Update the prior work for this topic to be in line with the current state of the expertiza beta branch.&lt;br /&gt;
# DRY out prior implementation's controller methods by creating a single controller which handles bidding for both topics and reviews.&lt;br /&gt;
# DRY out prior implementation's views by implementing a view from scratch (rather than a code copy of topic bidding view).&lt;br /&gt;
# Create exhaustive tests for newly DRY-ed methods, including edge cases.&lt;br /&gt;
# Retain all functionality from prior work.&lt;br /&gt;
&lt;br /&gt;
==Feature==&lt;br /&gt;
In the current state of implementation the reviews are still assigned using a first-come-first-served basis. Current state of the feature implementation contains bad code smell and needs improvement to resolve merge conflict and follow DRY principle in order to finalize the implementation. With the current state in mind, the new implementation will enable the capability that reviews could be bid on like how topics are bid on. Behind the scene, the process would involve matching multiple students to review a submission up to the maximum reviewers for a submission.&lt;br /&gt;
&lt;br /&gt;
==Planned Changes==&lt;br /&gt;
&lt;br /&gt;
===General Design Goals===&lt;br /&gt;
&lt;br /&gt;
* Update the prior work for this topic to be in line with the current state of the expertiza beta branch.&lt;br /&gt;
* DRY out prior implementation's controller methods by creating a single controller which handles bidding for both topics and reviews.&lt;br /&gt;
* DRY out prior implementation's views by implementing a view from scratch (rather than a code copy of topic bidding view).&lt;br /&gt;
* Create exhaustive tests for newly DRY-ed methods, including edge cases.&lt;br /&gt;
* Retain all functionality from prior work.&lt;br /&gt;
&lt;br /&gt;
===Specific Design Goals (may be expanded as project continues)===&lt;br /&gt;
&lt;br /&gt;
* Inspect implementation structure to refactor out duplicated code&lt;br /&gt;
* Review ''def self.reviewer_self_topic'' in ''review_bid'' for refacotring to address DRY violation&lt;br /&gt;
* Modify ''app/views/review_bids/_all_actions.html.erb'' as fitted to integrate reafactored controller modules&lt;br /&gt;
* Update tests to test the refactored DRYed-out methods&lt;br /&gt;
&lt;br /&gt;
===Previous Implementation VS New Implementation (may change as project continues)===&lt;br /&gt;
The before diagram describes the current implementation of the review bidding system. Currently, the available topics are pulled from different controllers, depending on if the user is bidding for topics or topics to review. The new implementation involves created a single controller that will populate both the topic and review bidding features. &lt;br /&gt;
[[File:Before-diagram.png]] [[File:After-diagram.png]]&lt;br /&gt;
&lt;br /&gt;
==Github==&lt;br /&gt;
The Github corresponding to this task is publicly available here: https://github.com/WeiRui-Wang/expertiza&lt;br /&gt;
&lt;br /&gt;
==Contributors==&lt;br /&gt;
This feature was created as part of Dr. Edward Gehringer's &amp;quot;CSC/ECE 517: Object-Oriented Design and Development&amp;quot; class, Fall 2021. The contributors were: WeiRui Wang, Geoff Garrido, and Ayush Luthra. Our project mentor was Luis Delossantos (lgdeloss@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=140762</id>
		<title>CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=140762"/>
		<updated>2021-11-04T00:58:31Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: /* Before vs After Diagrams (may change as project continues) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic Overview==&lt;br /&gt;
===Statement of Problem===&lt;br /&gt;
Assigning reviews to users is a complicated process. Currently, reviews are still assigned using a first-come-first-served basis. However, reviews could be bid on like how topics are bid on. This would involve matching multiple students to review a submission up to the maximum reviewers for a submission. A similar feature is present in bidding for topics.&lt;br /&gt;
&lt;br /&gt;
The goal of this topic is to allow both reviews and topics to be bid on by students following a bidding algorithm, and for both of these features to come from the same root functionality. This will involve refactoring the current bidding functionality of expertiza, as well as incorporating new code to allow this functionality to also be utilized for reviews.&lt;br /&gt;
&lt;br /&gt;
==Prior Work==&lt;br /&gt;
Before starting, it is vital to note the substantial amount of prior work done on this task. The prior work done in Fall of 2020 (linked here [[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Design]]) achieved much of the desired functionality for this task, and contains a comprehensive explanation of the underlying design principles behind the algorithm implemented. However, the implementation was rejected due to DRY violations. Thus, the primary goal of this project topic will be to rebuild and refactor this prior work to make it consistent with DRY principles and able to be merged into the expertiza environment.&lt;br /&gt;
&lt;br /&gt;
A brief review will be given of the underlying design for the bidding algorithm. For a more exhaustive explanation, please see the aforementioned link to the prior year's work.&lt;br /&gt;
&lt;br /&gt;
===Goals of this Topic===&lt;br /&gt;
&lt;br /&gt;
# Update the prior work for this topic to be in line with the current state of the expertiza beta branch.&lt;br /&gt;
# DRY out prior implementation's controller methods by creating a single controller which handles bidding for both topics and reviews.&lt;br /&gt;
# DRY out prior implementation's views by implementing a view from scratch (rather than a code copy of topic bidding view).&lt;br /&gt;
# Create exhaustive tests for newly DRY-ed methods, including edge cases.&lt;br /&gt;
# Retain all functionality from prior work.&lt;br /&gt;
&lt;br /&gt;
==Feature==&lt;br /&gt;
In the current state of implementation the reviews are still assigned using a first-come-first-served basis. Current state of the feature implementation contains bad code smell and needs improvement to resolve merge conflict and follow DRY principle in order to finalize the implementation. With the current state in mind, the new implementation will enable the capability that reviews could be bid on like how topics are bid on. Behind the scene, the process would involve matching multiple students to review a submission up to the maximum reviewers for a submission.&lt;br /&gt;
&lt;br /&gt;
==Planned Changes==&lt;br /&gt;
&lt;br /&gt;
===General Design Goals===&lt;br /&gt;
&lt;br /&gt;
* Update the prior work for this topic to be in line with the current state of the expertiza beta branch.&lt;br /&gt;
* DRY out prior implementation's controller methods by creating a single controller which handles bidding for both topics and reviews.&lt;br /&gt;
* DRY out prior implementation's views by implementing a view from scratch (rather than a code copy of topic bidding view).&lt;br /&gt;
* Create exhaustive tests for newly DRY-ed methods, including edge cases.&lt;br /&gt;
* Retain all functionality from prior work.&lt;br /&gt;
&lt;br /&gt;
===Specific Design Goals (may be expanded as project continues)===&lt;br /&gt;
&lt;br /&gt;
* Inspect implementation structure to refactor out duplicated code&lt;br /&gt;
* Review ''def self.reviewer_self_topic'' in ''review_bid'' for refacotring to address DRY violation&lt;br /&gt;
* Modify ''app/views/review_bids/_all_actions.html.erb'' as fitted to integrate reafactored controller modules&lt;br /&gt;
* Update tests to test the refactored DRYed-out methods&lt;br /&gt;
&lt;br /&gt;
===Before vs After Diagrams (may change as project continues)===&lt;br /&gt;
[[File:Before-diagram.png]] [[File:After-diagram.png]]&lt;br /&gt;
&lt;br /&gt;
==Github==&lt;br /&gt;
The Github corresponding to this task is publicly available here: https://github.com/WeiRui-Wang/expertiza&lt;br /&gt;
&lt;br /&gt;
==Contributors==&lt;br /&gt;
This feature was created as part of Dr. Edward Gehringer's &amp;quot;CSC/ECE 517: Object-Oriented Design and Development&amp;quot; class, Fall 2021. The contributors were: WeiRui Wang, Geoff Garrido, and Ayush Luthra. Our project mentor was Luis Delossantos (lgdeloss@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:After-diagram.png&amp;diff=140761</id>
		<title>File:After-diagram.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:After-diagram.png&amp;diff=140761"/>
		<updated>2021-11-04T00:58:02Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=140759</id>
		<title>CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=140759"/>
		<updated>2021-11-04T00:57:14Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: /* Before vs After Diagrams (may change as project continues) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic Overview==&lt;br /&gt;
===Statement of Problem===&lt;br /&gt;
Assigning reviews to users is a complicated process. Currently, reviews are still assigned using a first-come-first-served basis. However, reviews could be bid on like how topics are bid on. This would involve matching multiple students to review a submission up to the maximum reviewers for a submission. A similar feature is present in bidding for topics.&lt;br /&gt;
&lt;br /&gt;
The goal of this topic is to allow both reviews and topics to be bid on by students following a bidding algorithm, and for both of these features to come from the same root functionality. This will involve refactoring the current bidding functionality of expertiza, as well as incorporating new code to allow this functionality to also be utilized for reviews.&lt;br /&gt;
&lt;br /&gt;
==Prior Work==&lt;br /&gt;
Before starting, it is vital to note the substantial amount of prior work done on this task. The prior work done in Fall of 2020 (linked here [[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Design]]) achieved much of the desired functionality for this task, and contains a comprehensive explanation of the underlying design principles behind the algorithm implemented. However, the implementation was rejected due to DRY violations. Thus, the primary goal of this project topic will be to rebuild and refactor this prior work to make it consistent with DRY principles and able to be merged into the expertiza environment.&lt;br /&gt;
&lt;br /&gt;
A brief review will be given of the underlying design for the bidding algorithm. For a more exhaustive explanation, please see the aforementioned link to the prior year's work.&lt;br /&gt;
&lt;br /&gt;
===Goals of this Topic===&lt;br /&gt;
&lt;br /&gt;
# Update the prior work for this topic to be in line with the current state of the expertiza beta branch.&lt;br /&gt;
# DRY out prior implementation's controller methods by creating a single controller which handles bidding for both topics and reviews.&lt;br /&gt;
# DRY out prior implementation's views by implementing a view from scratch (rather than a code copy of topic bidding view).&lt;br /&gt;
# Create exhaustive tests for newly DRY-ed methods, including edge cases.&lt;br /&gt;
# Retain all functionality from prior work.&lt;br /&gt;
&lt;br /&gt;
==Feature==&lt;br /&gt;
In the current state of implementation the reviews are still assigned using a first-come-first-served basis. Current state of the feature implementation contains bad code smell and needs improvement to resolve merge conflict and follow DRY principle in order to finalize the implementation. With the current state in mind, the new implementation will enable the capability that reviews could be bid on like how topics are bid on. Behind the scene, the process would involve matching multiple students to review a submission up to the maximum reviewers for a submission.&lt;br /&gt;
&lt;br /&gt;
==Planned Changes==&lt;br /&gt;
&lt;br /&gt;
===General Design Goals===&lt;br /&gt;
&lt;br /&gt;
* Update the prior work for this topic to be in line with the current state of the expertiza beta branch.&lt;br /&gt;
* DRY out prior implementation's controller methods by creating a single controller which handles bidding for both topics and reviews.&lt;br /&gt;
* DRY out prior implementation's views by implementing a view from scratch (rather than a code copy of topic bidding view).&lt;br /&gt;
* Create exhaustive tests for newly DRY-ed methods, including edge cases.&lt;br /&gt;
* Retain all functionality from prior work.&lt;br /&gt;
&lt;br /&gt;
===Specific Design Goals (may be expanded as project continues)===&lt;br /&gt;
&lt;br /&gt;
* Inspect implementation structure to refactor out duplicated code&lt;br /&gt;
* Review ''def self.reviewer_self_topic'' in ''review_bid'' for refacotring to address DRY violation&lt;br /&gt;
* Modify ''app/views/review_bids/_all_actions.html.erb'' as fitted to integrate reafactored controller modules&lt;br /&gt;
* Update tests to test the refactored DRYed-out methods&lt;br /&gt;
&lt;br /&gt;
===Before vs After Diagrams (may change as project continues)===&lt;br /&gt;
[[File:Before-diagram.png]]&lt;br /&gt;
&lt;br /&gt;
==Github==&lt;br /&gt;
The Github corresponding to this task is publicly available here: https://github.com/WeiRui-Wang/expertiza&lt;br /&gt;
&lt;br /&gt;
==Contributors==&lt;br /&gt;
This feature was created as part of Dr. Edward Gehringer's &amp;quot;CSC/ECE 517: Object-Oriented Design and Development&amp;quot; class, Fall 2021. The contributors were: WeiRui Wang, Geoff Garrido, and Ayush Luthra. Our project mentor was Luis Delossantos (lgdeloss@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=140758</id>
		<title>CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=140758"/>
		<updated>2021-11-04T00:56:48Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: /* Before vs After Diagrams (may change as project continues) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic Overview==&lt;br /&gt;
===Statement of Problem===&lt;br /&gt;
Assigning reviews to users is a complicated process. Currently, reviews are still assigned using a first-come-first-served basis. However, reviews could be bid on like how topics are bid on. This would involve matching multiple students to review a submission up to the maximum reviewers for a submission. A similar feature is present in bidding for topics.&lt;br /&gt;
&lt;br /&gt;
The goal of this topic is to allow both reviews and topics to be bid on by students following a bidding algorithm, and for both of these features to come from the same root functionality. This will involve refactoring the current bidding functionality of expertiza, as well as incorporating new code to allow this functionality to also be utilized for reviews.&lt;br /&gt;
&lt;br /&gt;
==Prior Work==&lt;br /&gt;
Before starting, it is vital to note the substantial amount of prior work done on this task. The prior work done in Fall of 2020 (linked here [[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Design]]) achieved much of the desired functionality for this task, and contains a comprehensive explanation of the underlying design principles behind the algorithm implemented. However, the implementation was rejected due to DRY violations. Thus, the primary goal of this project topic will be to rebuild and refactor this prior work to make it consistent with DRY principles and able to be merged into the expertiza environment.&lt;br /&gt;
&lt;br /&gt;
A brief review will be given of the underlying design for the bidding algorithm. For a more exhaustive explanation, please see the aforementioned link to the prior year's work.&lt;br /&gt;
&lt;br /&gt;
===Goals of this Topic===&lt;br /&gt;
&lt;br /&gt;
# Update the prior work for this topic to be in line with the current state of the expertiza beta branch.&lt;br /&gt;
# DRY out prior implementation's controller methods by creating a single controller which handles bidding for both topics and reviews.&lt;br /&gt;
# DRY out prior implementation's views by implementing a view from scratch (rather than a code copy of topic bidding view).&lt;br /&gt;
# Create exhaustive tests for newly DRY-ed methods, including edge cases.&lt;br /&gt;
# Retain all functionality from prior work.&lt;br /&gt;
&lt;br /&gt;
==Feature==&lt;br /&gt;
In the current state of implementation the reviews are still assigned using a first-come-first-served basis. Current state of the feature implementation contains bad code smell and needs improvement to resolve merge conflict and follow DRY principle in order to finalize the implementation. With the current state in mind, the new implementation will enable the capability that reviews could be bid on like how topics are bid on. Behind the scene, the process would involve matching multiple students to review a submission up to the maximum reviewers for a submission.&lt;br /&gt;
&lt;br /&gt;
==Planned Changes==&lt;br /&gt;
&lt;br /&gt;
===General Design Goals===&lt;br /&gt;
&lt;br /&gt;
* Update the prior work for this topic to be in line with the current state of the expertiza beta branch.&lt;br /&gt;
* DRY out prior implementation's controller methods by creating a single controller which handles bidding for both topics and reviews.&lt;br /&gt;
* DRY out prior implementation's views by implementing a view from scratch (rather than a code copy of topic bidding view).&lt;br /&gt;
* Create exhaustive tests for newly DRY-ed methods, including edge cases.&lt;br /&gt;
* Retain all functionality from prior work.&lt;br /&gt;
&lt;br /&gt;
===Specific Design Goals (may be expanded as project continues)===&lt;br /&gt;
&lt;br /&gt;
* Inspect implementation structure to refactor out duplicated code&lt;br /&gt;
* Review ''def self.reviewer_self_topic'' in ''review_bid'' for refacotring to address DRY violation&lt;br /&gt;
* Modify ''app/views/review_bids/_all_actions.html.erb'' as fitted to integrate reafactored controller modules&lt;br /&gt;
* Update tests to test the refactored DRYed-out methods&lt;br /&gt;
&lt;br /&gt;
===Before vs After Diagrams (may change as project continues)===&lt;br /&gt;
[[File:Before-diagram.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Github==&lt;br /&gt;
The Github corresponding to this task is publicly available here: https://github.com/WeiRui-Wang/expertiza&lt;br /&gt;
&lt;br /&gt;
==Contributors==&lt;br /&gt;
This feature was created as part of Dr. Edward Gehringer's &amp;quot;CSC/ECE 517: Object-Oriented Design and Development&amp;quot; class, Fall 2021. The contributors were: WeiRui Wang, Geoff Garrido, and Ayush Luthra. Our project mentor was Luis Delossantos (lgdeloss@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Before-diagram.png&amp;diff=140755</id>
		<title>File:Before-diagram.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Before-diagram.png&amp;diff=140755"/>
		<updated>2021-11-04T00:55:39Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=140754</id>
		<title>CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=140754"/>
		<updated>2021-11-04T00:54:32Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: /* Planned Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic Overview==&lt;br /&gt;
===Statement of Problem===&lt;br /&gt;
Assigning reviews to users is a complicated process. Currently, reviews are still assigned using a first-come-first-served basis. However, reviews could be bid on like how topics are bid on. This would involve matching multiple students to review a submission up to the maximum reviewers for a submission. A similar feature is present in bidding for topics.&lt;br /&gt;
&lt;br /&gt;
The goal of this topic is to allow both reviews and topics to be bid on by students following a bidding algorithm, and for both of these features to come from the same root functionality. This will involve refactoring the current bidding functionality of expertiza, as well as incorporating new code to allow this functionality to also be utilized for reviews.&lt;br /&gt;
&lt;br /&gt;
==Prior Work==&lt;br /&gt;
Before starting, it is vital to note the substantial amount of prior work done on this task. The prior work done in Fall of 2020 (linked here [[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Design]]) achieved much of the desired functionality for this task, and contains a comprehensive explanation of the underlying design principles behind the algorithm implemented. However, the implementation was rejected due to DRY violations. Thus, the primary goal of this project topic will be to rebuild and refactor this prior work to make it consistent with DRY principles and able to be merged into the expertiza environment.&lt;br /&gt;
&lt;br /&gt;
A brief review will be given of the underlying design for the bidding algorithm. For a more exhaustive explanation, please see the aforementioned link to the prior year's work.&lt;br /&gt;
&lt;br /&gt;
===Goals of this Topic===&lt;br /&gt;
&lt;br /&gt;
# Update the prior work for this topic to be in line with the current state of the expertiza beta branch.&lt;br /&gt;
# DRY out prior implementation's controller methods by creating a single controller which handles bidding for both topics and reviews.&lt;br /&gt;
# DRY out prior implementation's views by implementing a view from scratch (rather than a code copy of topic bidding view).&lt;br /&gt;
# Create exhaustive tests for newly DRY-ed methods, including edge cases.&lt;br /&gt;
# Retain all functionality from prior work.&lt;br /&gt;
&lt;br /&gt;
==Feature==&lt;br /&gt;
In the current state of implementation the reviews are still assigned using a first-come-first-served basis. Current state of the feature implementation contains bad code smell and needs improvement to resolve merge conflict and follow DRY principle in order to finalize the implementation. With the current state in mind, the new implementation will enable the capability that reviews could be bid on like how topics are bid on. Behind the scene, the process would involve matching multiple students to review a submission up to the maximum reviewers for a submission.&lt;br /&gt;
&lt;br /&gt;
==Planned Changes==&lt;br /&gt;
&lt;br /&gt;
===General Design Goals===&lt;br /&gt;
&lt;br /&gt;
* Update the prior work for this topic to be in line with the current state of the expertiza beta branch.&lt;br /&gt;
* DRY out prior implementation's controller methods by creating a single controller which handles bidding for both topics and reviews.&lt;br /&gt;
* DRY out prior implementation's views by implementing a view from scratch (rather than a code copy of topic bidding view).&lt;br /&gt;
* Create exhaustive tests for newly DRY-ed methods, including edge cases.&lt;br /&gt;
* Retain all functionality from prior work.&lt;br /&gt;
&lt;br /&gt;
===Specific Design Goals (may be expanded as project continues)===&lt;br /&gt;
&lt;br /&gt;
* Inspect implementation structure to refactor out duplicated code&lt;br /&gt;
* Review ''def self.reviewer_self_topic'' in ''review_bid'' for refacotring to address DRY violation&lt;br /&gt;
* Modify ''app/views/review_bids/_all_actions.html.erb'' as fitted to integrate reafactored controller modules&lt;br /&gt;
* Update tests to test the refactored DRYed-out methods&lt;br /&gt;
&lt;br /&gt;
===Before vs After Diagrams (may change as project continues)===&lt;br /&gt;
&lt;br /&gt;
==Github==&lt;br /&gt;
The Github corresponding to this task is publicly available here: https://github.com/WeiRui-Wang/expertiza&lt;br /&gt;
&lt;br /&gt;
==Contributors==&lt;br /&gt;
This feature was created as part of Dr. Edward Gehringer's &amp;quot;CSC/ECE 517: Object-Oriented Design and Development&amp;quot; class, Fall 2021. The contributors were: WeiRui Wang, Geoff Garrido, and Ayush Luthra. Our project mentor was Luis Delossantos (lgdeloss@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=140738</id>
		<title>CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=140738"/>
		<updated>2021-11-04T00:38:56Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: /* Diagrams */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic Overview==&lt;br /&gt;
===Statement of Problem===&lt;br /&gt;
Assigning reviews to users is a complicated process. Currently, reviews are still assigned using a first-come-first-served basis. However, reviews could be bid on like how topics are bid on. This would involve matching multiple students to review a submission up to the maximum reviewers for a submission. A similar feature is present in bidding for topics. This current feature will serve us as an example when creating our feature.&lt;br /&gt;
&lt;br /&gt;
===Prior Work===&lt;br /&gt;
Before starting, it is vital to note the substantial amount of prior work done on this task. The prior work done in Fall of 2020 (linked here [[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Design]]) achieved much of the desired functionality for this task, and contains a comprehensive explanation of the underlying design principles behind the algorithm implemented. However, the implementation was rejected due to DRY violations. Thus, the primary goal of this project topic will be to rebuild and refactor this prior work to make it consistent with DRY principles and able to be merged into the expertiza environment.&lt;br /&gt;
&lt;br /&gt;
===Goals of this Topic===&lt;br /&gt;
&lt;br /&gt;
# Update the prior work for this topic to be in line with the current state of the expertiza beta branch.&lt;br /&gt;
# DRY out prior implementation's controller methods by creating a single controller which handles bidding for both topics and reviews.&lt;br /&gt;
# DRY out prior implementation's views by implementing a view from scratch (rather than a code copy of topic bidding view).&lt;br /&gt;
# Create exhaustive tests for newly DRY-ed methods, including edge cases.&lt;br /&gt;
# Retain all functionality from prior work.&lt;br /&gt;
&lt;br /&gt;
==Feature==&lt;br /&gt;
In the current state of implementation the reviews are still assigned using a first-come-first-served basis. Current state of the feature implementation contains bad code smell and needs improvement to resolve merge conflict and follow DRY principle in order to finalize the implementation. With the current state in mind, the new implementation will enable the capability that reviews could be bid on like how topics are bid on. Behind the scene, the process would involve matching multiple students to review a submission up to the maximum reviewers for a submission.&lt;br /&gt;
&lt;br /&gt;
==Planned Changes==&lt;br /&gt;
* Inspect implementation structure to refactor out duplicated code&lt;br /&gt;
* Review ''def self.reviewer_self_topic'' in ''review_bid'' for refacotring to address DRY violation&lt;br /&gt;
* Modify ''app/views/review_bids/_all_actions.html.erb'' as fitted to integrate reafacotred controller modules&lt;br /&gt;
* Update tests to test the refactored DRYed-out methods&lt;br /&gt;
&lt;br /&gt;
===Diagrams===&lt;br /&gt;
&lt;br /&gt;
==Github==&lt;br /&gt;
The Github corresponding to this task is publicly available here: https://github.com/WeiRui-Wang/expertiza&lt;br /&gt;
&lt;br /&gt;
==Contributors==&lt;br /&gt;
This feature was created as part of Dr. Edward Gehringer's &amp;quot;CSC/ECE 517: Object-Oriented Design and Development&amp;quot; class, Fall 2021. The contributors were: WeiRui Wang, Geoff Garrido, and Ayush Luthra. Our project mentor was Luis Delossantos (lgdeloss@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=140737</id>
		<title>CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=140737"/>
		<updated>2021-11-04T00:38:35Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: /* Planned Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic Overview==&lt;br /&gt;
===Statement of Problem===&lt;br /&gt;
Assigning reviews to users is a complicated process. Currently, reviews are still assigned using a first-come-first-served basis. However, reviews could be bid on like how topics are bid on. This would involve matching multiple students to review a submission up to the maximum reviewers for a submission. A similar feature is present in bidding for topics. This current feature will serve us as an example when creating our feature.&lt;br /&gt;
&lt;br /&gt;
===Prior Work===&lt;br /&gt;
Before starting, it is vital to note the substantial amount of prior work done on this task. The prior work done in Fall of 2020 (linked here [[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Design]]) achieved much of the desired functionality for this task, and contains a comprehensive explanation of the underlying design principles behind the algorithm implemented. However, the implementation was rejected due to DRY violations. Thus, the primary goal of this project topic will be to rebuild and refactor this prior work to make it consistent with DRY principles and able to be merged into the expertiza environment.&lt;br /&gt;
&lt;br /&gt;
===Goals of this Topic===&lt;br /&gt;
&lt;br /&gt;
# Update the prior work for this topic to be in line with the current state of the expertiza beta branch.&lt;br /&gt;
# DRY out prior implementation's controller methods by creating a single controller which handles bidding for both topics and reviews.&lt;br /&gt;
# DRY out prior implementation's views by implementing a view from scratch (rather than a code copy of topic bidding view).&lt;br /&gt;
# Create exhaustive tests for newly DRY-ed methods, including edge cases.&lt;br /&gt;
# Retain all functionality from prior work.&lt;br /&gt;
&lt;br /&gt;
==Feature==&lt;br /&gt;
In the current state of implementation the reviews are still assigned using a first-come-first-served basis. Current state of the feature implementation contains bad code smell and needs improvement to resolve merge conflict and follow DRY principle in order to finalize the implementation. With the current state in mind, the new implementation will enable the capability that reviews could be bid on like how topics are bid on. Behind the scene, the process would involve matching multiple students to review a submission up to the maximum reviewers for a submission.&lt;br /&gt;
&lt;br /&gt;
==Planned Changes==&lt;br /&gt;
* Inspect implementation structure to refactor out duplicated code&lt;br /&gt;
* Review ''def self.reviewer_self_topic'' in ''review_bid'' for refacotring to address DRY violation&lt;br /&gt;
* Modify ''app/views/review_bids/_all_actions.html.erb'' as fitted to integrate reafacotred controller modules&lt;br /&gt;
* Update tests to test the refactored DRYed-out methods&lt;br /&gt;
&lt;br /&gt;
==Diagrams==&lt;br /&gt;
&lt;br /&gt;
==Github==&lt;br /&gt;
The Github corresponding to this task is publicly available here: https://github.com/WeiRui-Wang/expertiza&lt;br /&gt;
&lt;br /&gt;
==Contributors==&lt;br /&gt;
This feature was created as part of Dr. Edward Gehringer's &amp;quot;CSC/ECE 517: Object-Oriented Design and Development&amp;quot; class, Fall 2021. The contributors were: WeiRui Wang, Geoff Garrido, and Ayush Luthra. Our project mentor was Luis Delossantos (lgdeloss@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=140630</id>
		<title>CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=140630"/>
		<updated>2021-11-03T19:21:20Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: /* Statement of Problem */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic Overview==&lt;br /&gt;
===Statement of Problem===&lt;br /&gt;
Assigning reviews to users is a complicated process. Currently, reviews are still assigned using a first-come-first-served basis. However, reviews could be bid on like how topics are bid on. This would involve matching multiple students to review a submission up to the maximum reviewers for a submission. A similar feature is present in bidding for topics. This current feature will serve us as an example when creating our feature.&lt;br /&gt;
&lt;br /&gt;
===Prior Work===&lt;br /&gt;
Before starting, it is vital to note the substantial amount of prior work done on this task. The prior work done in Fall of 2020 (linked here [[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Design]]) achieved much of the desired functionality for this task, and contains a comprehensive explanation of the underlying design principles behind the algorithm implemented. However, the implementation was rejected due to DRY violations. Thus, the primary goal of this project topic will be to rebuild and refactor this prior work to make it consistent with DRY principles and able to be merged into the expertiza environment.&lt;br /&gt;
&lt;br /&gt;
===Goals of this Topic===&lt;br /&gt;
&lt;br /&gt;
# Update the prior work for this topic to be in line with the current state of the expertiza beta branch.&lt;br /&gt;
# DRY out prior implementation's controller methods by creating a single controller which handles bidding for both topics and reviews.&lt;br /&gt;
# DRY out prior implementation's views by implementing a view from scratch (rather than a code copy of topic bidding view).&lt;br /&gt;
# Create exhaustive tests for newly DRY-ed methods, including edge cases.&lt;br /&gt;
# Retain all functionality from prior work.&lt;br /&gt;
&lt;br /&gt;
==Feature==&lt;br /&gt;
In the current state of implementation the reviews are still assigned using a first-come-first-served basis. Current state of the feature implementation contains bad code smell and needs improvement to resolve merge conflict and follow DRY principle in order to finalize the implementation. With the current state in mind, the new implementation will enable the capability that reviews could be bid on like how topics are bid on. Behind the scene, the process would involve matching multiple students to review a submission up to the maximum reviewers for a submission.&lt;br /&gt;
&lt;br /&gt;
==Planned Changes==&lt;br /&gt;
* Inspect implementation structure to refactor out duplicated code&lt;br /&gt;
* Review ''def self.reviewer_self_topic'' in ''review_bid'' for refacotring to address DRY violation&lt;br /&gt;
* Modify ''app/views/review_bids/_all_actions.html.erb'' as fitted to integrate reafacotred controller modules&lt;br /&gt;
* Update tests to test the refactored DRYed-out methods&lt;br /&gt;
&lt;br /&gt;
==Github==&lt;br /&gt;
The Github corresponding to this task is publicly available here: https://github.com/WeiRui-Wang/expertiza&lt;br /&gt;
&lt;br /&gt;
==Contributors==&lt;br /&gt;
This feature was created as part of Dr. Edward Gehringer's &amp;quot;CSC/ECE 517: Object-Oriented Design and Development&amp;quot; class, Fall 2021. The contributors were: WeiRui Wang, Geoff Garrido, and Ayush Luthra. Our project mentor was Luis Delossantos (lgdeloss@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=140629</id>
		<title>CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review&amp;diff=140629"/>
		<updated>2021-11-03T19:18:37Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: /* Contributors */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic Overview==&lt;br /&gt;
===Statement of Problem===&lt;br /&gt;
Assigning reviews to users is a complicated process. Currently, reviews are still assigned using a first-come-first-served basis. However, reviews could be bid on like how topics are bid on. This would involve matching multiple students to review a submission up to the maximum reviewers for a submission.&lt;br /&gt;
&lt;br /&gt;
===Prior Work===&lt;br /&gt;
Before starting, it is vital to note the substantial amount of prior work done on this task. The prior work done in Fall of 2020 (linked here [[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2020_-_E2085._Allow_reviewers_to_bid_on_what_to_review#Design]]) achieved much of the desired functionality for this task, and contains a comprehensive explanation of the underlying design principles behind the algorithm implemented. However, the implementation was rejected due to DRY violations. Thus, the primary goal of this project topic will be to rebuild and refactor this prior work to make it consistent with DRY principles and able to be merged into the expertiza environment.&lt;br /&gt;
&lt;br /&gt;
===Goals of this Topic===&lt;br /&gt;
&lt;br /&gt;
# Update the prior work for this topic to be in line with the current state of the expertiza beta branch.&lt;br /&gt;
# DRY out prior implementation's controller methods by creating a single controller which handles bidding for both topics and reviews.&lt;br /&gt;
# DRY out prior implementation's views by implementing a view from scratch (rather than a code copy of topic bidding view).&lt;br /&gt;
# Create exhaustive tests for newly DRY-ed methods, including edge cases.&lt;br /&gt;
# Retain all functionality from prior work.&lt;br /&gt;
&lt;br /&gt;
==Feature==&lt;br /&gt;
In the current state of implementation the reviews are still assigned using a first-come-first-served basis. Current state of the feature implementation contains bad code smell and needs improvement to resolve merge conflict and follow DRY principle in order to finalize the implementation. With the current state in mind, the new implementation will enable the capability that reviews could be bid on like how topics are bid on. Behind the scene, the process would involve matching multiple students to review a submission up to the maximum reviewers for a submission.&lt;br /&gt;
&lt;br /&gt;
==Planned Changes==&lt;br /&gt;
* Inspect implementation structure to refactor out duplicated code&lt;br /&gt;
* Review ''def self.reviewer_self_topic'' in ''review_bid'' for refacotring to address DRY violation&lt;br /&gt;
* Modify ''app/views/review_bids/_all_actions.html.erb'' as fitted to integrate reafacotred controller modules&lt;br /&gt;
* Update tests to test the refactored DRYed-out methods&lt;br /&gt;
&lt;br /&gt;
==Github==&lt;br /&gt;
The Github corresponding to this task is publicly available here: https://github.com/WeiRui-Wang/expertiza&lt;br /&gt;
&lt;br /&gt;
==Contributors==&lt;br /&gt;
This feature was created as part of Dr. Edward Gehringer's &amp;quot;CSC/ECE 517: Object-Oriented Design and Development&amp;quot; class, Fall 2021. The contributors were: WeiRui Wang, Geoff Garrido, and Ayush Luthra. Our project mentor was Luis Delossantos (lgdeloss@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2146._Introduce_a_Student_View_for_instructors&amp;diff=139988</id>
		<title>CSC/ECE 517 Fall 2021 - E2146. Introduce a Student View for instructors</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2146._Introduce_a_Student_View_for_instructors&amp;diff=139988"/>
		<updated>2021-10-25T04:04:30Z</updated>

		<summary type="html">&lt;p&gt;Aluthra: Adding mentor name to contributors section.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Problem Statement==&lt;br /&gt;
Currently, Expertiza is designed such that an instructor can view all the pages a student can, and is given access to a view very similar to that of a student. However, the difference between the navigational bar shown to an instructor and that which is shown to a student means that an instructor cannot perfectly emulate the view that a student has of Expertiza.&lt;br /&gt;
&lt;br /&gt;
This makes activities such as demonstrating how to navigate around the website and access certain parts of assignments more difficult. While an instructor can choose to impersonate a student, this is cumbersome if they simply wish to view things as a student would from within their instructor account.&lt;br /&gt;
&lt;br /&gt;
Additionally, certain features of the navigational bar are redundant. The main feature in question is the ''Assignments'' navigational link, which navigates to the same location as ''Manage... -&amp;gt; Assignments''. Having such redundancy is confusing.&lt;br /&gt;
&lt;br /&gt;
To summarize the problem, there is no easy way for an instructor to have the same view as a student at a moment's notice due to a difference between an instructor's and a student's navigational bars.&lt;br /&gt;
&lt;br /&gt;
==Goal of this Topic==&lt;br /&gt;
The goal of this topic has two primary components:&lt;br /&gt;
*Remove the redundant &amp;quot;Assignments&amp;quot; link in the current navigational bar&lt;br /&gt;
*Add a new &amp;quot;Student View&amp;quot; link to the navigational bar. When clicked, the navigational bar changes to that of a student for the remainder of the session, with the addition of an &amp;quot;Instructor View&amp;quot; link. When that link is clicked, the navigational bar changes back to that of an instructor.&lt;br /&gt;
&lt;br /&gt;
By making these changes, the unnecessary redundancy in the navigational bar is removed, and an instructor has an easy ability to demonstrate or visualize expertiza from the perspective of a student.&lt;br /&gt;
&lt;br /&gt;
==Specific Statement of Intent==&lt;br /&gt;
&lt;br /&gt;
The following is a precise, mechanical description of the intended changes.&lt;br /&gt;
&lt;br /&gt;
When an instructor logs in, they should see a navigational bar with the following components:&lt;br /&gt;
''Home'' | ''Manage...'' | ''Survey Deployments'' | ''Course Evaluation'' | ''Profile'' | ''Contact Us'' | ''Student View''&lt;br /&gt;
&lt;br /&gt;
These are the same navigational components that an instructor can currently view, with the removal of ''Assignments'' and the addition of ''Student View''.&lt;br /&gt;
&lt;br /&gt;
If an instructor clicks on ''Student View'', they are redirected to the home page and their navigational bar changes to the following:&lt;br /&gt;
&lt;br /&gt;
''Home'' | ''Assignments'' | ''Pending Surveys'' | ''Profile'' | ''Contact Us'' | ''Anonymized view'' | ''Instructor View''&lt;br /&gt;
&lt;br /&gt;
These are the same navigational links that a student can view, with the addition of ''Instructor View''.&lt;br /&gt;
&lt;br /&gt;
This navigational bar change should persist throughout the session, until the instructor chooses to change their view.&lt;br /&gt;
&lt;br /&gt;
==Design==&lt;br /&gt;
To implement the feature, we first start with the design in our mind for the control flow as shown below.&lt;br /&gt;
&lt;br /&gt;
[[File:UMLFLowDiagram_OSS1.png]]&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
&lt;br /&gt;
To implement these changes, our theoretical framework was as follows:&lt;br /&gt;
1. Add a link to the navigational bar which directs to a new controller and its controller method.&lt;br /&gt;
2. Write a controller method which flips the value of a session flag. This session flag determines which navigational bar you see at any time.&lt;br /&gt;
3. Whenever the navigational bar is loaded, this flag is checked. If in the &amp;quot;student view&amp;quot; state, it renders the student view version of the instructor's navigational bar. if not, it renders the instructor's normal navigational bar (both with the addition of the link to switch to the other state).&lt;br /&gt;
&lt;br /&gt;
To make this change, the following files were affected:&lt;br /&gt;
*controllers/student_view_controller.rb: a controller with a single unique method, &amp;quot;flip_view&amp;quot;, which flips the [:flip_user] session variable when called.&lt;br /&gt;
*views/shared/_navigation.html.erb: the view which handles rendering the navigation bar. Has been edited to check the status of [:flip_user] and render a view accordingly.&lt;br /&gt;
*config/role_instructor.yml: determines various aspects about those assigned the role of instructor. Only change made is the addition of the student_view and instructor_view Menu::Node objects, which are rendered in the navigation bar.&lt;br /&gt;
*config/routes.rb: the routes for expertiza. Modified to allow a route to the newly made &amp;quot;flip_view&amp;quot; method.&lt;br /&gt;
*spec/controllers/student_view_controller_spec.rb: A series of unit tests for the student view controller, ensuring proper functionality and permissions.&lt;br /&gt;
&lt;br /&gt;
Each major change and/or will now be explained in detail.&lt;br /&gt;
&lt;br /&gt;
===student_view_controller.rb===&lt;br /&gt;
This controller contains only two methods, flip_view and _action_allowed? The later is a method common to all controllers, which determines who has access to the method. This is defined for the student_view_controller such that only those with instructor privileges may use it.&lt;br /&gt;
&lt;br /&gt;
The flip_view function is shown below.&lt;br /&gt;
 &lt;br /&gt;
   def flip_view&lt;br /&gt;
     if(session[:flip_user] == nil || session[:flip_user] == false) then&lt;br /&gt;
       session[:flip_user] = true&lt;br /&gt;
       redirect_to '/'&lt;br /&gt;
     elsif(session[:flip_user] == true) then&lt;br /&gt;
       session[:flip_user] = false&lt;br /&gt;
       redirect_to '/'&lt;br /&gt;
     end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
This relatively simple method's purpose is to flip the parity of a session variable named :flip_user between true and false, before then redirecting back to the home page. It also sets this variable to true if uninitialized, as would be the case at the beginning of a session. The route to this method is specified in the routes file as &amp;quot;student_view/flip_view&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===_navigation.html.erb===&lt;br /&gt;
The purpose of this variable becomes clear when we investigate _navigation.html.erb. This file is the first step in rendering the navigation menu at the top. While this process does involve other files, the determination of which menu items to render is handled here, which is the point at which student view interacts. The relevant portion of code is given below:&lt;br /&gt;
  ...&lt;br /&gt;
  &amp;lt;% if session[:menu] %&amp;gt;&lt;br /&gt;
  &amp;lt;!-- if student_view is inactive (session[:flip_user] is not set to true),&lt;br /&gt;
       show the standard navigation menu --&amp;gt;&lt;br /&gt;
    &amp;lt;% if !session[:flip_user] || session[:flip_user] == nil  %&amp;gt;&lt;br /&gt;
      &amp;lt;%= render :partial =&amp;gt; 'menu_items/suckerfish',&lt;br /&gt;
             :locals =&amp;gt; { items: session[:menu].get_menu(0) - [26, 59], level: 0 } %&amp;gt;&lt;br /&gt;
      &amp;lt;!-- if student_view is active for instructor, render student view navigation menu,&lt;br /&gt;
       including the Instructor View button --&amp;gt;&lt;br /&gt;
    &amp;lt;% elsif session[:user].role.name == 'Instructor' %&amp;gt;&lt;br /&gt;
      &amp;lt;% session[:menu] = Role.student.cache[:menu] %&amp;gt;&lt;br /&gt;
        &amp;lt;%= render :partial =&amp;gt; 'menu_items/suckerfish',&lt;br /&gt;
                         :locals =&amp;gt; { items: session[:menu].get_menu(0), level: 0 } %&amp;gt;&lt;br /&gt;
        &amp;lt;% session[:menu] = Role.instructor.cache[:menu] %&amp;gt;&lt;br /&gt;
        &amp;lt;%= render :partial =&amp;gt; 'menu_items/suckerfish',&lt;br /&gt;
                         :locals =&amp;gt; { items: session[:menu].get_menu(0) &amp;amp; [59], level: 0 } %&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
&lt;br /&gt;
The second line is where the [:flip_user] session variable becomes relevant. If this variable is either false or nil (set to false or uninitialized), then the standard instructor view is rendered (the 26 and 59 subtracted from &amp;quot;items&amp;quot; are removing menu items exclusive to the Student View, Assignments and Instructor View, respectively). If this condition fails (and the user is an instructor), it implies the instructor has set that variable to true. In that case, the student view menu items are found (the cache for the student menu items is pulled from Role.student.cache[:menu]) and then rendered, with the addition of the &amp;quot;Instructor View&amp;quot; button (indicated by the &amp;amp; [59]).&lt;br /&gt;
&lt;br /&gt;
Thus, by clicking the view button, the re-rendered page gains a newly updated navigation bar, depending on the state of session[:flip_user], which will continue to persist for the entire expertiza session.&lt;br /&gt;
&lt;br /&gt;
===_role_instructor.yml===&lt;br /&gt;
It is typically said that one should not edit config files lightly, and so we made sure to be careful with our changes to role_instructor.yml. However, changes were necessary, as this file is what supplies the data called in _navigation.html.erb by Role.instructor.cache[:menu]. It took a while to determine this, but the navigation menu items displayed at the top of the Expertiza view are defined under the :menu: items of this file. Each listed Menu::Node item is rendered within the navigational menu, with associated label, name, and url.&lt;br /&gt;
&lt;br /&gt;
Because there was no way to know what other files or controllers may rely on this file, the only change we made was the addition of two new menu nodes: student_view and instructor_view, both with a url leading to the route for student_view_controller's flip_user method. Each was added to all three databases (development, testing, and deployment), and each was assigned a corresponding id (58 for student_view, and 59 for instructor_view). The added code can be seen below:&lt;br /&gt;
&lt;br /&gt;
    ...&lt;br /&gt;
      58: &amp;amp;58 !ruby/object:Menu::Node&lt;br /&gt;
        content_page_id:&lt;br /&gt;
        controller_action_id: 58&lt;br /&gt;
        id: 58&lt;br /&gt;
        label: Student View&lt;br /&gt;
        name: student_view&lt;br /&gt;
        parent:&lt;br /&gt;
        parent_id:&lt;br /&gt;
        site_controller_id: 58&lt;br /&gt;
        url: &amp;quot;/student_view/flip_view&amp;quot;&lt;br /&gt;
      59: &amp;amp;59 !ruby/object:Menu::Node&lt;br /&gt;
        content_page_id:&lt;br /&gt;
        controller_action_id: 59&lt;br /&gt;
        id: 59&lt;br /&gt;
        label: Instructor View&lt;br /&gt;
        name: instructor_view&lt;br /&gt;
        parent:&lt;br /&gt;
        parent_id:&lt;br /&gt;
        site_controller_id: 59&lt;br /&gt;
        url: &amp;quot;/student_view/flip_view&amp;quot;&lt;br /&gt;
    ...&lt;br /&gt;
&lt;br /&gt;
Thus, these two nodes are now loaded when the navigational bar is loaded, allowing them to appear. However, 59 is removed from the normal instructor view, and is added back in with the student view.&lt;br /&gt;
&lt;br /&gt;
It's worthy to note that, currently, the Assignments menu item is manually removed from the navigation bar in _navigation.html.erb (the subtracted 26 when rendering the instructor view). While it would presumably be more clean to remove the menu node object all together, due to an abundance of caution, we decided it best not to remove any data from this config file, as again, its contents may be used by other controllers and methods we are not aware of. Future development may be able to determine if this caution is unnecessary, and make this change.&lt;br /&gt;
&lt;br /&gt;
This concludes all major changes and additions. All other modifications were minor changes already referenced, and so will not be discussed in detail.&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
In order to test the functionality of this change, a spec file was created to enforce unit tests on the student view controller, in a file titled &amp;quot;student_view_controller_spec.rb&amp;quot;. The goals of this testing file were as follows:&lt;br /&gt;
&lt;br /&gt;
*only instructors are able to switch between student and instructor view&lt;br /&gt;
*the flip user flag is worked as expected&lt;br /&gt;
*navigation is occurring as expected&lt;br /&gt;
&lt;br /&gt;
We believe that, so long as the above functionality is working correctly, the controller is adequately tested. Testing that only instructors can access the method ensures that it is not accessed by inappropriate users such as students, matching similar functionality for features like student impersonation. Checking that the flip user flag works when navigating between pages and when calling the method ensures that the changes to the view will occur successfully, and that both student and instructor views can be toggled between. Finally, ensuring that navigation works as expected ensures that the method is being called correctly and is having no issues regarding redirection back to the homepage.&lt;br /&gt;
&lt;br /&gt;
A reasonable criticism would be that only using a unit test for the controller would not test to ensure that a user could actually interact with the controller through a visible link in the view. Doing so would require a feature test, presumably involving something like Capybara ensuring that the link is visible and accessible, and that clicking it changes the view as expected. In fact, as was recently taught in Dr. Gehringer's Object Oriented Design class, this is arguably the only sort of test necessary. The internals of how the flip user flag functions and such can be considered internal functions, while we only care about an incoming command (switching views should lead to a measurable change in the navigation bar) and an outgoing command (clicking the switch view button sends a message to switch the views).&lt;br /&gt;
&lt;br /&gt;
Unfortunately, for a reason we were unable to determine, the simplified view Capybara renders would not render the newly updated navigation bar. Various options and variations were tried to correct this issue, but no change had the desired effect (including ensuring we made our changes to the testing data for &amp;quot;role_instructor.yml&amp;quot;). This issue seems to only affect Capybara, as the link is visible and clickable on both the development build and a deployed Heroku build. For the time being, we were thus unable to create a feature test for this topic, although we strongly believe the feature to be working as intended. Should anyone work on this project in the future, this would be a great area of improvement.&lt;br /&gt;
&lt;br /&gt;
Thus, for the moment, asserting the value of the flip_user variable is a stand-in for testing the incoming command (the :flip_user variable is treated as a public side-effect), and the access testing is a stand-in for the outgoing command (the controller must be accessible and able to make its changes).&lt;br /&gt;
&lt;br /&gt;
===Actions taken before testing===&lt;br /&gt;
Before any testing occurs, an instructor and student are built using factories. Then, before each test, the current user is set to be the created instructor. This ensures we have the proper permissions to use the method. The created student is used for testing that we can only access this method as an instructor, not a student. The code for this test context is given below.&lt;br /&gt;
&lt;br /&gt;
 describe StudentViewController do&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 2) }&lt;br /&gt;
  let(:student1) { build(:student, id: 30, name: :Amanda)}&lt;br /&gt;
  # student view is only accessible to instructors, so we will make one&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===Access Tests===&lt;br /&gt;
&lt;br /&gt;
The first component tested is to ensure that access is properly handled. First, we simply check if we are allowed to access the student_view_controller when logged in as an instructor. We then change our login to that of a student, and check that we are no longer able to take actions with the controller. The code that accomplishes this is given below.&lt;br /&gt;
&lt;br /&gt;
  describe &amp;quot;check access&amp;quot; do&lt;br /&gt;
    it &amp;quot;instructor should be able to call flip user&amp;quot; do&lt;br /&gt;
      expect(controller.action_allowed?).to be true&lt;br /&gt;
    end&lt;br /&gt;
    it &amp;quot;student should not be able to call flip user&amp;quot; do&lt;br /&gt;
      stub_current_user(student1, student1.role.name, student1.role)&lt;br /&gt;
      expect(controller.action_allowed?).to be false&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===Student View Flag Tests===&lt;br /&gt;
To ensure that requesting the navigational view be flipped is working as expected, we first test that the flag is nil by default (defaulting to the instructor view), that calling &amp;quot;flip_view&amp;quot; once changes the flag to true, and that calling it again changes the flag to false. Assuming that the changes to the navigational view are working as intended (a different set of links is rendered depending upon the status of the :flip_user variable), this adequately tests that the primary functionality of the Student/Instructor View link is working. The test code is given below.&lt;br /&gt;
&lt;br /&gt;
  describe &amp;quot;the student view flag working as expected&amp;quot; do&lt;br /&gt;
    it 'flag should not be initialized by default' do&lt;br /&gt;
      expect(session[:flip_user]).to eq nil&lt;br /&gt;
    end&lt;br /&gt;
    it 'flag should be set to true after selecting student view' do&lt;br /&gt;
      post :flip_view&lt;br /&gt;
      expect(session[:flip_user]).to eq true&lt;br /&gt;
    end&lt;br /&gt;
    it 'flag should become false after using student view twice' do&lt;br /&gt;
      post :flip_view&lt;br /&gt;
      post :flip_view&lt;br /&gt;
      expect(session[:flip_user]).to eq false&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===Navigational Tests===&lt;br /&gt;
These last tests simply determine that, after flipping from one view to another, the user is redirected back to the home page. This redirection is done to avoid the edge cases involving a user being on a page that should not be accessible to the view they currently have selected (for example, being on an instructor-only page after changing to the student view). The code to test this is given below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  describe &amp;quot;navigation should work as intended&amp;quot; do&lt;br /&gt;
    it 'should be redirected to homepage after entering student view' do&lt;br /&gt;
      post :flip_view&lt;br /&gt;
      expect(response).to redirect_to(&amp;quot;/&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    it 'should be redirected to homepage after exiting student view' do&lt;br /&gt;
      post :flip_view&lt;br /&gt;
      post :flip_view&lt;br /&gt;
      expect(response).to redirect_to(&amp;quot;/&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
This concludes the testing for this feature. So long as all the above tests pass, we can be confident the controller method is working as intended, and thus that the student/instructor view is working properly.&lt;br /&gt;
&lt;br /&gt;
==Feature Demo==&lt;br /&gt;
In place of a feature test, we here present a demo of the functionality working as intended. To summarize the contents, a user logs in as an instructor, clicks &amp;quot;Student View&amp;quot; in the navigational bar, and has their bar be changed to that of a student. They then click a newly added &amp;quot;Instructor View&amp;quot; link, and are returned to the navigational bar of an instructor.&lt;br /&gt;
 [https://drive.google.com/file/d/1tArc7o5_mSfy8R4Yt3J9wMBDdcHUQtN_ Navi Student View for Instructor Feature Demo]&lt;br /&gt;
&lt;br /&gt;
==Conclusions and Future Work==&lt;br /&gt;
We believe this feature to be working in its entirety and hope it will be a helpful tool to improve the teaching options of instructors.&lt;br /&gt;
&lt;br /&gt;
If future changes were to be made to this feature, the following suggestions may be applicable:&lt;br /&gt;
*A means of performing feature tests. Due to an unknown error in capybara's simplified testing view, any tests specifically looking for the Instructor View button seemed to fail. This error has not occurred on any fully rendered version of the application, nor on the Heroku-hosted server. It would be benefitial to implement tests to ensure the link appears correctly for users, but it's not clear how to do so with this issue. Finding a way to feature test would be preferrable.&lt;br /&gt;
*As previously noted, if the Menu::Node objects listed in role_instructor.yml are exclusively used for rendering the navigational bar, the Assignments node object should be removed entirely, and the code where 26 is removed from the items rendered in _navigation.html.erb changed to reflect this removal.&lt;br /&gt;
&lt;br /&gt;
==Github==&lt;br /&gt;
The Github corresponding to this task is publicly available here: https://github.com/Aeront39/expertiza&lt;br /&gt;
&lt;br /&gt;
==Contributors==&lt;br /&gt;
This feature was created as part of Dr. Edward Gehringer's &amp;quot;CSC/ECE 517: Object-Oriented Design and Development&amp;quot; class, Fall 2021. The contributors were: WeiRui Wang, Geoff Garrido, and Ayush Luthra. Our project mentor was Yi Qiu (yqiu9@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Aluthra</name></author>
	</entry>
</feed>