12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8" />
- <meta name="viewport" content="width=device-width" />
- <title>Prueba sobre cultura de Alemania</title>
- <script type="text/javascript" src="preguntas.js"></script>
- </head>
- <body>
- <h2>Prueba sobre cultura de Alemania</h2>
- <script>
- html_test = document.getElementsByTagName("body")[0];
- preguntas.forEach(
- (arr, index1) => {
- var correct;
- arr.forEach(
- item => {
- check_array = Array.isArray(item);
- if (check_array) {
- item.forEach((answer, index2) => {
- html_answer = '<div><input name="answers_' + index1 + '" id="answer_' + index1 + '.' + index2 + '"' + ' type="radio"';
- var emoji;
- if (correct == index2 + 1) {
- html_answer += 'value="correct"'
- html_answer += 'onclick="this.parentElement.lastChild.removeAttribute(' + "'hidden'" + ')"';
- emoji = '<span hidden>✅</span>'
- } else {
- html_answer += 'value="incorrect"'
- html_answer += 'onclick="this.parentElement.lastChild.removeAttribute(' + "'hidden'" + ')"';
- emoji = '<span hidden>❌</span>'
- }
- html_answer += '>' + '<label for="answer_' + index1 + '.' + index2 + '">' + answer + '</label>';
- html_test.innerHTML += html_answer + ' ' + emoji + '</div>';
- }
- );
- } else {
- if (isNaN(item)) {
- html_test.innerHTML += "<h3>" + (index1+1) + '. ' + item + "</h3>";
- } else {
- correct = item;
- console.log(correct);
- }
- }
- }
- )
- }
- );
- </script>
- </body>
- </html>
|