Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.76 KB | None | 0 0
  1. -------------------------------------HTML------------------------------------
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5. <meta charset="UTF-8"/>
  6. <title> Quiz </title>
  7. <link rel="stylesheet" href="file:///C:/Users/Irisio/Desktop/Quiz/Stylesheet.css">
  8.  
  9. </head>
  10.  
  11. <body>
  12. <div id="container" class="title"
  13. <div class="title"> Quiz sur l'athlétisme </div>
  14. <div id="question" class="question"></div>
  15. <label class="option"><input type="radio" name="option" value="1" /> </span id="opt1"></label>
  16. <label class="option"><input type="radio" name="option" value="2" /> </span id="opt2"></label>
  17. <button id="nextButton" class="next-btn" onclick="prochainequestion();"> Prochaine Question </button>
  18. </div>
  19. <div id="result" class="container result" style="display:none;">
  20. </div>
  21. <script src="file:///C:/Users/Irisio/Desktop/Quiz/questions.js"> </script>
  22. <script src="file:///C:/Users/Irisio/Desktop/Quiz/quiz.js"></script>
  23. </body>
  24. </html>
  25.  
  26. -------------------------------------questions.js------------------------------------
  27. var questions = [{
  28. "question" : "Usain Bolt est -il le recordman  du 100m en 9. 58 ?",
  29. "option1" : "Vrai",
  30. "option2" : "Faux",
  31. "answer" : "1"
  32. }
  33. ,
  34. {
  35. "question" : "Christophe Lemaitre est il le recordman du 200m en 19. 19 ?",
  36. "option1" : "Vrai",
  37. "option2" : "Faux",
  38. "answer" : "2"
  39. }
  40. ,
  41. {
  42. "question" : "Wayde Van Niekerk est -il le recordman du 400m en 43. 03 ?",
  43. "option1" : "Vrai",
  44. "option2" : "Faux",
  45. "answer" : "1"
  46. }
  47. ,
  48. {
  49. "question" : "Bernard Lagat est-il le recordman du 1500m en 3 : 26. 00 ?",
  50. "option1" : "Vrai",
  51. "option2" : "Faux",
  52. "answer" : "2"
  53. }
  54. ,
  55. {
  56. "question" : "Kenenisa Bekele est-il  le recordman du 5000m en 12 : 37. 35 ?",
  57. "option1" : "Vrai",
  58. "option2" : "Faux",
  59. "answer" : "1"
  60. }
  61. ,
  62. {
  63. "question" : "Mohamed Farah est-il le  recordman du 10000m en 26 : 17. 53 ?",
  64. "option1" : "Vrai",
  65. "option2" : "Faux",
  66. "answer" : "2"
  67. }
  68. ,
  69. {
  70. "question" : "Dennis Kimetto est-il le recordman  du marathon en 2 h 02 min 57 s ?",
  71. "option1" : "Vrai",
  72. "option2" : "Faux",
  73. "answer" : "1"
  74. }
  75. ,
  76. {
  77. "question" : "Aries Merritt est-il le recordman du 110m haies en 12. 80 ?",
  78. "option1" : "Vrai",
  79. "option2" : "Faux",
  80. "answer" : "1"
  81. }
  82. ,
  83. {
  84. "question" : "Stéphane Diagana  est-il le  recordman du 400m haies en 46. 78 ?",
  85. "option1" : "Vrai",
  86. "option2" : "Faux",
  87. "answer" : "2"
  88. }
  89. ,
  90. {
  91. "question" : "Saif Saaeed Shaheen est-il le recordman du 3. 000m Steeple en 7 : 53. 63 ?",
  92. "option1" : "Vrai",
  93. "option2" : "Faux",
  94. "answer" : "1"
  95.  
  96. }
  97. ,
  98. {
  99. "question" : "Javier Sotomayor  est-il le  recordman du saut en hauteur avec 2m45 ?",
  100. "option1" : "Vrai",
  101. "option2" : "Faux",
  102. "answer" : "1"
  103. }
  104. ,
  105. {
  106. "question" : "Carl Lewis est-il le  recordman du saut en longueur avec 8m95 ?",
  107. "option1" : "Vrai",
  108. "option2" : "Faux",
  109. "answer" : "2"
  110. }
  111. ,
  112. {
  113. "question" : "Renaud Lavillenie est-il le recordman du saut à la perche avec 6m16 ?",
  114. "option1" : "Vrai",
  115. "option2" : "Faux",
  116. "answer" : "1"
  117. }
  118. ,
  119. {
  120. "question" : "Teddy Tamgho Qui est recordman du monde du triple saut avec 18m29 ?",
  121. "option1" : "Vrai",
  122. "option2" : "Faux",
  123. "answer" : "2"
  124. }
  125. ,
  126. {
  127. "question" : "Reese Hoffa Qui est recordman du monde du lancer du poids avec 23m12 ? ",
  128. "option1" : "Vrai",
  129. "option2" : "Faux",
  130. "answer" : "2"
  131. }
  132. ,
  133. {
  134. "question" : "Jürgen Schult est-il le  recordman  du lancer du disque avec 74m08 ?",
  135. "option1" : "Vrai",
  136. "option2" : "Faux",
  137. "answer" : "1"
  138. }
  139. ,
  140. {
  141. "question" : "Ivan Tsikhan est-il le  recordman du lancer du marteau avec 86m74 ?",
  142. "option1" : "Vrai",
  143. "option2" : "Faux",
  144. "answer" : "2"
  145. }
  146. ,
  147. {
  148. "question" : "Steeve Backley est-il le recordman  du lancer du javelot avec 98m48 ?",
  149. "option1" : "Vrai",
  150. "option2" : "Faux",
  151. "answer" : "2"
  152. }
  153. ,
  154. {
  155. "question" : "Ashton Eaton  est-il recordman du décathlon avec 9039 pts ?",
  156. "option1" : "Vrai",
  157. "option2" : "Faux",
  158. "answer" : "1"
  159. }
  160. ,
  161. {
  162. "question" : "Yusuke Suzuki  est-il le recordman du 20km marche en 1 h 16 min 36 s ?",
  163. "option1" : "Vrai",
  164. "option2" : "Faux",
  165. "answer" : "1"
  166. }
  167.  
  168. -------------------------------------quiz.js------------------------------------
  169. var currentQuestion = 0;
  170. var score = 0;
  171. var totQuestions = question.lenght;
  172.  
  173. var container = document.getElementById('quiz');
  174. var questionEl = document.getElementById('question');
  175. var opt1 = document.getElementById('opt1');
  176. var opt2 = document.getElementById('opt2');
  177. var nextButton = document.getElementById('nextButton')
  178. var result = document.getElementById('result')
  179.  
  180.  
  181. function loadQuestion (questionIndex) {
  182. var q = question[questionIndex];
  183. questionEl.textContent = (questionIndex + 1) + '. ' + q.question;
  184. opt1.textContent = q.option1;
  185. opt2.textContent = q.option2;
  186. };
  187.  
  188. function prochainequestion () {
  189. var selectedOption = document.querySelector('input[type=radio]:checked');
  190. if (!selectedOption) {
  191. alert('Veuillez séléctionnez votre réponse')
  192. return;
  193. }
  194. var answer = selectedOption.value;
  195. if(question[currentQuestion].answer == answer){
  196. score +=10;
  197. }
  198. selectedOption.checked = false;
  199. currentQuestion++;
  200. if(currentQuestion == totQuestions -1){
  201. nextButton.textContent = 'Finish';
  202. }
  203. if (currentQuestion == totQuestions){
  204. container.style.displan = 'none';
  205. resultCont.style.display = '';
  206. resultCont.textContent = 'Ton score est de :' + score;
  207. return;
  208. }
  209. loadQuestion(currentQuestion);
  210. }
  211.  
  212. loadQuestion(currentQuestion);
  213.  
  214. -------------------------------------Steelsheet.css------------------------------------
  215. body {background-image: url("file:///C:/Users/Irisio/Desktop/Quiz/athl%C3%A9tisme.png")}
  216. body {background-size: cover;}
  217. body {background-repeat: no-repeat;}
  218.  
  219.  
  220. .title{
  221. padding-top: 20px;
  222. text-align: center;
  223. font-size: 35px;
  224. text-transform: uppercase;
  225. font-weight: bold;
  226.  
  227. }
  228.  
  229. .question{
  230. padding: 20px;
  231. font-size: 22px;
  232. color: white;
  233. border-radius: 20px;
  234. margin: 10px 0 10px 0;
  235. margin-top: 10%;
  236. height:20%;
  237. background:black;
  238. text-align: center;
  239.  
  240. }
  241.  
  242. .option{
  243. width: 471px;
  244. display: inline-block;
  245. padding: 10px 0 10px 15px;
  246. vertical-align: middle;
  247. margin : 10px 0 10px 10px;
  248. border-radius: 20px;
  249. background: black;
  250. margin-left:15%;
  251.  
  252. }
  253.  
  254. .option:hover{
  255. background: white;
  256. color: black;
  257.  
  258. }
  259.  
  260. .next-btn{
  261. margin-top:5%;
  262. margin-left:47%;
  263. background-color:black;
  264. color: white;
  265. border-radius: 50px;
  266. width : 100px;
  267. height: 100px;
  268. }
  269.  
  270. .next-btn:hover{
  271. background-color: white;
  272. color: grey;
  273. cursor: pointer;
  274. }
  275.  
  276. .result{
  277. height: 100px;
  278. text-align:center;
  279. font-size: 75px;
  280. }
  281.  
  282. .option input:checked .option{
  283. background: yellow;
  284. color: black;
  285. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement