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 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'app/controllers/matches_controller.rb') 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 -- cgit v1.2.3 From 22d74ce5b34140b353d43a1848fe51eaaa254d84 Mon Sep 17 00:00:00 2001 From: AndrewMurrell Date: Mon, 7 Apr 2014 03:28:37 -0400 Subject: updated matches controller and added hooks --- app/controllers/matches_controller.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'app/controllers/matches_controller.rb') diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index 97b8b83..fc44e35 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -207,7 +207,10 @@ class MatchesController < ApplicationController base_score = next_score next_score += base_score end - @match.status = 3 + @match.submitted_peer_reviews += 1 + if (@match.submitted_peer_reviews == @match.players.count) + @match.status = 3 + end respond_to do |format| if @match.save format.html { redirect_to tournament_match_path(@tournament, @match), notice: 'Peer Review Submitted' } -- cgit v1.2.3 From fea1311388477583b31fa3214a7241a7322f494a Mon Sep 17 00:00:00 2001 From: AndrewMurrell Date: Mon, 7 Apr 2014 03:35:49 -0400 Subject: Updated Generate and Re-added hoooks --- app/controllers/matches_controller.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'app/controllers/matches_controller.rb') diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index fc44e35..9c0a740 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -147,11 +147,12 @@ class MatchesController < ApplicationController if (@match.status == 1) @scores = @match.scores end - file_blue = "blue.yaml" - file_purple = "purple.yaml" - @blue2 = YAML.load_file(file_blue) - @purp2 = YAML.load_file(file_purple) - + if Tournament.find_by_id(@match.tournament_id).game_id == 1 + file_blue = "blue.yaml" + file_purple = "purple.yaml" + @blue2 = YAML.load_file(file_blue) + @purp2 = YAML.load_file(file_purple) + end end def update -- cgit v1.2.3