My boss has it in his head to have a high-tech Secret Santa utility on our IIS run intranet webpage.
The idea would be to compile a list of all the people in the office (who are going to play) and then have a webpage which hands out the names.
Of course the names can’t be handed out twice.
The added catch is I can’t spend forever working on this.
I figured I could use a text document with all the names listed in each line. The script would display a name each time the page is hit. It would cycle through all the names until there were no more.
The boss could email the URL of the website and people would open it to see who got what name.
I’m not well versed in asp programming so I’m not really sure where to start with this. It sounds simple though.
Does anyone have a bit of code sitting around that would handle this?
The code is easy, however, I see a couple of potential issues:
What happens if someone accidently double-clicks the webpage? They won’t even know they were given two names, they would just see the last. A quick way I see around this is: does everyone in your office have a unique NT login? (I am assuming Windows network since you are considering ASP) Hopefully you have access to those names. Often they are the same as the first part of their email address unless your network administrators are really sophisticated.
Also, it will only work until the server (or IIS) is restarted. After that it will start over from the first person unless you have a plan for storing the names given out. Are you able to access IIS and turn on write permission to the directory?
I don’t have the code to handle this. But there are some things you need to consider.
First, you can’t just display a new name each time the page is hit. What if I hit the page a seond time? Would I have to buy two people presents? The program would have to know who is logging on.
Second, Each employee would have to identify themself with a secret code or password. Otherwise I could just identify myself as each person in turn to find out who drew my name.
Finally, you need to make sure no person draws his own name.
I did this before, although with a java app. And there was no web front end. I’d just assemble the names and email addresses, run the program and it would mail the participants their assignments.
Just one other thing, out of interest. I initially implemented the algorithm as a model of the real world, pick the name out of the hat. However, there is an issue with this system. If a person picks his own name, he throws back and picks another, but if the person is the last to pick and picks his own name… ? gotta start again.
So, I changed things around. I arranged the participants at random in a ring, then moved the ring a random number of spaces around. No deadlock issues. Obviously, this doesn’t work so well in the real world, since everybody would know who everybody else got.
Right, this is the same as arranging them in a random ring, and then assigning each person to the person on their left. Of course, you left out a lot of the possibilities. There could be several disconnected rings if you drew from a hat. But that’s fine for Secret Santa.
How about this: after you’ve assigned everyone to the person on their left, go through for each person and switch their assignment with a random person’s. If that would make one of them assigned to himself, leave their assignments as is and go to the next person.