about summary refs log tree commit diff stats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/wittle/puzzles_controller.rb11
-rw-r--r--app/views/wittle/puzzles/_handle_puzzle.html.erb2
2 files changed, 12 insertions, 1 deletions
diff --git a/app/controllers/wittle/puzzles_controller.rb b/app/controllers/wittle/puzzles_controller.rb index b481460..8dc2ac8 100644 --- a/app/controllers/wittle/puzzles_controller.rb +++ b/app/controllers/wittle/puzzles_controller.rb
@@ -22,6 +22,14 @@ module Wittle
22 @puzzle = Puzzle.find(params[:id]) 22 @puzzle = Puzzle.find(params[:id])
23 @playable = @puzzle.latest? && !((session[:played_puzzles] || []).include? @puzzle.id) 23 @playable = @puzzle.latest? && !((session[:played_puzzles] || []).include? @puzzle.id)
24 @already_started = ((session[:started_puzzles] || []).include? @puzzle.id) 24 @already_started = ((session[:started_puzzles] || []).include? @puzzle.id)
25
26 unless @playable
27 if (session[:puzzle_solutions] || {}).has_key? @puzzle.id.to_s
28 @solution = session[:puzzle_solutions][@puzzle.id.to_s]
29 else
30 @solution = @puzzle.solved_data
31 end
32 end
25 end 33 end
26 34
27 def start 35 def start
@@ -45,6 +53,9 @@ module Wittle
45 53
46 session[:played_puzzles] ||= [] 54 session[:played_puzzles] ||= []
47 session[:played_puzzles] << @puzzle.id 55 session[:played_puzzles] << @puzzle.id
56
57 session[:puzzle_solutions] ||= {}
58 session[:puzzle_solutions][@puzzle.id] = params[:solved]
48 end 59 end
49 60
50 def submit 61 def submit
diff --git a/app/views/wittle/puzzles/_handle_puzzle.html.erb b/app/views/wittle/puzzles/_handle_puzzle.html.erb index 81bca29..e451745 100644 --- a/app/views/wittle/puzzles/_handle_puzzle.html.erb +++ b/app/views/wittle/puzzles/_handle_puzzle.html.erb
@@ -51,7 +51,7 @@ window.onload = function() {
51 <% else %> 51 <% else %>
52 var puzzle = window.deserializePuzzle("<%= @puzzle.data %>") 52 var puzzle = window.deserializePuzzle("<%= @puzzle.data %>")
53 draw(puzzle) 53 draw(puzzle)
54 drawPath(puzzle, JSON.parse("<%= escape_javascript(sanitize @puzzle.solved_data) %>")) 54 drawPath(puzzle, JSON.parse("<%= escape_javascript(sanitize @solution) %>"))
55 window.trace = function() {} 55 window.trace = function() {}
56 <% end %> 56 <% end %>
57} 57}