summaryrefslogtreecommitdiff
path: root/app/controllers/matches_controller.rb
diff options
context:
space:
mode:
authorAndrewMurrell <amurrel@purdue.edu>2014-04-26 18:45:54 -0400
committerAndrewMurrell <amurrel@purdue.edu>2014-04-26 18:45:54 -0400
commit36cdca9bc95599e67f73889c3ebf7d52f55f06eb (patch)
tree58acaf609f4becce962016b84b68b1e5d8862e1c /app/controllers/matches_controller.rb
parent10749a6242bec56586b71f4e8b886eddc9edc499 (diff)
Added updated Skeleton for match controller.
Diffstat (limited to 'app/controllers/matches_controller.rb')
-rw-r--r--app/controllers/matches_controller.rb37
1 files changed, 32 insertions, 5 deletions
diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb
index b1b283b..6709a53 100644
--- a/app/controllers/matches_controller.rb
+++ b/app/controllers/matches_controller.rb
@@ -168,6 +168,10 @@ class MatchesController < ApplicationController
def update
case params[:update_action]
when "start"
+ #
+ # Redirect to the current match page for this tournament with the correct sampling view rendered
+ #
+
@match.status = 1
respond_to do |format|
if @match.save
@@ -180,15 +184,30 @@ class MatchesController < ApplicationController
end
when "finish"
+ #
+ # Get the winner and blowout status from the params given by the correct sampling view
+ #
+
+
+ #in general
+ #provide contribution
+ #if all contributions are in, update statistics
+
+
#make this use the statistics interface for scoring and ScoringAlgorithms
@match.winner = @match.teams.find_by_id(params['winner'])
- @match.blowout = false
+ @match.statistics.create(name: "blowout", user: nil, value: 0)
- @match.statistics['Score'] = @tournament.settings['ScoringMethod'].constantize.score(@match, @match.statistics)
-=begin
+ #How to access the blowout statistic of a match:
+ @match.statistics.where(:name => "blowout").first.value
+
+
+ #@match.statistics.create(name: 'score', value: @tournament.settings.where(:name => 'Scoring Method').value.constantize.score(@match, @match.statistics)
+
+=begin
# Individual scores
#scores = params["scores"]
#scores.each do |user_name, score|
@@ -233,6 +252,10 @@ class MatchesController < ApplicationController
end
end
when "peer"
+ #
+ # Update user scores via scoring method
+ #
+
order = params[:review_action]
base_score = 2
next_score = 3
@@ -262,10 +285,14 @@ class MatchesController < ApplicationController
end
end
when "reset"
- @match.status = 0
+ #
+ # Reset Match Status to 1 in case something needs to be replayed.
+ #
+
+ @match.status = 1
respond_to do |format|
if @match.save
- format.html { redirect_to tournament_match_path(@tournament, @match), notice: 'Match Status Reset to 0' }
+ format.html { redirect_to tournament_match_path(@tournament, @match), notice: 'Match Status Reset to 1' }
format.json { head :no_content }
else
format.html { redirect_to @tournament, notice: "You don't have permission to start this match." }