app/controllers/review_bids_controller.rb
# if some participants don't get assigned reviews from peerlogic,
# randomly assign availables reviews to them
if some participants don't get assigned reviews from peerlogic,
randomly assign availables reviews to them
if some participants don ' t get assigned reviews from peerlogic randomly assign availables reviews to them
def run_intelligent_bid(assignment, teams, participants, bid_result)
    team_assigned_count = {}
    participant_count = {}
    response_mappings = []
    participants.each do |participant|
      participant_count[participant.id] = 0
    end
    teams.each do |team|
      team_assigned_count[team] = 0
    end
    bid_result.each do |participant_bid|
      participant_bid["items"].each do |team_id|
        response_mappings << {pid: participant_bid["pid"], team: team_id}
        team_assigned_count[team_id] += 1
        participant_count[participant_bid["pid"]] += 1
      end
    end
    participants.each do |participant|
      while participant_count[participant.id] < assignment.num_reviews_required
        team = teams[rand(teams.count)]
        next if team_assigned_count[team] >= assignment.max_reviews_per_submission
        team_assigned_count[team] += 1
        participant_count[participant.id] += 1
        response_mappings << {pid: participant.id, team: team}
      end
    end
    response_mappings
  end
def run_intelligent_bid ( assignment , teams , participants , bid_result ) team_assigned_count = { } participant_count = { } response_mappings = [ ] participants . each do | participant | participant_count [ participant . id ] = 0 end teams . each do | team | team_assigned_count [ team ] = 0 end bid_result . each do | participant_bid | participant_bid [ "items" ] . each do | team_id | response_mappings << { pid : participant_bid [ "pid" ] , team : team_id } team_assigned_count [ team_id ] += 1 participant_count [ participant_bid [ "pid" ] ] += 1 end end participants . each do | participant | while participant_count [ participant . id ] < assignment . num_reviews_required team = teams [ rand ( teams . count ) ] next if team_assigned_count [ team ] >= assignment . max_reviews_per_submission team_assigned_count [ team ] += 1 participant_count [ participant . id ] += 1 response_mappings << { pid : participant . id , team : team } end end response_mappings end
if some participants don't get assigned reviews from peerlogic,
randomly assign availables reviews to them
if some participants don ' t get assigned reviews from peerlogic randomly assign availables reviews to them
# make a record for the bidding result from peerlogic # counting how many participants are assigned with this team # counting how many reviews are assigned to each participant # if after the bidding, there are some participants who do not have enough available reviews # assign them with some random teams
assignment
teams
participants
bid_result