diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/matches_controller.rb | 30 | ||||
-rw-r--r-- | app/views/matches/index.html.erb | 3 | ||||
-rw-r--r-- | app/views/matches/show.html.erb | 17 | ||||
-rw-r--r-- | app/views/users/show.html.erb | 36 |
4 files changed, 72 insertions, 14 deletions
diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index 7d6bf43..9e376f7 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -144,11 +144,12 @@ class MatchesController < ApplicationController handle_asynchronously :is_match_over def show - 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 @@ -200,7 +201,24 @@ class MatchesController < ApplicationController end end when "peer" - @match.status = 3; + 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.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: 'Scores Submitted' } diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb index 6c93321..15b59f4 100644 --- a/app/views/matches/index.html.erb +++ b/app/views/matches/index.html.erb @@ -36,7 +36,8 @@ <SVG version="1.1" baseProfile="full" width="100%" height="<%= @height = [@height, 500].max %>" - xmlns="http://www.w3.org/2000/svg"> + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink"> <% lastrx = 0 lastry = 0 lastrh = 0 diff --git a/app/views/matches/show.html.erb b/app/views/matches/show.html.erb index a832d17..c92aea3 100644 --- a/app/views/matches/show.html.erb +++ b/app/views/matches/show.html.erb @@ -81,6 +81,7 @@ <% when 2 %> <!-- Finished, waiting for peer reviews --> <input type="hidden" name="update_action" value="peer"> + <input type="hidden" name="review_action" value=""> <% users = []; @match.teams.each{|t| users.concat(t.users)}; %> <% if users.include? current_user %> <% @match.teams.each do |team| %> @@ -101,7 +102,7 @@ </ol> <% end %> <% end %> - <%= submit_tag("Submit peer evaluation") %> + <%= submit_tag("Submit peer evaluation", :onsubmit => "score_peers()") %> <% else %> Waiting for peer evaluations to be submitted. <% end %> @@ -113,3 +114,17 @@ <% end # case %> <% end # form %> </div> + +<script type="text/javascript"> +function score_peers() { + //get each player in order and assign score here! + var $lisp = $('ol#boxes'); + var comma = "," + for(var i=0; i < $lisp.length; i++) { + if ( i == lisp.length-1) { + comma = ""; + } + $('review_action').value += $('ol#boxes:eq(' + i + ')').text() + comma; + } +} +</script> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 7bda009..c2b5c75 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -1,10 +1,8 @@ -<p> - <%= image_tag 'http://www.gravatar.com/avatar/' + Digest::MD5.hexdigest(@user.email) + '?s=100&d=mm' %> -</p> + +<h1> <%= @user.user_name %>'s Profile </h1> <p> - <strong>Name:</strong> - <%= @user.name %> + <%= image_tag 'http://www.gravatar.com/avatar/' + Digest::MD5.hexdigest(@user.email) + '?s=100&d=mm' %> </p> <p> @@ -13,9 +11,35 @@ </p> <p> - <strong>User name:</strong> + <strong>Preferred name:</strong> <%= @user.user_name %> </p> +<p> + <strong>Relationship Status:</strong> + too single +</p> + +<div class="row"> + <div class="col-md-6"> + <h3> Recent Tournaments Players </h3> + <ul> + <% @user.tournaments_played.each do |t| %> + <li><%= t.name %></li> + <% end %> + </ul> + </div> + <div class="col-md-6"> + <h3> Recent Tournaments Hosted </h3> + <% if @user.tournaments_hosted.count == 0 %> <p> <%= @user.user_name %> has never hosted a tournament </p> <%end %> + <ul> + <% @user.tournaments_hosted.each do |t| %> + <li><%= t.name %></li> + <% end %> + </ul> + </div> + </div> +</div> + <%= link_to 'Edit', edit_user_path(@user) %> | <%= link_to 'Users', users_path %> |