diff --git a/README.md b/README.md index a22d2b2..c512136 100644 --- a/README.md +++ b/README.md @@ -6,36 +6,13 @@ This is a example for a simple quiz 3. Run `npm start` 4. Open your browser and go to `http://localhost:3000` ## How to edit questions -1. go to `src/index.html` -2. In the `questions` element, follow the following structure and fill in between the brackets: -```html -
-

(question)

- -


+1. Open the file `questions.json` +2. Edit the questions in the questions array with the following format: +```json +{"question": "(question)", "answer": "(answer)"} ``` -3. In the script tag, follow the following structure and fill in between the brackets: -```js -async function question(question_number)_submit() { - var question_(question_number) = document.getElementById("question_(question_number)"); - question_(question_number).disabled = true; - //set the cookie 1 to the value of the question and remove the expiry date - document.cookie = "question_1=" + question_(question_number).value + "; expires=Thu, 01 Jan 3000 00:00:00 UTC; path=/;"; - //check if the answer is correct - if (question_(question_number).value === question_(question_number).dataset.answer) { - question_(question_number).style.backgroundColor = "green"; - question_(question_number).style.color = "white"; - return true; - } else { - question_(question_number).style.backgroundColor = "red"; - question_(question_number).style.color = "white"; - return false; - } -} -``` -4. Add the newly made functions to the submit_all function at the start -5. In the html, edit the number in the score element to the amount of questions you have -6. In the script tag and in the submit_all() function, edit the score_total variable to the amount of questions you have +3. Save the file +4. No need to restart the server, the questions will be reloaded automatically ## How to contribute 1. Fork the repository 2. Make your changes diff --git a/src/index.html b/src/index.html index a7d23a0..993cb97 100644 --- a/src/index.html +++ b/src/index.html @@ -6,23 +6,13 @@ + Document -
-

What is the year that never gonna give you up was released?


- -


-
-

What do you call the instrument that helps planes land in no visibility??

- -


-
-

What is the biggest discord server

- -


+

@@ -58,6 +48,7 @@

Score: /2

transition: background-color 2s, color 2s; padding: 12px 20px; } + /*put the score in the top right corner*/ #score { position: absolute; @@ -97,88 +88,79 @@

Score: /2

} \ No newline at end of file diff --git a/src/questions.json b/src/questions.json new file mode 100644 index 0000000..b61b457 --- /dev/null +++ b/src/questions.json @@ -0,0 +1,16 @@ +{ + "questions": [ + { + "question": "What is the capital of France?", + "answer": "Paris" + }, + { + "question": "When was never gonna give you up released?", + "answer": "1987" + }, + { + "question": "What is the system for landing a plane called? (use the acronym)", + "answer": "ILS" + } + ] +} \ No newline at end of file