From 29df65e51b2cb38e31b1c377c536e7bba1eecc90 Mon Sep 17 00:00:00 2001 From: AndrewMurrell Date: Mon, 7 Apr 2014 02:57:59 -0400 Subject: Updated Peer Review -- Now allows review and scoring -- not tested because Davis can not yaml. --- app/controllers/matches_controller.rb | 14 ++++++++++++++ app/views/matches/show.html.erb | 19 +++++++++++++++++-- app/views/tournaments/_selected.html.erb | 4 ++-- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index 93b5514..97b8b83 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -193,6 +193,20 @@ class MatchesController < ApplicationController end end when "finish" + order = params[:review_action] + base_score = 2 + next_score = 3 + order.split(",").reverse.each do |elem| + player_score = base_score + if @match.winner.user.include?(@current_user) + player_score += 10 + else + player_score += 7 + end + Score.create(user: elem, match: @match, value: player_score ) + base_score = next_score + next_score += base_score + end @match.status = 3 respond_to do |format| if @match.save diff --git a/app/views/matches/show.html.erb b/app/views/matches/show.html.erb index cd30926..a0540f9 100644 --- a/app/views/matches/show.html.erb +++ b/app/views/matches/show.html.erb @@ -117,7 +117,7 @@ <% if @tournament.players.include?(current_user) %>
- <%= form_tag(tournament_match_path(@tournament, @match), method: "put") do %> + <%= form_tag(tournament_match_path(@tournament, @match), method: "put", name: "peeris") do %> <% case @match.status %> <% when 0 %> @@ -126,8 +126,9 @@ <%= submit_tag("Begin Peer Evaluation") %> <% when 2 %> + - <%= submit_tag("End Match") %> + <%= submit_tag("End Peer Evaluation", :onsubmit => "score_peers()") %> <% when 3 %> <%= submit_tag("Reset Status") %> @@ -136,3 +137,17 @@
<% end %> + + + + diff --git a/app/views/tournaments/_selected.html.erb b/app/views/tournaments/_selected.html.erb index d37c741..1be1adf 100644 --- a/app/views/tournaments/_selected.html.erb +++ b/app/views/tournaments/_selected.html.erb @@ -23,9 +23,9 @@ <% when 0 %> <%= setting_fields.text_field( setting.name, :name ) %> <% when 1 %> - <%= setting_fields.text_area( setting.name, setting.name ) %> + <%#setting_fields.text_area( setting.name, setting.name ) %> <% when 2 %> - <%= setting_fields.collection_radio_buttons( setting.name, setting.type_opt.split(',') ) %> + <%#setting_fields.collection_radio_buttons( setting.name, setting.type_opt.split(',') ) %> <% when 3 %> <%= setting_fields.collection_check_boxes( setting.name, setting.type_opt.split(',') ) %> <% when 4 %> -- cgit v1.2.3-2-g168b