summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrewMurrell <amurrel@purdue.edu>2014-04-24 00:46:42 -0400
committerAndrewMurrell <amurrel@purdue.edu>2014-04-24 00:46:42 -0400
commit1942d4307f392d61d13cdc488fecd523f55e427d (patch)
treed4ad5210f28a2c07aaca9548ebd883e1672cd2d8
parent1429cd41bb4af3429f28dc97efd6994433ebde7b (diff)
Fixed Spacing, Scoring, and began implementing statistics
-rw-r--r--app/assets/javascripts/tournaments/show.js.coffee2
-rw-r--r--app/controllers/matches_controller.rb5
-rw-r--r--app/models/user.rb6
-rw-r--r--app/views/matches/show.html.erb2
4 files changed, 12 insertions, 3 deletions
diff --git a/app/assets/javascripts/tournaments/show.js.coffee b/app/assets/javascripts/tournaments/show.js.coffee
index ef6bb82..8620210 100644
--- a/app/assets/javascripts/tournaments/show.js.coffee
+++ b/app/assets/javascripts/tournaments/show.js.coffee
@@ -29,4 +29,4 @@ update = (tournament) ->
# Now kick off the whole process
window.onload = ->
- $.ajax(url: json_url).done update
+ $.ajax(url: json_url).done update
diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb
index 254f797..8a8b9ca 100644
--- a/app/controllers/matches_controller.rb
+++ b/app/controllers/matches_controller.rb
@@ -142,6 +142,11 @@ class MatchesController < ApplicationController
end
end
when "finish"
+
+ #make this use the statistics interface for scoring and ScoringAlgorithms
+
+
+
# Individual scores
scores = params["scores"]
scores.each do |user_name, score|
diff --git a/app/models/user.rb b/app/models/user.rb
index 5c0b5b1..e5ae7ea 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -5,7 +5,7 @@ class User < ActiveRecord::Base
has_and_belongs_to_many :tournaments_hosted, class_name: "Tournament", foreign_key: "host_id", join_table: "hosts_tournaments"
has_and_belongs_to_many :teams
has_many :sessions
- has_many :scores
+ has_many :statistics
has_many :remote_usernames
apply_simple_captcha
@@ -23,6 +23,10 @@ class User < ActiveRecord::Base
self.permissions ||= Server.first.default_user_permissions
end
+ def scores
+ self.statistics.find_by_name(:score)
+ end
+
def find_remote_username(game)
obj = self.remote_usernames.where(:game => game).first
if obj.nil?
diff --git a/app/views/matches/show.html.erb b/app/views/matches/show.html.erb
index e61d6b3..e9809a2 100644
--- a/app/views/matches/show.html.erb
+++ b/app/views/matches/show.html.erb
@@ -82,7 +82,7 @@ function score_peers() {
<% team.users.collect{|u| u.user_name}.each do |k| %><label>
Score for <%= k %><br>
<% @player_score = 0 %>
- <% current_user.scores.find_by_match(@match).each{ |s| @player_score+=s.value } %>
+ <% current_user.statistics.where(:match => @match, :user => current_user).each{ |s| @player_score+=s.value } %>
<%= text_field_tag("scores[#{k}]", @player_score, size: 3) %>
</label><% end %>
</fieldset>