index.html 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width" />
  6. <title>Prueba sobre cultura de Alemania</title>
  7. <script type="text/javascript" src="preguntas.js"></script>
  8. </head>
  9. <body>
  10. <h2>Prueba sobre cultura de Alemania</h2>
  11. <script>
  12. html_test = document.getElementsByTagName("body")[0];
  13. preguntas.forEach(
  14. (arr, index1) => {
  15. var correct;
  16. arr.forEach(
  17. item => {
  18. check_array = Array.isArray(item);
  19. if (check_array) {
  20. item.forEach((answer, index2) => {
  21. html_answer = '<div><input name="answers_' + index1 + '" id="answer_' + index1 + '.' + index2 + '"' + ' type="radio"';
  22. var emoji;
  23. if (correct == index2 + 1) {
  24. html_answer += 'value="correct"'
  25. html_answer += 'onclick="this.parentElement.lastChild.removeAttribute(' + "'hidden'" + ')"';
  26. emoji = '<span hidden>✅</span>'
  27. } else {
  28. html_answer += 'value="incorrect"'
  29. html_answer += 'onclick="this.parentElement.lastChild.removeAttribute(' + "'hidden'" + ')"';
  30. emoji = '<span hidden>❌</span>'
  31. }
  32. html_answer += '>' + '<label for="answer_' + index1 + '.' + index2 + '">' + answer + '</label>';
  33. html_test.innerHTML += html_answer + ' ' + emoji + '</div>';
  34. }
  35. );
  36. } else {
  37. if (isNaN(item)) {
  38. html_test.innerHTML += "<h3>" + (index1+1) + '. ' + item + "</h3>";
  39. } else {
  40. correct = item;
  41. console.log(correct);
  42. }
  43. }
  44. }
  45. )
  46. }
  47. );
  48. </script>
  49. </body>
  50. </html>