home.html 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
  7. <title>Kvíz: Který učitel na GJS jsi ty?</title>
  8. <script src="https://cdn.tailwindcss.com"></script>
  9. <script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
  10. <style>
  11. body { background-color: #f0f4f8; }
  12. .gjs-blue { background-color: #0055a4; }
  13. .card { border-radius: 15px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
  14. </style>
  15. <script>
  16. function quizApp() {
  17. return {
  18. zacalqiz: false,
  19. otazky: [],
  20. async startQuiz() {
  21. this.zacalqiz = !this.zacalqiz;
  22. if (this.zacalqiz && !this.otazky.length) {
  23. const res = await fetch('/api/questions?count=5');
  24. this.otazky = await res.json();
  25. }
  26. }
  27. };
  28. }
  29. function getSummary() {
  30. const quizScope = document.querySelector('[x-data*="SvobodaBody"]');
  31. if (!quizScope || typeof Alpine === 'undefined' || typeof Alpine.$data !== 'function') {
  32. return {
  33. teacher: null,
  34. similarityPercent: 0,
  35. message: 'Kvízové proměnné zatím nejsou dostupné. Spusťte kvíz a zavolejte getSummary() znovu.'
  36. };
  37. }
  38. const data = Alpine.$data(quizScope);
  39. const scores = Object.entries(data)
  40. .filter(([key, value]) => /Body$/.test(key) && typeof value === 'number' && Number(value) > 0)
  41. .map(([key, value]) => ({
  42. teacher: key.replace(/Body$/, ''),
  43. score: Number(value) || 0
  44. }));
  45. if (!scores.length) {
  46. return {
  47. teacher: null,
  48. similarityPercent: 0,
  49. totalScore: 0,
  50. message: 'Zatím není zaznamenán žádný výsledek.'
  51. };
  52. }
  53. const totalScore = scores.reduce((sum, entry) => sum + entry.score, 0);
  54. const bestMatch = scores.reduce((currentBest, entry) => {
  55. return entry.score > currentBest.score ? entry : currentBest;
  56. }, scores[0]);
  57. return {
  58. teacher: bestMatch.teacher,
  59. similarityPercent: totalScore > 0
  60. ? Math.round((bestMatch.score / totalScore) * 100)
  61. : 0,
  62. topScore: bestMatch.score,
  63. totalScore
  64. };
  65. }
  66. window.getSummary = getSummary;
  67. </script>
  68. </head>
  69. <body x-data="quizApp()">
  70. <template x-if="!zacalqiz">
  71. <div>
  72. <div >
  73. <h1>silly_qiz</h1>
  74. <h3 class="rainbow">toto bude mega giga silly qiz, aby jste mohli zjistit který z učítelů gimjs jste :3</h3>
  75. <a href="{{ url_for('index') }}">Začít kvíz</a>
  76. </div>
  77. </div>
  78. </template>
  79. <template x-if="zacalqiz">
  80. <div class="flex flex-col items-center justify-center min-h-screen p-4" x-data="{
  81. skoncilqiz: false,
  82. CurrentOtazka: 0,
  83. SvobodaBody: 0,
  84. SvobodovaBody: 0,
  85. ReditelkBody: 0,
  86. PasterikovaBody: 0,
  87. HelgertBody: 0,
  88. DominecBody: 0,
  89. DudilieuxBody: 0,
  90. HlavacekBody: 0,
  91. HolasovaBody: 0,
  92. BesinBody: 0,
  93. JilekBody: 0,
  94. JungovaBody: 0,
  95. HorovaBody: 0,
  96. KarnoltovaBody: 0,
  97. ValdaBody: 0,
  98. KozubekBody: 0,
  99. HrabecBody: 0,
  100. KubiskovaBody: 0,
  101. MarekBody: 0,
  102. LímanováBody: 0,
  103. NajemnikBody: 0,
  104. OrrBody: 0,
  105. AparicioBody: 0,
  106. HornicekBody: 0,
  107. SibaBody: 0,
  108. ToulecBody: 0,
  109. UlrichovaBody: 0,
  110. ZabranskaBody: 0,
  111. ZalskaBody: 0,
  112. SmidBody: 0,
  113. LafreniereBody: 0,
  114. StejskalBody: 0,
  115. EkrtovaBody: 0,
  116. BurdenovaBody: 0,
  117. VavraBody: 0
  118. }">
  119. <div class="card bg-white w-full max-w-lg p-6 border-t-8 border-blue-700">
  120. <h1 class="text-2xl font-bold text-center text-gray-800 mb-8">
  121. Který učitel na GJS jsi ty?
  122. </h1>
  123. <div class="mb-8">
  124. <p class="text-lg font-semibold text-gray-700 mb-4 text-center" x-text="otazky[CurrentOtazka]['question']"></p>
  125. <div class="space-y-3">
  126. <template x-for="(option, index) in otazky[CurrentOtazka]['options']" :key="index">
  127. <label class="block p-3 border rounded-lg cursor-pointer hover:bg-blue-50 transition">
  128. <input
  129. type="radio"
  130. name="q1"
  131. class="mr-2"
  132. :value="option"
  133. >
  134. <span x-text="option"></span>
  135. </label>
  136. </template>
  137. </div>
  138. </div>
  139. <div class="flex justify-between mt-10">
  140. <button class="px-6 py-2 bg-gray-200 text-gray-700 rounded font-bold hover:bg-gray-300 transition" x-on:click="CurrentOtazka = Math.max(CurrentOtazka - 1, 0)" x-bind:disabled="CurrentOtazka === 0">
  141. Předchozí
  142. </button>
  143. <button class="px-6 py-2 gjs-blue text-white rounded font-bold hover:opacity-90 transition" x-on:click="CurrentOtazka = Math.min(CurrentOtazka + 1, otazky.length - 1)" x-bind:disabled="CurrentOtazka >= otazky.length - 1">
  144. Další
  145. </button>
  146. </div>
  147. </div>
  148. </div>
  149. </template>
  150. <button @click="startQuiz()">Začít kvíz</button>
  151. </body>
  152. </html>