With Annie’s family being so large, it would be somewhat outrageous for everyone to purchase gifts for everyone, so they’ve come up with a Secret Santa system that limits the number of gifts people need to give. Organizing this each year can be a little difficult. The number of people in the list changes, and it can take time for the organizer to collect all the names, and then randomly assign them to other people.
Last night, I got it in my mind that I could create a simple web application to do some of this and make it easier. The link is available on Facebook for those that know where to look. I am not going to post it publicly for fear of having it all messed up due to spam.
The first thing I did was come up with a simple bullet list of what I wanted the tool to do.
- Easily Add Names
- Randomly select someone other than the inputted name
- Update the database so that the same person can’t be chosen twice
I looked at some tutorials on sending data to a database, and showing the result without refreshing the page using jQuery. I created a database on the small hosting plan that I got from InMotion Hosting, and then started creating the application.
The database is simple. It just includes:
- ID – number that automatically increments
- Name – first name of person
- Taken – are they already taken or not? It is either 0 or 1
You’ll note that I don’t see who they are taken by, and I heavily debated if this was important or not. If everyone wants to use this, but they want me to keep a record of who has selected who, I could always update this and include another field that puts the name of who took each person in the database as well.
I added in some basic error handling and checking, as well as a simple system to check to see if your name is already on the list and return an appropriate message if that’s the case. If you are requesting a name, I made sure that you don’t get your own by comparing against what you enter in the submission box.
The last thing I added was a block on requesting Secret Santa names until there are at least twenty people in the database. This was just a random number limitation to make sure we had a good starting seed number. I also did this because the database is updated when someone requests a name, changing their taken status so they can’t be taken twice. I don’t want people to start getting taken until most of the family have been added to the database.
I am willing to make some simple updates and changes to the system I’ve built. One thing I want to do is to list who is currently in the database, so people will know upon arriving if their name is already in the pool or not.
I am willing to make other updates as needed. One cool thing about this is that it is easy for me to delete names, update statuses, and essentially reset for next year. Let me know what you think.
Update 1: I was able to list out who is already added into the system, and tie it into jQuery to update the list upon adding a name. I am pretty excited about how easy this all was.
Update 2: The family have asked for two other features: master list and re-roll. I am going to try to find time to work on both of these. The master list feature is the most requested one, so I’ll work on that first. Basically, they want me to track who got who, so that if they need a reminder later, I can give it to them.
As for the re-roll feature, this is so that people can request a different name if they got a person last year or if the person is their spouse or child (who they’ll be buying a gift for anyways, I assume). This feature adds complexity because it means I’d have to have a system of confirmation asking the user if they want to keep their choice, or at least a button to say “Lock in”. I think I can make this work, but I am not sure how yet…
Update 3: I got the master list working, at least to record which person has which person… I don’t know how to get the re-roll/lock-in working though. I could create a table to check for family relationships. It wouldn’t take long. I would have to manually create it though. It might be better to just keep doing it using paper, or text files or a spreadsheet at this point.
Update 4: I got the re-roll/lock-in working. I also added some bug fixes that people found in testing. I decided against creating a table for family relationships because it would require either too much work from users or too much manual management for me. I have had about a dozen people try it out, and so far no major hiccups. I have cleared the database, and starting tomorrow, October 21st, people will be able to select people for their Secret Santa this year!
Update 5: Annie’s nephew, Jn, came up with a brilliant idea to store everyone into various PHP arrays based on families. This made it easier to do the exclusionary on selections so that people don’t buy for those in their house. We are still working on Annie’s mom as she has two “families” that live with her and thus should be excluded from buying for her. His help has been super useful in making this system better, and he did all the manual heavy lifting for the exclusionary rules for the Secret Santa system.
3 responses to “Christmas Draw – Random Secret Santa Name Grabber”
I would like to try this but can’t find where it is or see it ?
I never posted it publicly. My coding is not worthy of being seen/shared. I am an amateur. Anyone with a half decent amount of coding knowledge could do better…