Skip to content

Commit

Permalink
Merge c952ed4 into 4c3174c
Browse files Browse the repository at this point in the history
  • Loading branch information
vijdurk committed May 1, 2022
2 parents 4c3174c + c952ed4 commit 3cf47db
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 16 deletions.
6 changes: 4 additions & 2 deletions app/controllers/review_bids_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def show
@num_participants = AssignmentParticipant.where(parent_id: @assignment.id).count
@selected_topics = nil # this is used to list the topics assigned to review. (ie select == assigned i believe)
@bids = ReviewBid.where(participant_id: @participant, assignment_id: @assignment.id)
@count = ReviewBid.all.count
#(:conditions => "priority = 1")
signed_up_topics = []
@bids.each do |bid|
sign_up_topic = SignUpTopic.find_by(id: bid.signuptopic_id)
Expand Down Expand Up @@ -99,7 +101,7 @@ def assign_bidding
# list of reviewer id's from a specific assignment
reviewer_ids = AssignmentParticipant.where(parent_id: assignment_id).ids
bidding_data = ReviewBid.bidding_data(assignment_id, reviewer_ids)
matched_topics = run_bidding_algorithm(bidding_data)
matched_topics = assign_reviewers(bidding_data)
ReviewBid.assign_review_topics(assignment_id, reviewer_ids, matched_topics)
Assignment.find(assignment_id).update(can_choose_topic_to_review: false) # turns off bidding for students
redirect_back fallback_location: root_path
Expand All @@ -109,7 +111,7 @@ def assign_bidding
# passing webserver: student_ids, topic_ids, student_preferences, time_stamps
# webserver returns:
# returns matched assignments as json body
def run_bidding_algorithm(bidding_data)
def assign_reviewers(bidding_data)
# begin
url = 'http://app-csc517.herokuapp.com/match_topics' # hard coding for the time being
response = RestClient.post url, bidding_data.to_json, content_type: 'application/json', accept: :json
Expand Down
4 changes: 2 additions & 2 deletions app/views/assignments/edit/_topics.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<%= label_tag('assignment_form[assignment][can_choose_topic_to_review]', 'Allow reviewer to choose which topic to review?') %>

<br>
<% if @assignment_form.assignment.can_choose_topic_to_review? == true %>

<input name="assignment_form[assignment][review_choosing_algorithm]" type="hidden" value="Simple Choose"/>
<%= label_tag('assignment_form[assignment][review_choosing_algorithm]', 'Method for reviewer to choose which topic to review:') %>
<%= select('assignment_form[assignment]', 'review_choosing_algorithm',[['Simple Choose', 'Simple Choose'],['Bidding','Bidding']], {:selected => @assignment_form.assignment.review_choosing_algorithm})%>
Expand All @@ -31,7 +31,7 @@
<% if @assignment_form.assignment.review_choosing_algorithm == "Bidding" %>
<%= button_to 'Run Review Algorithm', :controller=>'review_bids', :action=>'assign_bidding', :assignment_id => @assignment_form.assignment.id %>
<% end %>
<% end %>


<br>
<input name="assignment_form[assignment][use_bookmark]" type="hidden" value="false"/>
Expand Down
14 changes: 6 additions & 8 deletions app/views/sign_up_sheet/review_bids_others_work.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<%= flash[:notice] %>
</div>
<% end %>

<h2>Reviews for</h2>
<h2>Reviews for "<%= @assignment.name %>"</h2>

<!-- add headers that provide information regarding review numbers -->
Expand Down Expand Up @@ -34,13 +34,11 @@
<td>
<b><%= "#{title} #{review_no}." %></b>
<!--In ‘review_bids/index’ page, if the topic_identifier is empty, ‘:’ sign should not be displayed.-->
<% if !topic_id.nil? %>
<% if SignUpTopic.find(topic_id).topic_identifier != '' %>
<%= " #{SignUpTopic.find(topic_id).topic_identifier}: #{SignUpTopic.find(topic_id).topic_name}" %>
<% else %>
<%= " #{SignUpTopic.find(topic_id).topic_name}" %>
<% end %>
<% end %>
<% if !topic_id.nil? && SignUpTopic.find(topic_id).topic_identifier != '' %>
<%= " #{SignUpTopic.find(topic_id).topic_identifier}: #{SignUpTopic.find(topic_id).topic_name}" %>
<% elsif !topic_id.nil? %>
<%= " #{SignUpTopic.find(topic_id).topic_name}" %>
<% end %>
<%if !@assignment.is_anonymous%>
&nbsp; (author: <%= participant.fullname%>)
Expand Down
2 changes: 2 additions & 0 deletions app/views/sign_up_sheet/review_bids_show.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<h1>Bidding sheet for <%= @assignment.name %> reviews</h1>
<h3> Number of bids <%= @count %></h3>
<div style="display:block">
<h3 style="width: 40%; float: left">Topics</h3>
<h3 style="width: 40%; float:right">Review Bid Selections</h3>

</div>

<div style="display:block">
Expand Down
6 changes: 3 additions & 3 deletions spec/controllers/review_bids_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@
end
end

describe '#run_bidding_algorithm' do
describe '#assign_reviewers' do
render_views
it 'connects to the webservice to run bidding algorithm' do
post :run_bidding_algorithm
it 'connects to the webservice to assign reviewers' do
post :assign_reviewers
expect(response).to have_http_status(302)
end
end
Expand Down
11 changes: 10 additions & 1 deletion spec/helpers/review_bids_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,13 @@
end
end
end
end
describe '#get_topic_bg_color_review_bids' do
context 'when bid size is 0' do
it 'changes colour' do
allow(ReviewBid).to receive(:where).and_return([])
num_bids=0
expect(helper.get_topic_bg_color_review_bids(topic,2)).to eq("rgb(47,352,0)")
end
end
end
end

0 comments on commit 3cf47db

Please sign in to comment.