diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/matches_controller.rb | 14 | ||||
-rw-r--r-- | app/views/matches/show.html.erb | 19 |
2 files changed, 31 insertions, 2 deletions
diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index 93b5514..97b8b83 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -193,6 +193,20 @@ class MatchesController < ApplicationController end end when "finish" + 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.status = 3 respond_to do |format| if @match.save diff --git a/app/views/matches/show.html.erb b/app/views/matches/show.html.erb index cd30926..a0540f9 100644 --- a/app/views/matches/show.html.erb +++ b/app/views/matches/show.html.erb @@ -117,7 +117,7 @@ <% if @tournament.players.include?(current_user) %> <br /> <div id="host"> - <%= form_tag(tournament_match_path(@tournament, @match), method: "put") do %> + <%= form_tag(tournament_match_path(@tournament, @match), method: "put", name: "peeris") do %> <% case @match.status %> <% when 0 %> <input type="hidden" name="update_action" value="start"> @@ -126,8 +126,9 @@ <input type="hidden" name="update_action" value="peer"> <%= submit_tag("Begin Peer Evaluation") %> <% when 2 %> + <input type="hidden" name="review_action" value=""> <input type="hidden" name="update_action" value="finish"> - <%= submit_tag("End Match") %> + <%= submit_tag("End Peer Evaluation", :onsubmit => "score_peers()") %> <% when 3 %> <input type="hidden" name="update_action" value="reset"> <%= submit_tag("Reset Status") %> @@ -136,3 +137,17 @@ </div> <% end %> + +<script type="text/javascript"> + //get each player in order and assign score here! + var $lisp = $('ol li peeris'); + var comma = "," + for(var i=0; i < $lisp.length; i++) { + if ( i == lisp.length-1) { + comma = ""; + } + $('review_action').value += $('ol li peeris:eq(' + i + ')').text() + comma; + } +</script> + + |