Online Puzzle Challenges as Portfolio Piece

I’ve always enjoyed making and presenting puzzles to my friends and enemies. I couldn't resist setting something up for the larger public that was all my own to control. This article is about the tech stack behind them.

There are multiple challenges to presenting puzzles online. I’ll update and expand on these as I progress.

Consistent Presentation
Puzzles can have many different formats.
Hints
Accepting and Validating Answers
Database
Puzzles

Ha ha joke’s on you; There is no database of puzzles. Since each puzzle could be wildly different from the rest, I didn't want to fight trying to shove them into a database. Each puzzle is actually a class file. It might be a bit annoying on the data entry, but it means every puzzle can be as unique as I like.

Responses

Responses, however, are stored in a database. I want to track what gets entered so that I can watch for misinterpretations of the parameters of a puzzle.

Users/Players

Since I am presenting a leaderboard, and I want the players to compete, that means I have to keep track of a score of some kind. I can't do that without tying those points to a user record that is authenticateable. I didn't want to create yet another website for people to create a profile on, and I didn't want any private information recorded. My solution was to make system that relies on an email address. A user enters their email address, and the system sends a unique link to that email address. Nothing is recorded in the database yet. If the user clicks the link, it should mesh with a token in their session, and a userID is generated for the session which is a salted hash of the email address. We have authenticated the user, but we still haven't added a user record yet. If the user correctly answers a puzzle, the user record is finally created, and the player is offered the ability to give themselves a name to show in the leaderboard.

If the user clears their cookies or closes their browser, the session is lost. Clicking the link in the email does not work because the session token is no longer connected. However, If the user puts the same email address in the login box, the whole process starts again, and the hash of the email address matches a user record, which is loaded into session.

Leaderboard

I am looking forward to making multiple views of the leaderboards - to show up-and-comers, the current user's place, top ten, etc.

I’m implementing a system where scores fade over time. So someone who did many puzzles will get a high score and may be on top. But after a few months, their ranking will drop, and some one who has earned the same number of points will be on top.