Fiskerik
New Coder
Hi, I’m pretty new to Javascript but I do know a bit HTML and CSS since before.
I try to build a webpage where I can add quizzes with different topics (Animals/Music/Technology etc) where a question will be presented along with 3-4 answer options. I want the user to be able to browse through different topics, select a specific quiz (for instance, Animal topic can contain “African Animals”, “Sea creatures” etc, and I want to be able to label the questions used with 1 or more labels to fall within these cathegories. The questions and alternatives should show for each question, with maybe an "Expand" button to reveal the answer for the question.
For the questions, I think I might need to have an array, which contains arrays with the questions, where I add the question as a variable and then the options as other variables. Then I could fetch the first array and get questions within it based on Topics etc.
I just need some input on how I build up the framework for the questions in the easiest way so I do right from the beginning since I don’t think my method is optimal. I will need to have a file/variable containing all questions, maybe already categorized, so that I have an array for all “Animal”-related questions, another array for “Technology” questions etc. I then want to be able to fetch random questions from the topics, depending on what the user selects.
Any input on how to build a good database for questions, with different topics, that then can be randomly selected from different categories, or selected based on a specific category, for the user to be able to see would be of immense help!
I try to build a webpage where I can add quizzes with different topics (Animals/Music/Technology etc) where a question will be presented along with 3-4 answer options. I want the user to be able to browse through different topics, select a specific quiz (for instance, Animal topic can contain “African Animals”, “Sea creatures” etc, and I want to be able to label the questions used with 1 or more labels to fall within these cathegories. The questions and alternatives should show for each question, with maybe an "Expand" button to reveal the answer for the question.
For the questions, I think I might need to have an array, which contains arrays with the questions, where I add the question as a variable and then the options as other variables. Then I could fetch the first array and get questions within it based on Topics etc.
I just need some input on how I build up the framework for the questions in the easiest way so I do right from the beginning since I don’t think my method is optimal. I will need to have a file/variable containing all questions, maybe already categorized, so that I have an array for all “Animal”-related questions, another array for “Technology” questions etc. I then want to be able to fetch random questions from the topics, depending on what the user selects.
Any input on how to build a good database for questions, with different topics, that then can be randomly selected from different categories, or selected based on a specific category, for the user to be able to see would be of immense help!
Code:
var quiz = {
"Animals": [
{
"id": 1,
"category": Animals
"question": "What animal is the biggest mammal on earth?",
"options": [
{
"a": "Rhino",
"b": "Elephant",
"c": "Giraffe",
"d": "Blue whale"
}
],
"answer": "Blue whale",
},
{
"id": 2,
"category": "Insects"
"question": "How many legs does a spider have?",
"options": [
{
"a": "6 legs",
"b": "12 legs",
"c": "8 legs"
}
],
"answer": "8 legs",
},...