summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornfoy <nfoy@purdue.edu>2014-04-27 19:12:07 -0400
committernfoy <nfoy@purdue.edu>2014-04-27 19:12:07 -0400
commit95542d38ddae5700e7fa35c166260a51ce17e46a (patch)
tree3ed1b9fcb793a426901586367dc5212819e9bff5
parent07dbbeb404dedcf9733262ae2ce9cdddc086bb0e (diff)
parent8b1e26bf00c7e536def47ae4ef3441192f154aa8 (diff)
Merge branch 'master' of https://github.com/LukeShu/leaguer
-rw-r--r--app/controllers/matches_controller.rb2
-rw-r--r--app/models/game_setting.rb13
-rw-r--r--app/models/tournament_setting.rb4
-rw-r--r--lib/sampling/README.md15
-rw-r--r--lib/scheduling/README.md19
-rw-r--r--lib/scheduling/round_robin.rb8
-rw-r--r--lib/scoring/README.md7
-rw-r--r--lib/seeding/README.md5
-rw-r--r--lib/seeding/early_bird_seeding.rb2
-rw-r--r--lib/seeding/fair_ranked_seeding.rb2
-rw-r--r--lib/seeding/random_seeding.rb2
11 files changed, 64 insertions, 15 deletions
diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb
index 4a20df2..8b8e86d 100644
--- a/app/controllers/matches_controller.rb
+++ b/app/controllers/matches_controller.rb
@@ -286,7 +286,7 @@ class MatchesController < ApplicationController
params.require(:match).permit(:status, :tournament_stage_id, :winner_id, :remote_id, :submitted_peer_evaluations, :update_action)
end
- # Turn of check_edit, since our #update is flexible
+ # Turn of check_edit, since our #update is flexible
def check_edit
set_match
end
diff --git a/app/models/game_setting.rb b/app/models/game_setting.rb
index bff8d97..e701cae 100644
--- a/app/models/game_setting.rb
+++ b/app/models/game_setting.rb
@@ -1,3 +1,16 @@
class GameSetting < ActiveRecord::Base
belongs_to :game
+
+ alias_attribute :value, :default
+
+ def self.types
+ return {
+ :text_short => 0,
+ :text_long => 1,
+ :pick_one_radio => 2,
+ :pick_several => 3,
+ :true_false => 4,
+ :pick_one_dropdown => 5,
+ }
+ end
end
diff --git a/app/models/tournament_setting.rb b/app/models/tournament_setting.rb
index b3e6ace..9efaaea 100644
--- a/app/models/tournament_setting.rb
+++ b/app/models/tournament_setting.rb
@@ -1,3 +1,7 @@
class TournamentSetting < ActiveRecord::Base
belongs_to :tournament
+
+ def self.types
+ GameSetting.types
+ end
end
diff --git a/lib/sampling/README.md b/lib/sampling/README.md
index 28c603e..731f1d1 100644
--- a/lib/sampling/README.md
+++ b/lib/sampling/README.md
@@ -1,28 +1,41 @@
-Files in this directory should be modules implementing the following
+Sampling interface
+==================
+
+Files in this directory should be _modules_ implementing the following
interface:
- `works_with?(Game) => Boolean`
+
Returns whether or not this sampling method works with the
specified game.
- `uses_remote?() => Boolean`
+
Return whether or not this sampling method requires remote IDs for
users.
- `set_remote_name(User, Game, String)`
+
Set the remote ID for a user for the specified game. It is safe to
assume that this sampling method `works_with?` that game.
- `get_remote_name(Object)`
+
When given an object from `RemoteUsername#value`, give back a
human-readable/editable name to display.
- `sampling_start(Match)`
+
Fetch the statistics for a match.
+
- `sampling_done?(Match) => Boolean`
+
Returns whether or not statistics have been completely collected
yet.
- `render_user_interaction(Match, User) => String`
+
Returns HTML to render on a page.
+
- `handle_user_interaction(Match, User, Hash params)`
+
Handles params from the form generated by
`#user_interaction_render`.
diff --git a/lib/scheduling/README.md b/lib/scheduling/README.md
index 173b7be..8b21164 100644
--- a/lib/scheduling/README.md
+++ b/lib/scheduling/README.md
@@ -1,13 +1,22 @@
-Files in this directory should implement the following interface:
+Scheduling interface
+====================
+
+Files in this directory should be _classes_ implementing the following
+interface:
- `initialize(tournament_stage)`
- construct new Scheduling object from tournament_stage
+
+ Construct new Scheduling object from tournament_stage.
- `create_matches`
- creates all the matches of the current round
+
+ Creates all the matches of the current round.
- `finish_match(match)`
- progresses the match through the schedule
+
+ Progresses the match through the schedule.
- `graph`
- returns a string representation of an svg image of the current stage \ No newline at end of file
+
+ Returns a string representation of an svg image of the current
+ stage.
diff --git a/lib/scheduling/round_robin.rb b/lib/scheduling/round_robin.rb
index 7a9e257..1d9ac0d 100644
--- a/lib/scheduling/round_robin.rb
+++ b/lib/scheduling/round_robin.rb
@@ -7,11 +7,15 @@ module Scheduling
end
def create_matches
+ #number of teams*number of teams per match = number of matches per round
num_teams = (tournament.players.count/tournament.min_players_per_team).floor
- num_matches = Float(num_teams/2)*(num_teams-1)
- for i in 1..num_matches
+ @matches_per_round = num_teams * tournament.min_teams_per_match
+
+ @matches_per_round.each do |match|
tournament_stage.matches.create(status: 0, submitted_peer_evaluations: 0)
end
+
+ tournament_stage.seeding.seed_matches(tournament_stage)
end
def finish_match(match)
diff --git a/lib/scoring/README.md b/lib/scoring/README.md
index 95dd5e0..5beb0a2 100644
--- a/lib/scoring/README.md
+++ b/lib/scoring/README.md
@@ -1,10 +1,15 @@
-Files in this directory should be modules implementing the following
+Scoring interface
+=================
+
+Files in this directory should be _modules_ implementing the following
interface:
- `stats_needed() => Array[i]=Symbol`
+
Returns which statistics need to be collected for this scoring
algorithm.
- `score(match) => Hash[User]=Integer`
+
User scores for this match, assuming statistics have been
collected.
diff --git a/lib/seeding/README.md b/lib/seeding/README.md
index 67fc19b..596adea 100644
--- a/lib/seeding/README.md
+++ b/lib/seeding/README.md
@@ -1,4 +1,5 @@
Files in this directory should implement the following interface:
-- seed_matches(tournament)
- take the matches of a tournament and the players in a tournament, assign players to teams, and teams to matches (all must exist) \ No newline at end of file
+- `seed(tournament_stage)`
+ take a tournament stage, assign players to teams and teams to
+ matches (matches must exist) \ No newline at end of file
diff --git a/lib/seeding/early_bird_seeding.rb b/lib/seeding/early_bird_seeding.rb
index 30e15fc..f3fc6f9 100644
--- a/lib/seeding/early_bird_seeding.rb
+++ b/lib/seeding/early_bird_seeding.rb
@@ -1,6 +1,6 @@
module Seeding
class EarlyBirdSeeding
- def seed_matches(tournament)
+ def seed(tournament_stage)
matches = tournament.current_stage.matches
match = matches.first
match_num = 0
diff --git a/lib/seeding/fair_ranked_seeding.rb b/lib/seeding/fair_ranked_seeding.rb
index 4eb8c26..22c245e 100644
--- a/lib/seeding/fair_ranked_seeding.rb
+++ b/lib/seeding/fair_ranked_seeding.rb
@@ -1,6 +1,6 @@
module Seeding
class FairRankedSeeding
- def seed_matches(tournament)
+ def seed(tournament_stage)
matches = tournament.current_stage.matches
match = matches.first
match_num = 0
diff --git a/lib/seeding/random_seeding.rb b/lib/seeding/random_seeding.rb
index ec39e61..bc332ef 100644
--- a/lib/seeding/random_seeding.rb
+++ b/lib/seeding/random_seeding.rb
@@ -1,6 +1,6 @@
module Seeding
class RandomSeeding
- def seed_matches(tournament)
+ def seed(tournament_stage)
matches = tournament.current_stage.matches
match = matches.first
match_num = 0