Javascript and markup for publishing open-ended "How many of X can you name?"-style quizzes. Example.
- Check out the repo.
- Put the
www
directory somewhere on your web path. - Test your changes with the
_blank/index.php
file.
- Copy the
_blank
directory into a new directory, named after your quiz. - Edit your new index.php file.
- Edit the title element.
- Edit the canonical meta element.
- Edit the
<h2>
. - Edit the
<input id="answer_key" type="hidden"
and add your answers. - If you need more than two minutes, edit the values of the
<input id="time_limit" type="hidden" value="2" />
and the<input id="timer" type="text" readonly="true" value="2:00" name="timer" />
elements. - Edit the
var quiz_config = {
object.- Add the quiz title and slug.
- If your quiz doesn't have photos, change the has_photos property value to 0.
- Add the quiz to the database.
- Copy the SQL from www/sql/insert.sql,
INSERT INTO howmany (slug, max, create_date) VALUES ('fast-and-furious', 8, NOW());
- Replace the "fast-and-furious" value with whatever your quiz slug is.
- Log in to your database server and execute that query.
- If you run into trouble and need to edit your entry, you can edit the database record with a query along the lines of
UPDATE howmany SET slug='new-slug-name' WHERE quiz_id=9 LIMIT 1;
. - If you want to delete your record and start over, do that with
DELETE FROM howmany WHERE quiz_id=[ID-OF-YOUR-ERRANT-QUIZ] LIMIT 1;
- If you run into trouble and need to edit your entry, you can edit the database record with a query along the lines of
- Copy the SQL from www/sql/insert.sql,
- If the quiz is not in repo, download the latest version of the quiz from the server.
- If you're deploying via scp, that command may look something like
cd path-to-www; scp -r prod:/apps/quiz/specific-quiz ./
- If you're deploying via scp, that command may look something like
- Edit
index.php
in your text editor, go down to around line 48. You'll want to edit the line below the line that hasEDIT: Put the answers here
on it. - In the line below, add your answers to the value attribute of the answer_key input (
<input id="answer_key" type="hidden" value="...
). - If this is a photo quiz, add the photo(s) to the img directory.
- Update the
max
value for that particular quiz in the database.- SSH into the server.
- Log in to the database.
- Find the
quiz_id
for the quiz you're editing. You can see a list of all the quizzes and the quiz_id's withSELECT * FROM howmany;
- Update the max field value with a query such as
UPDATE howmany SET max = 183 WHERE quiz_id = 16;
, but replace the183
and the16
with your particular values.
- Re-deploy.
Dwight Gooden also goes by Doc Gooden and we wanted people to be able to type in either Dwight or Doc Gooden and still have it count as a correct answer. Because of this, a lot of javascript was written. You can see most of it by searching for "SPLIT ANSWER" in the js.
Design by Jeffrey Mariano, New York Daily News. Markup, CSS, most of the javascript by Joe Murphy, New York Daily News / Denver Post.