Yeah, at the moment the scale quiz script works by putting the number of points the answer is worth in the value attribute of the option, so although you could technically make a multiple-choice trivia quiz with it, it's not built to be able to write in your own answers.
For the modification, you would want to define the correct answers in an object like
var correct_answers = {
"q1": "pikachu",
"q2": …
};
and then remove the whole "Validate the quiz form to prevent common issues" section (until the form.onsubmit = … line). Then you'd want to replace the first for loop inside the onsubmit handler with
for (i = 0; i < form_elements.length; i++) {
form_element = form_elements;
if (form_element.type === "text" && form_element.value.trim().toLowerCase() === correct_answers[form_element.name]) {
score += 1;
}
}
(The .trim().toLowerCase() bit is to make the answers case-insensitive and remove leading and trailing spaces; the correct answers should always be all lowercase, since the answer they'll be compared to is all lowercase.)
It'd be a little more complicated if you want to straight-up accept multiple different correct answers to each question.
Inflammatory or off-topic comments will be deleted; please go to the guestbook for discussion unrelated to this page. You can use BBCode (forum code) to format your messages.
Giving an e-mail address is optional; if it is given, you will be notified by e-mail if I respond to your post. If you fill in a website (this should be your own website, blog or social media profile), it will be linked publicly on your post; however, messages obviously posted solely as a pretext for advertising, or advertising shady or inappropriate websites, will be deleted.
- [b]Bold[/b]
- [i]Italic[/i]
- [u]Underlined[/u]
- [s]Strikethrough[/s]
- [url=http://www.dragonflycave.com]Link[/url]
- [spoiler]Spoiler[/spoiler]
Aagh, can't believe I forgot about BBCode, but hopefully you can infer what the start of the italic section is actually meant to be here.
Yeah, at the moment the scale quiz script works by putting the number of points the answer is worth in the value attribute of the option, so although you could technically make a multiple-choice trivia quiz with it, it's not built to be able to write in your own answers.
For the modification, you would want to define the correct answers in an object like
var correct_answers = {
"q1": "pikachu",
"q2": …
};
and then remove the whole "Validate the quiz form to prevent common issues" section (until the form.onsubmit = … line). Then you'd want to replace the first for loop inside the onsubmit handler with
for (i = 0; i < form_elements.length; i++) {
form_element = form_elements;
if (form_element.type === "text" && form_element.value.trim().toLowerCase() === correct_answers[form_element.name]) {
score += 1;
}
}
(The .trim().toLowerCase() bit is to make the answers case-insensitive and remove leading and trailing spaces; the correct answers should always be all lowercase, since the answer they'll be compared to is all lowercase.)
It'd be a little more complicated if you want to straight-up accept multiple different correct answers to each question.
This feels like a good place to ask a related question. (Not least of which because I get a cute little Magby for my trouble!)
If I was looking to make a *quiz* quiz - e.g., something where you ask "Who's that yellow guy who goes pika-pika-pi?" and the reader writes in PIKACHU - how complicated a modification would that be of the Scale Quiz? You'd have to change the radio buttons to a text input, which isn't too tricky, but having the script determine what counts as a "right answer" seems a bit harder.
going to test this later when i have the time, thank you so much for your help ^^
The unmodified vote script can't do that as it stands, no. Try saving this page instead, though, and then it should work if you write all the values each answer applies to separated by commas in the value attribute of the radio input.
Honestly maybe I should just make that the default vote quiz script, since it still works with a single value per option and just makes it more flexible…
Thank you! I think the main thing I'd need to know is if with the vote quiz I can assign multiple results to an answer: for example having the results dandelion, sun, and buttercup all assigned to the answer yellow on a "What's your favourite color" question
Ooh, interesting! Feel free to contact me if you'd like any help with that - it sounds like what you want would be a bit different from these quiz types (correct me if I'm wrong), so you'd probably need to adjust the script a bit, but it should be possible. I read the first arc of Warriors recently and have some friends who love the series and would probably enjoy your quiz too, so I'd love to help it get made.
for a while ive had the idea for a warrior cats name quiz. a really impractical one. im talking hundreds of results. i actually started work on categorizing results recently (linked above. not complete) but couldnt actually make anything real with it because i didnt know how to code it. anyways thank you for solving that problem i will now use this new knowledge to fuel my hubris and make a very bad quiz that will almost definetly have skewed results
i love this template sm
Nice website
Aww, I'm glad it's been useful! I'm always happy to support anyone creating their own websites.
Hi Butterfree! Your wonderful Pokemon website has a fan who has never played Pokemon or even collected more than ten or so cards.
I'm from the Petz community (a series of pet simulation games from the 1990s) and I absolutely loved your tutorial on how to create custom quizzes. I dipped my toes into HTML coding for the first time with a silly little personality quiz on my drag-and-drop builder site, and now I've been working on incorporating more HTML. Eventually I'd love to switch to something like Neocities so I can custom-build everything (and get away from an external corporation I don't like).
Thank you so much for sharing these resources with not just the Pokemon community, but the whole world of the web. You guide is accessible, helpful, and lots of fun!