diff options
author | tkimia <tkimia@purdue.edu> | 2014-04-28 20:03:34 -0400 |
---|---|---|
committer | tkimia <tkimia@purdue.edu> | 2014-04-28 20:03:34 -0400 |
commit | 1a6450ec1f5c538eff6dbf6f91582c47fb16e3cc (patch) | |
tree | dc1a9455fedb082a3be0bb36ac19aae5cbbe39fd | |
parent | 3992a2e52a950c644cfe56bc23991e3a03166568 (diff) | |
parent | 3ab30900798a838b399d06f28251b6cdd82a94de (diff) |
Merge branch 'master' of https://github.com/LukeShu/leaguer
-rw-r--r-- | app/assets/stylesheets/application/scaffolds.css.scss | 16 | ||||
-rw-r--r-- | app/assets/stylesheets/patch | 54 | ||||
-rw-r--r-- | app/assets/stylesheets/servers.css.scss | 5 | ||||
-rw-r--r-- | app/assets/stylesheets/users.css.scss | 5 | ||||
-rw-r--r-- | app/controllers/matches_controller.rb | 21 | ||||
-rw-r--r-- | app/models/match.rb | 7 | ||||
-rw-r--r-- | app/models/statistic.rb | 23 | ||||
-rw-r--r-- | app/views/alerts/new.html.erb | 2 | ||||
-rw-r--r-- | app/views/pms/index.html.erb | 15 | ||||
-rw-r--r-- | db/migrate/20140428183808_create_simple_captcha_data.rb (renamed from db/migrate/20140428092839_create_simple_captcha_data.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140428223805_create_mailboxer.mailboxer_engine.rb (renamed from db/migrate/20140428132832_create_mailboxer.mailboxer_engine.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140428223806_add_notified_object.mailboxer_engine.rb (renamed from db/migrate/20140428132833_add_notified_object.mailboxer_engine.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140428223807_add_notification_code.mailboxer_engine.rb (renamed from db/migrate/20140428132834_add_notification_code.mailboxer_engine.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140428223808_add_attachments.mailboxer_engine.rb (renamed from db/migrate/20140428132835_add_attachments.mailboxer_engine.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140428223809_rename_receipts_read.mailboxer_engine.rb (renamed from db/migrate/20140428132836_rename_receipts_read.mailboxer_engine.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140428223810_add_global_notification_support.mailboxer_engine.rb (renamed from db/migrate/20140428132837_add_global_notification_support.mailboxer_engine.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140428223812_create_delayed_jobs.rb (renamed from db/migrate/20140428132845_create_delayed_jobs.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140428223815_create_servers.rb (renamed from db/migrate/20140428132852_create_servers.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140428223819_create_matches.rb (renamed from db/migrate/20140428132900_create_matches.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140428223823_create_teams.rb (renamed from db/migrate/20140428132907_create_teams.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140428223827_create_alerts.rb (renamed from db/migrate/20140428132914_create_alerts.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140428223830_create_pms.rb (renamed from db/migrate/20140428132922_create_pms.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140428223834_create_tournaments.rb (renamed from db/migrate/20140428132929_create_tournaments.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140428223838_create_games.rb (renamed from db/migrate/20140428132937_create_games.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140428223842_create_users.rb (renamed from db/migrate/20140428132944_create_users.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140428223845_create_sessions.rb (renamed from db/migrate/20140428132951_create_sessions.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140428223849_create_brackets.rb (renamed from db/migrate/20140428132958_create_brackets.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140428223853_create_game_settings.rb (renamed from db/migrate/20140428133006_create_game_settings.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140428223856_create_tournament_settings.rb (renamed from db/migrate/20140428133013_create_tournament_settings.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140428223900_create_tournament_stages.rb (renamed from db/migrate/20140428133020_create_tournament_stages.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140428223903_create_statistics.rb (renamed from db/migrate/20140428133026_create_statistics.rb) | 2 | ||||
-rw-r--r-- | db/migrate/20140428223907_create_remote_usernames.rb (renamed from db/migrate/20140428133033_create_remote_usernames.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140428223911_create_bracket_matches.rb (renamed from db/migrate/20140428133041_create_bracket_matches.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140428223914_create_api_requests.rb (renamed from db/migrate/20140428133048_create_api_requests.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140428223918_create_tournament_players_join_table.rb (renamed from db/migrate/20140428133055_create_tournament_players_join_table.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140428223922_create_tournament_hosts_join_table.rb (renamed from db/migrate/20140428133102_create_tournament_hosts_join_table.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140428223925_create_team_user_join_table.rb (renamed from db/migrate/20140428133109_create_team_user_join_table.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140428223929_create_match_team_join_table.rb (renamed from db/migrate/20140428133116_create_match_team_join_table.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140428223939_add_hidden_attrs_to_user.rb (renamed from db/migrate/20140428133136_add_hidden_attrs_to_user.rb) | 0 | ||||
-rw-r--r-- | db/schema.rb | 4 | ||||
-rw-r--r-- | db/seeds.rb | 84 | ||||
-rwxr-xr-x | generate.sh | 2 | ||||
-rw-r--r-- | lib/sampling/manual.html.erb | 14 | ||||
-rw-r--r-- | lib/sampling/manual.rb | 7 | ||||
-rw-r--r-- | lib/sampling/peer_review.html.erb | 2 | ||||
-rw-r--r-- | lib/sampling/peer_review.rb | 10 | ||||
-rw-r--r-- | lib/scoring/winner_takes_all.rb | 4 | ||||
-rw-r--r-- | test/fixtures/statistics.yml | 4 |
48 files changed, 206 insertions, 75 deletions
diff --git a/app/assets/stylesheets/application/scaffolds.css.scss b/app/assets/stylesheets/application/scaffolds.css.scss index ae26907..4f0c781 100644 --- a/app/assets/stylesheets/application/scaffolds.css.scss +++ b/app/assets/stylesheets/application/scaffolds.css.scss @@ -39,9 +39,6 @@ html { form.search { @extend .navbar-form; float: right; - input[type="submit"] { - @extend .btn-warning; - } input[type="text"], input[type="search"] { background-color: #303030; border: 2px solid #ED9C28; @@ -51,6 +48,9 @@ html { height: 30px; padding: 0px 5px; } + input[type="submit"] { + @extend .btn-warning; + } } } @@ -77,7 +77,7 @@ html { clear: both; border-top: solid 1px $orange; text-align: center; - margin: 0 auto; + margin: 1em auto 0; width: 90%; } } @@ -115,6 +115,10 @@ fieldset { } } +form ul { + list-style: none; +} + a, button, input[type="submit"] { @extend .btn; &.user { @extend .btn-info; } @@ -144,7 +148,7 @@ input, textarea{ border: 3px inset #A5A5A5; padding: 8px; - color: $orange !important; + color: $orange; background: rgba(0,0,0,0.5); margin: 0 0 5px 0; } @@ -153,7 +157,7 @@ select { background-color: #333; padding: 5px; border: none; - color: $orange !important; + color: $orange; } pre { diff --git a/app/assets/stylesheets/patch b/app/assets/stylesheets/patch new file mode 100644 index 0000000..0997417 --- /dev/null +++ b/app/assets/stylesheets/patch @@ -0,0 +1,54 @@ +commit 10f01633176ca214e7aec6be61ed3344035ec77e +Merge: 99dff7e 20f7b74 +Author: webb39 <webb39@purdue.edu> +Date: Mon Mar 10 20:41:27 2014 -0400 + + Merge branch 'master' of https://github.com/LukeShu/Leaguer + +commit 99dff7e01a65986338824804651367e97a0d1923 +Merge: 1f00553 f0c03cd +Author: webb39 <webb39@purdue.edu> +Date: Mon Mar 10 20:41:16 2014 -0400 + + Merge https://github.com/LukeShu/Leaguer + + Conflicts: + doc/Sprint1-Retrospective.md + +commit 1f00553cbc5d281efe3ac1b434d16537a17bc969 +Author: webb39 <webb39@purdue.edu> +Date: Mon Mar 10 20:36:31 2014 -0400 + + added match controller information + +diff --git a/doc/Sprint1-Retrospective.md b/doc/Sprint1-Retrospective.md +index 3da3669..ae1b07a 100644 +--- a/doc/Sprint1-Retrospective.md ++++ b/doc/Sprint1-Retrospective.md +@@ -97,13 +97,24 @@ f + f + + ## Login (UI) {#login-ui} +- ++ + ## Tournament settings {#tourney-settings} +- ++ + ## Tournament registration {#tourney-registration} + + ## Match controller {#match-controller} + ++The Match Controller creates the separate matches for a specific tournament. ++When a tournament is started, it begins with an initial match that contains ++no players. Currently, a player must join a match by entering the specific ++tournament (by clicking the 'show' button on the tournament), ++then they must enter the match (again by clicking the 'show' button but this ++time on the match they desire to participate in) and then finally clicking ++the 'join' button. This updates the match with the user as a participant in ++the matc and then finally clicking the 'join' button. This updates the match ++with the user as a participant in the match. A match can also be destroyed ++by clicking the 'delete' button on the no longer desired match on the page. ++ + ## Permissions system {#permissions} + + ## Tournament view {#tourney-view} diff --git a/app/assets/stylesheets/servers.css.scss b/app/assets/stylesheets/servers.css.scss index bb20956..e69de29 100644 --- a/app/assets/stylesheets/servers.css.scss +++ b/app/assets/stylesheets/servers.css.scss @@ -1,5 +0,0 @@ -.edit_server { - li { - list-style: none; - } -} diff --git a/app/assets/stylesheets/users.css.scss b/app/assets/stylesheets/users.css.scss index 790aa5f..e69de29 100644 --- a/app/assets/stylesheets/users.css.scss +++ b/app/assets/stylesheets/users.css.scss @@ -1,5 +0,0 @@ -.new_user, .edit_user { - li { - list-style: none; - } -} diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index bed06ba..81ffcd8 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -44,19 +44,11 @@ class MatchesController < ApplicationController end when 2 # Started, waiting to finish - @match.handle_sampling(params) - if @match.finished? - @match.status = 3 - respond_to do |format| - if @match.save - format.html { redirect_to tournament_match_path(@tournament, @match), notice: 'Match has finished.' } - format.json { head :no_content } - else - format.html { render action: 'show' } - format.json { render json: @match.errors, status: :unprocessable_entity } - end - end - return + @match.handle_sampling(@current_user, params) + # The @match.status will be updated by Statistic's after_save hook + respond_to do |format| + format.html { redirect_to tournament_match_path(@tournament, @match), notice: 'Match has finished.' } + format.json { head :no_content } end when 3 if (@tournament.hosts.include? current_user) and (params[:update_action] == "start") @@ -77,8 +69,9 @@ class MatchesController < ApplicationController end return end + else + redirect_to tournament_match_path(@tournament, @match) end - redirect_to tournament_match_path(@tournament, @match) end private diff --git a/app/models/match.rb b/app/models/match.rb index 4c7acbf..219e662 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -5,9 +5,6 @@ class Match < ActiveRecord::Base belongs_to :winner, class_name: "Team" - def setup() - end - def finished? ok = true tournament_stage.scoring_method.stats_needed.each do |stat| @@ -59,7 +56,7 @@ class Match < ActiveRecord::Base method_class = "Sampling::#{method_name.camelcase}".constantize needed.each do |stat| data[stat] ||= {} - data[stat][method] = method_class.can_get?(user, stat) + data[stat][method_class] = method_class.can_get?(stat) end end @@ -83,7 +80,7 @@ class Match < ActiveRecord::Base if @method_classes.nil? data = Set.new figure_sampling_methods.each do |stat,method| - data.push(method) + data.add(method) end @method_classes = data end diff --git a/app/models/statistic.rb b/app/models/statistic.rb index 341fd9d..b4608b8 100644 --- a/app/models/statistic.rb +++ b/app/models/statistic.rb @@ -1,4 +1,27 @@ class Statistic < ActiveRecord::Base belongs_to :user belongs_to :match + + def value + begin + return JSON.parse(self.json_value) + rescue + return {} + end + end + + def value=(v) + self.json_value = v.to_json + end + + after_save :update_match + def update_match + if (self.name == "win") and (self.value > 0) + self.match.winner = self.match.teams.find{|t| t.users.include? self.user} + end + if (self.match.status == 2) and (self.match.finished?) + self.match.status = 3 + end + self.match.save + end end diff --git a/app/views/alerts/new.html.erb b/app/views/alerts/new.html.erb index 6d04589..db5af2d 100644 --- a/app/views/alerts/new.html.erb +++ b/app/views/alerts/new.html.erb @@ -2,4 +2,4 @@ <%= render 'form' %> -<%= link_to 'Back', alerts_path %> +<%= link_to 'See past Alerts', alerts_path %> diff --git a/app/views/pms/index.html.erb b/app/views/pms/index.html.erb index fec6db2..c823efb 100644 --- a/app/views/pms/index.html.erb +++ b/app/views/pms/index.html.erb @@ -97,14 +97,12 @@ <table> <col width="150"> - <col width="250"> - <col width="300"> + <col width="650"> <tbody> <%# if conversations.reject { |c| c.is_read?(current_user) || (c.receipts_for current_user).last.message.sender == current_user }.empty? %> <tr> <tr> <td><b>With</b></td> - <td><b>Subject</b></td> <td><b>Body</b></td> </tr> <% conversations.each do |conversation| %> @@ -112,7 +110,7 @@ <% if conversation.is_read?(current_user) || receipts.last.message.sender == current_user %> <% message = receipts.last.message %> <tr> - <% if conversation.subject == "Pay Attention!" %> + <% if conversation.subject == "Pay Attention!" && message.sender != current_user %> <td> <% people = conversation.participants %> <% people.each do |person| %> @@ -121,8 +119,7 @@ <% end %> <% end %> </td> - <td><%= truncate(conversation.subject, length: 30) %></td> - <td><%= truncate(message.body, length: 42) %></td> + <td><%= truncate(message.body, length: 80) %></td> <td><%= link_to 'View', @pms.find_by(conversation: conversation) %></td> <% end %> </tr> @@ -133,4 +130,8 @@ <% #end %> </tbody> -</table>
\ No newline at end of file +</table> + +<br> +<br> +<br>
\ No newline at end of file diff --git a/db/migrate/20140428092839_create_simple_captcha_data.rb b/db/migrate/20140428183808_create_simple_captcha_data.rb index 4573b20..4573b20 100644 --- a/db/migrate/20140428092839_create_simple_captcha_data.rb +++ b/db/migrate/20140428183808_create_simple_captcha_data.rb diff --git a/db/migrate/20140428132832_create_mailboxer.mailboxer_engine.rb b/db/migrate/20140428223805_create_mailboxer.mailboxer_engine.rb index 690cec2..690cec2 100644 --- a/db/migrate/20140428132832_create_mailboxer.mailboxer_engine.rb +++ b/db/migrate/20140428223805_create_mailboxer.mailboxer_engine.rb diff --git a/db/migrate/20140428132833_add_notified_object.mailboxer_engine.rb b/db/migrate/20140428223806_add_notified_object.mailboxer_engine.rb index 7f41ac6..7f41ac6 100644 --- a/db/migrate/20140428132833_add_notified_object.mailboxer_engine.rb +++ b/db/migrate/20140428223806_add_notified_object.mailboxer_engine.rb diff --git a/db/migrate/20140428132834_add_notification_code.mailboxer_engine.rb b/db/migrate/20140428223807_add_notification_code.mailboxer_engine.rb index 04c12ef..04c12ef 100644 --- a/db/migrate/20140428132834_add_notification_code.mailboxer_engine.rb +++ b/db/migrate/20140428223807_add_notification_code.mailboxer_engine.rb diff --git a/db/migrate/20140428132835_add_attachments.mailboxer_engine.rb b/db/migrate/20140428223808_add_attachments.mailboxer_engine.rb index b8d6588..b8d6588 100644 --- a/db/migrate/20140428132835_add_attachments.mailboxer_engine.rb +++ b/db/migrate/20140428223808_add_attachments.mailboxer_engine.rb diff --git a/db/migrate/20140428132836_rename_receipts_read.mailboxer_engine.rb b/db/migrate/20140428223809_rename_receipts_read.mailboxer_engine.rb index 9ce904f..9ce904f 100644 --- a/db/migrate/20140428132836_rename_receipts_read.mailboxer_engine.rb +++ b/db/migrate/20140428223809_rename_receipts_read.mailboxer_engine.rb diff --git a/db/migrate/20140428132837_add_global_notification_support.mailboxer_engine.rb b/db/migrate/20140428223810_add_global_notification_support.mailboxer_engine.rb index 60f67ab..60f67ab 100644 --- a/db/migrate/20140428132837_add_global_notification_support.mailboxer_engine.rb +++ b/db/migrate/20140428223810_add_global_notification_support.mailboxer_engine.rb diff --git a/db/migrate/20140428132845_create_delayed_jobs.rb b/db/migrate/20140428223812_create_delayed_jobs.rb index ec0dd93..ec0dd93 100644 --- a/db/migrate/20140428132845_create_delayed_jobs.rb +++ b/db/migrate/20140428223812_create_delayed_jobs.rb diff --git a/db/migrate/20140428132852_create_servers.rb b/db/migrate/20140428223815_create_servers.rb index fbe1b02..fbe1b02 100644 --- a/db/migrate/20140428132852_create_servers.rb +++ b/db/migrate/20140428223815_create_servers.rb diff --git a/db/migrate/20140428132900_create_matches.rb b/db/migrate/20140428223819_create_matches.rb index bac92d1..bac92d1 100644 --- a/db/migrate/20140428132900_create_matches.rb +++ b/db/migrate/20140428223819_create_matches.rb diff --git a/db/migrate/20140428132907_create_teams.rb b/db/migrate/20140428223823_create_teams.rb index dd8397d..dd8397d 100644 --- a/db/migrate/20140428132907_create_teams.rb +++ b/db/migrate/20140428223823_create_teams.rb diff --git a/db/migrate/20140428132914_create_alerts.rb b/db/migrate/20140428223827_create_alerts.rb index 68a8e10..68a8e10 100644 --- a/db/migrate/20140428132914_create_alerts.rb +++ b/db/migrate/20140428223827_create_alerts.rb diff --git a/db/migrate/20140428132922_create_pms.rb b/db/migrate/20140428223830_create_pms.rb index eb9f443..eb9f443 100644 --- a/db/migrate/20140428132922_create_pms.rb +++ b/db/migrate/20140428223830_create_pms.rb diff --git a/db/migrate/20140428132929_create_tournaments.rb b/db/migrate/20140428223834_create_tournaments.rb index f3715bb..f3715bb 100644 --- a/db/migrate/20140428132929_create_tournaments.rb +++ b/db/migrate/20140428223834_create_tournaments.rb diff --git a/db/migrate/20140428132937_create_games.rb b/db/migrate/20140428223838_create_games.rb index e841667..e841667 100644 --- a/db/migrate/20140428132937_create_games.rb +++ b/db/migrate/20140428223838_create_games.rb diff --git a/db/migrate/20140428132944_create_users.rb b/db/migrate/20140428223842_create_users.rb index 8032870..8032870 100644 --- a/db/migrate/20140428132944_create_users.rb +++ b/db/migrate/20140428223842_create_users.rb diff --git a/db/migrate/20140428132951_create_sessions.rb b/db/migrate/20140428223845_create_sessions.rb index f667f1e..f667f1e 100644 --- a/db/migrate/20140428132951_create_sessions.rb +++ b/db/migrate/20140428223845_create_sessions.rb diff --git a/db/migrate/20140428132958_create_brackets.rb b/db/migrate/20140428223849_create_brackets.rb index 8813bf2..8813bf2 100644 --- a/db/migrate/20140428132958_create_brackets.rb +++ b/db/migrate/20140428223849_create_brackets.rb diff --git a/db/migrate/20140428133006_create_game_settings.rb b/db/migrate/20140428223853_create_game_settings.rb index 06fb72e..06fb72e 100644 --- a/db/migrate/20140428133006_create_game_settings.rb +++ b/db/migrate/20140428223853_create_game_settings.rb diff --git a/db/migrate/20140428133013_create_tournament_settings.rb b/db/migrate/20140428223856_create_tournament_settings.rb index e56697f..e56697f 100644 --- a/db/migrate/20140428133013_create_tournament_settings.rb +++ b/db/migrate/20140428223856_create_tournament_settings.rb diff --git a/db/migrate/20140428133020_create_tournament_stages.rb b/db/migrate/20140428223900_create_tournament_stages.rb index 6e52bf0..6e52bf0 100644 --- a/db/migrate/20140428133020_create_tournament_stages.rb +++ b/db/migrate/20140428223900_create_tournament_stages.rb diff --git a/db/migrate/20140428133026_create_statistics.rb b/db/migrate/20140428223903_create_statistics.rb index cc2e97d..09a435f 100644 --- a/db/migrate/20140428133026_create_statistics.rb +++ b/db/migrate/20140428223903_create_statistics.rb @@ -4,7 +4,7 @@ class CreateStatistics < ActiveRecord::Migration t.references :user, index: true t.references :match, index: true t.string :name - t.integer :value + t.text :json_value t.timestamps end diff --git a/db/migrate/20140428133033_create_remote_usernames.rb b/db/migrate/20140428223907_create_remote_usernames.rb index e265985..e265985 100644 --- a/db/migrate/20140428133033_create_remote_usernames.rb +++ b/db/migrate/20140428223907_create_remote_usernames.rb diff --git a/db/migrate/20140428133041_create_bracket_matches.rb b/db/migrate/20140428223911_create_bracket_matches.rb index 3323e31..3323e31 100644 --- a/db/migrate/20140428133041_create_bracket_matches.rb +++ b/db/migrate/20140428223911_create_bracket_matches.rb diff --git a/db/migrate/20140428133048_create_api_requests.rb b/db/migrate/20140428223914_create_api_requests.rb index 544c330..544c330 100644 --- a/db/migrate/20140428133048_create_api_requests.rb +++ b/db/migrate/20140428223914_create_api_requests.rb diff --git a/db/migrate/20140428133055_create_tournament_players_join_table.rb b/db/migrate/20140428223918_create_tournament_players_join_table.rb index be240e8..be240e8 100644 --- a/db/migrate/20140428133055_create_tournament_players_join_table.rb +++ b/db/migrate/20140428223918_create_tournament_players_join_table.rb diff --git a/db/migrate/20140428133102_create_tournament_hosts_join_table.rb b/db/migrate/20140428223922_create_tournament_hosts_join_table.rb index 7521d89..7521d89 100644 --- a/db/migrate/20140428133102_create_tournament_hosts_join_table.rb +++ b/db/migrate/20140428223922_create_tournament_hosts_join_table.rb diff --git a/db/migrate/20140428133109_create_team_user_join_table.rb b/db/migrate/20140428223925_create_team_user_join_table.rb index f3b57fc..f3b57fc 100644 --- a/db/migrate/20140428133109_create_team_user_join_table.rb +++ b/db/migrate/20140428223925_create_team_user_join_table.rb diff --git a/db/migrate/20140428133116_create_match_team_join_table.rb b/db/migrate/20140428223929_create_match_team_join_table.rb index c2ed1b7..c2ed1b7 100644 --- a/db/migrate/20140428133116_create_match_team_join_table.rb +++ b/db/migrate/20140428223929_create_match_team_join_table.rb diff --git a/db/migrate/20140428133136_add_hidden_attrs_to_user.rb b/db/migrate/20140428223939_add_hidden_attrs_to_user.rb index 9b5c505..9b5c505 100644 --- a/db/migrate/20140428133136_add_hidden_attrs_to_user.rb +++ b/db/migrate/20140428223939_add_hidden_attrs_to_user.rb diff --git a/db/schema.rb b/db/schema.rb index a7910eb..c5032fa 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140428133136) do +ActiveRecord::Schema.define(version: 20140428223939) do create_table "alerts", force: true do |t| t.integer "author_id" @@ -218,7 +218,7 @@ ActiveRecord::Schema.define(version: 20140428133136) do t.integer "user_id" t.integer "match_id" t.string "name" - t.integer "value" + t.text "json_value" t.datetime "created_at" t.datetime "updated_at" end diff --git a/db/seeds.rb b/db/seeds.rb index f9d32ac..50ee7db 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -54,25 +54,38 @@ if Rails.env.development? players_for_league.push(User.create(name: "Kaceytron" , password: "password", email: "Kaceytron@gmail.com" , user_name: "Kaceytron" , password_confirmation: "password")) # Semi-real users - davis = User.create(name: "Davis Webb" , password: "password", email: "davislwebb@gmail.com" , user_name: "TeslasMind" , password_confirmation: "password") - foy = User.create(name: "Nathaniel Foy" , password: "password", email: "nfoy@notreal.com" , user_name: "Nalfeinx" , password_confirmation: "password") guntas = User.create(name: "Guntas Grewal" , password: "password", email: "guntasgrewal@gmail.com" , user_name: "guntasgrewal", password_confirmation: "password") luke = User.create(name: "Luke Shumaker" , password: "password", email: "lukeshu@emacs4lyfe.com" , user_name: "lukeshu" , password_confirmation: "password") tomer = User.create(name: "Tomer Kimia" , password: "password", email: "tomer@2majors4lyfe.com" , user_name: "tkimia" , password_confirmation: "password") - andrew = User.create(name: "Andrew Murrell" , password: "password", email: "murrel@murrel.gov" , user_name: "ImFromNasa" , password_confirmation: "password") - joey = User.create(name: "Joseph Adams" , password: "password", email: "alpha142@fluttershyop.com" , user_name: "alpha142" , password_confirmation: "password") josh = User.create(name: "Josh Huser" , password: "password", email: "jhuser@iownabusiness.net" , user_name: "WinterWorks" , password_confirmation: "password") dunsmore = User.create(name: "Professor Dunsmore", password: "password", email: "bxd@purdue.edu" , user_name: "Dumbledore" , password_confirmation: "password") marco = User.create(name: "Marco Polo" , password: "password", email: "marco@ta4lyfe.com" , user_name: "iCoordinate" , password_confirmation: "password") jordan = User.create(name: "Geoffrey Webb" , password: "password", email: "imnotjoffreybarathian@gameofthrones.com", user_name: "GTBPhoenix" , password_confirmation: "password") obama = User.create(name: "Obama" , password: "password", email: "obama@whitehouse.gov" , user_name: "Obama" , password_confirmation: "password") + g = Array.new + + davis = User.create(name: "Davis Webb" , password: "password", email: "davislwebb@gmail.com" , user_name: "TeslasMind" , password_confirmation: "password") + foy = User.create(name: "Nathaniel Foy" , password: "password", email: "nfoy@purdue.edu" , user_name: "NalfeinX" , password_confirmation: "password") + andrew = User.create(name: "Andrew Murrell" , password: "password", email: "murrel@murrel.gov" , user_name: "ImFromNasa" , password_confirmation: "password") + joey = User.create(name: "Joseph Adams" , password: "password", email: "alpha142@fluttershyop.com" , user_name: "alpha142" , password_confirmation: "password") + panda = User.create(name: "Panda" , password: "password", email: "panda@gmail.com" , user_name: "InspectorPanderp" , password_confirmation: "password") + mesa = User.create(name: "Mesataki" , password: "password", email: "mesataki@gmail.com" , user_name: "Mesataki" , password_confirmation: "password") + guntas_league = User.create(name: "TolkiensButt" , password: "password", email: "TolkiensButt@gmail.com" , user_name: "TolkiensButt" , password_confirmation: "password") + lyra = User.create(name: "Lyra Heartstings" , password: "password", email: "LyraHeartstings@gmail.com" , user_name: "Lyra Heartstings" , password_confirmation: "password") + josh_league = User.create(name: "Josh_league" , password: "password", email: "josh_league@gmail.com" , user_name: "Joshoowah" , password_confirmation: "password") + jeff = User.create(name: "Jeff Linguinee" , password: "password", email: "jefflingueeneeeee@gmail.com" , user_name: "SenorJeffafa" , password_confirmation: "password") + sarah = User.create(name: "Sarah Lawson" , password: "password", email: "sarah@gmail.com" , user_name: "LittlexSurah" , password_confirmation: "password") + + # League of Legends tournament league_tourn = Tournament.create(game: league, name: "League of Legends Seed", min_players_per_team: 5, max_players_per_team: 5, min_teams_per_match: 2, max_teams_per_match: 2, - scoring_method: "TODO") - # TODO: create stages + scoring_method: "winner_takes_all") + + league_tourn.stages.create(scheduling_method: "round_robin" , seeding_method: "random_seeding") + league_tourn.hosts.push(User.find(1)) players_for_league.each do |player| league_tourn.join(player) @@ -82,8 +95,10 @@ if Rails.env.development? chess_tourn = Tournament.create(game: chess, name: "Chess Seed", min_players_per_team: 1, max_players_per_team: 1, min_teams_per_match: 2, max_teams_per_match: 2, - scoring_method: "TODO") - # TODO: create stages + scoring_method: "winner_takes_all") + + chess_tourn.stages.create(scheduling_method: "round_robin" , seeding_method: "random_seeding") + chess_tourn.hosts.push(davis) chess_tourn.join(davis) chess_tourn.join(foy) @@ -92,8 +107,8 @@ if Rails.env.development? rps = Tournament.create(game: rockpaperscissors, name: "Rock, Paper, Scissors Seed", min_players_per_team: 1, max_players_per_team: 3, min_teams_per_match: 2, max_teams_per_match: 2, - scoring_method: "TODO") - rps.stages.create(scheduling_method: "elimination" , seeding_method: "random_seeding") + scoring_method: "winner_takes_all") + rps.stages.create(scheduling_method: "round_robin" , seeding_method: "random_seeding") rps.hosts.push(davis) rps.join(davis) rps.join(foy) @@ -103,20 +118,21 @@ if Rails.env.development? tourn5 = Tournament.create(game: league, name: "5 Teams, 2 Teams Per Match", min_players_per_team: 1, max_players_per_team: 1, min_teams_per_match: 2, max_teams_per_match: 2, - scoring_method: "TODO") + scoring_method: "winner_takes_all") tourn5.hosts.push(User.find(1)) players_for_league.each do |player| tourn5.join(player) end - tourn5.stages.create(scheduling_method: "elimination" , seeding_method: "random_seeding") + tourn5.stages.create(scheduling_method: "round_robin" , seeding_method: "random_seeding") # Yet another League tournament tourn6 = Tournament.create(game_id: 1, name: "3 teams per match", min_players_per_team: 1, max_players_per_team: 1, min_teams_per_match: 3, max_teams_per_match: 3, - scoring_method: "TODO") + scoring_method: "winner_takes_all") + tourn6.hosts.push(User.find(1)) - tourn6.stages.create(scheduling_method: "elimination" , seeding_method: "random_seeding") + tourn6.stages.create(scheduling_method: "round_robin" , seeding_method: "random_seeding") players_for_league.each do |player| tourn6.join(player) end @@ -128,4 +144,44 @@ if Rails.env.development? tourn6.join(jordan) tourn6.join(obama) tourn6.join(joey) + + #Hearthstone tournament + hearth = Tournament.create(game: hearthstone, name: "Hearthstone Seed", min_teams_per_match: 1, min_players_per_team: 1, + max_teams_per_match: 2, max_players_per_team: 1, scoring_method: "winner_takes_all") + + hearth.join(davis) + hearth.join(foy) + + hearth.stages.create(scheduling_method: "round_robin" , seeding_method: "random_seeding") + + #THE REAL GAME WE ARE PLAYING AT 10 + davis.remote_usernames.create(game: league, value: {"name" => "TeslasMind", "id" => 30533514} ) + foy.remote_usernames.create(game: league, value: {"name" => "NalfeinX", "id" => 29538130} ) + andrew.remote_usernames.create(game: league, value: {"name" => "ImFromNasa", "id" => 29782091} ) + joey.remote_usernames.create(game: league, value: {"name" => "Alpha142", "id" => 29732514} ) + sarah.remote_usernames.create(game: league, value: {"name" => "LittlexSurah", "id" => 30613787} ) + mesa.remote_usernames.create(game: league, value: {"name" => "Mesataki", "id" => 37259275} ) + panda.remote_usernames.create(game: league, value: {"name" => "NalfeinX", "id" => 47953989} ) + jordan.remote_usernames.create(game: league, value: {"name" => "GTBPhoenix", "id" => 29812020} ) + josh_league.remote_usernames.create(game: league, value: {"name" => "Joshoowah", "id" => 26083333} ) + jeff.remote_usernames.create(game: league, value: {"name" => "SenorJeffafa", "id" => 32612067} ) + lyra.remote_usernames.create(game: league, value: {"name" => "Lyra Heartstings", "id" => 32240762} ) + + g.push(davis, foy, andrew, joey, panda, mesa, jordan, jeff, sarah, josh_league) + #g.push(davis, foy, andrew, joey, panda, mesa, jordan, jeff, sarah, guntas_league) + + custom = Tournament.create(game: league, name: "Real League Game", + min_players_per_team: 5, max_players_per_team: 5, + min_teams_per_match: 2, max_teams_per_match: 2, + scoring_method: "winner_takes_all") + + custom.stages.create(scheduling_method: "round_robin" , seeding_method: "random_seeding") + + + custom.hosts.push(User.find(1)) + g.each do |player| + custom.join(player) + end + end + diff --git a/generate.sh b/generate.sh index 6a6c502..ffcde4b 100755 --- a/generate.sh +++ b/generate.sh @@ -55,7 +55,7 @@ bundle exec rails generate model game_setting game:references name:s bundle exec rails generate model tournament_setting tournament:references name:string vartype:integer type_opt:text description:text display_order:integer value:text bundle exec rails generate model tournament_stage tournament:references structure:text scheduling_method:string seeding_method:string -bundle exec rails generate model statistic user:references match:references name:string value:integer +bundle exec rails generate model statistic user:references match:references name:string json_value:text bundle exec rails generate model remote_username game:references user:references json_value:text diff --git a/lib/sampling/manual.html.erb b/lib/sampling/manual.html.erb index cf873b4..b783506 100644 --- a/lib/sampling/manual.html.erb +++ b/lib/sampling/manual.html.erb @@ -1 +1,13 @@ -<!-- TODO --> +<% if @tournament.hosts.include? @current_user %> + <input type="hidden" name="update_action" value="finish" > + <% @match.teams.each do |team| %> + <label> + <input type="radio", name="winner", value="<%= team.id %>" > + <%= "Team #{team.id} Won" %> + </label> + <% end %> + <br> + <input type="submit", value="Finish match" > +<% else %> + <p>The match is running; the host has yet to post the scores of the match.</p> +<% end %> diff --git a/lib/sampling/manual.rb b/lib/sampling/manual.rb index a190bd2..4e86925 100644 --- a/lib/sampling/manual.rb +++ b/lib/sampling/manual.rb @@ -4,7 +4,7 @@ module Sampling return true end - def can_get?(setting_name) + def self.can_get?(setting_name) return 1 end @@ -31,15 +31,16 @@ module Sampling end def render_user_interaction(user) + @tournament = @match.tournament_stage.tournament @current_user = user @users = @match.users @stats = @match.stats_from(self.class) require 'erb' - erb_filename = File.join(__FILE__.sub(/\.rb$/, '.svg.erb')) + erb_filename = File.join(__FILE__.sub(/\.rb$/, '.html.erb')) erb = ERB.new(File.read(erb_filename)) erb.filename = erb_filename - return erb.result.html_safe + return erb.result(binding).html_safe end def handle_user_interaction(user, sampling_params) diff --git a/lib/sampling/peer_review.html.erb b/lib/sampling/peer_review.html.erb index e744936..a0b9c4d 100644 --- a/lib/sampling/peer_review.html.erb +++ b/lib/sampling/peer_review.html.erb @@ -18,7 +18,7 @@ <%# TODO: display more statistics %> </li><% end %> </ol> - <%= submit_tag("Submit peer evaluation", :onsubmit => "score_peers()") %> + <input type="submit" value="Submit peer evaluation", onsubmit="score_peers()") > <% else %> <p>Still waiting for peer feedback from the following users: <ul><% @feedbacks_missing.each do |user| %> diff --git a/lib/sampling/peer_review.rb b/lib/sampling/peer_review.rb index 4577542..1aabe34 100644 --- a/lib/sampling/peer_review.rb +++ b/lib/sampling/peer_review.rb @@ -5,7 +5,7 @@ module Sampling end def self.can_get?(setting_name) - return setting_name.start_with?("feedback_from_") + return setting_name.start_with?("feedback_from_") ? 2 : 0 end def self.uses_remote? @@ -36,10 +36,10 @@ module Sampling @feedbacks_missing = get_feedbacks_missing(match) require 'erb' - erb_filename = File.join(__FILE__.sub(/\.rb$/, '.svg.erb')) + erb_filename = File.join(__FILE__.sub(/\.rb$/, '.html.erb')) erb = ERB.new(File.read(erb_filename)) erb.filename = erb_filename - return erb.result.html_safe + return erb.result(binding).html_safe end def handle_user_interaction(reviewing_user, params) @@ -74,14 +74,14 @@ module Sampling def self.get_feedbacks_missing(match) require 'set' - ret = Set.new() + ret = Set.new feedback = get_feedbacks(match) users = get_users(match) feedback.each do |feedback| (users - feedback.keys).each do |user| - ret.push(user) + ret.add(user) end end diff --git a/lib/scoring/winner_takes_all.rb b/lib/scoring/winner_takes_all.rb index bf95781..57ddae6 100644 --- a/lib/scoring/winner_takes_all.rb +++ b/lib/scoring/winner_takes_all.rb @@ -1,13 +1,13 @@ module Scoring module WinnerTakesAll def self.stats_needed - return [] + return ["win"] end def self.score(match, interface) scores = {} match.players.each do |player| - scores[player.user_name] = score_user(match.win?(player)) + scores[player.user_name] = score_user(player.statistics.where(:match => match, :name => "win").value) end scores end diff --git a/test/fixtures/statistics.yml b/test/fixtures/statistics.yml index 0b5b113..e6bbccf 100644 --- a/test/fixtures/statistics.yml +++ b/test/fixtures/statistics.yml @@ -4,10 +4,10 @@ one: user_id: match_id: name: MyString - value: 1 + json_value: MyText two: user_id: match_id: name: MyString - value: 1 + json_value: MyText |