about summary refs log tree commit diff stats
path: root/app/controllers
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2023-11-04 10:02:01 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2023-11-04 10:02:01 -0400
commit1bc945a9874722d1e0d236265f607f6fa78f609d (patch)
treea172333b8cbd1398242a72e29a35902683e7fed4 /app/controllers
parentb0481b17cbb177d329c67cfe5abd5f76365ceefd (diff)
downloadwittle-1bc945a9874722d1e0d236265f607f6fa78f609d.tar.gz
wittle-1bc945a9874722d1e0d236265f607f6fa78f609d.tar.bz2
wittle-1bc945a9874722d1e0d236265f607f6fa78f609d.zip
show player's own solution on show page
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/wittle/puzzles_controller.rb11
1 files changed, 11 insertions, 0 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