Don't like ads? PRO users don't see any ads ;-)
Guest

Quiz

By: a guest on May 13th, 2012  |  syntax: HTML  |  size: 3.36 KB  |  hits: 25  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <HEAD>
  2.  
  3. <style type="text/css">
  4. <!--
  5. body {
  6. background=color: #000;
  7. color: white;
  8. font-weight: bold;
  9. }
  10. -->
  11. </style>
  12.  
  13. <script language="JavaScript">
  14.  
  15. // Insert number of questions
  16. var numQues = 6;
  17.  
  18. // Insert number of choice in each question
  19. var numChoi = 3;
  20.  
  21. // Insert number of questions to be displayed in answer area
  22. var answers = new Array(6);
  23.  
  24. // Insert answers to questions
  25. answers[0] = "Charr";
  26. answers[1] = "Eight";
  27. answers[2] = "Dwarves";
  28. answers[3] = "Heavy";
  29. answers[4] = "Player vs Player";
  30. answers[5] = "Tyria";
  31.  
  32. // Loops through each question and each choice and compares selected option to correct answer
  33. function getScore(form){
  34.  
  35.                 var score = 0;
  36.                 var currElt;
  37.                 var currSelection;
  38.                 var p=0;
  39.         while(p<1){
  40.                 for (i=0; i<numQues; i++) {
  41.                         currElt = i*numChoi;
  42.                         for (j=0; j<numChoi; j++) {
  43.                                 currSelection = form.elements[currElt + j];
  44.                                 if (currSelection.checked) {
  45.                                         if (currSelection.value == answers[i]) {
  46.                                                 score++;
  47.                                                 break;
  48.                                         }
  49.                                 }
  50.                         }
  51.                 }
  52.                 p++;
  53.         }
  54.  
  55. // calculates % score
  56. score = Math.round(score/numQues*100);
  57.  
  58. // assigns % score to value of text box
  59. form.percentage.value = score + "%";
  60.  
  61. // assigns correct answers array to value of textarea box
  62. var correctAnswers = "";
  63. for (i=1; i<=numQues; i++) {
  64.         correctAnswers += i + ". " + answers[i-1] + "\r\n";
  65.         }
  66. form.solutions.value = correctAnswers;
  67. }
  68. </script>
  69. </HEAD>
  70.  
  71. <BODY>
  72.  
  73. <h3>Guild Wars 2 Quiz</h3>
  74.  
  75. <form name="quiz">
  76. <DL><DT>1. Which Guild Wars 2 playable race was previously an ememy in the first game?
  77.         <DD><input type="radio" name="q1" value="Humans">Humans
  78.         <DD><input type="radio" name="q1" value="Norn">Norn
  79.         <DD><input type="radio" name="q1" value="Charr">Charr
  80. </DL>
  81.  
  82. <DL><DT>2. How many proffesions are there to choose from in Guild Wars 2?
  83.         <DD><input type="radio" name="q2" value="Five">Five
  84.         <DD><input type="radio" name="q2" value="Eight">Eight
  85.         <DD><input type="radio" name="q2" value="Ten">Ten
  86. </DL>
  87.  
  88. <DL><DT>3. Which is not a playable race in Guild Wars 2?
  89.         <DD><input type="radio" name="q3" value="Sylvari">Sylvari
  90.         <DD><input type="radio" name="q3" value="Dwarves">Dwarves
  91.         <DD><input type="radio" name="q3" value="Asura">Asura
  92. </DL>
  93.  
  94. <DL><DT>4. Which of these is a correct class of gear in Guild Wars 2?
  95.         <DD><input type="radio" name="q4" value="Heavy">Heavy
  96.         <DD><input type="radio" name="q4" value="Plate">Plate
  97.         <DD><input type="radio" name="q4" value="Chain">Chain
  98. </DL>
  99.  
  100. <DL><DT>5. In Guild Wars 2 and other MMOs, what does PVP stand for?
  101.         <DD><input type="radio" name="q5" value="Person vs Person">Person vs Person
  102.         <DD><input type="radio" name="q5" value="Popular Versatile Precision">Popular Versatile Precision
  103.         <DD><input type="radio" name="q5" value="Player vs Player">Player vs Player
  104. </DL>
  105.  
  106. <DL><DT>6. What ficticious world is Guild Wars 2 set in?
  107.         <DD><input type="radio" name="q6" value="Tamriel">Tamriel
  108.         <DD><input type="radio" name="q6" value="Azeroth">Azeroth
  109.         <DD><input type="radio" name="q6" value="Tyria">Tyria
  110. </DL>
  111.  
  112. <input type="button" value="Get score" onClick="getScore(this.form)">
  113. <input type="reset" value="Clear answers">
  114. <p> Score = <strong><input class="bgclr" type="text" size="5" name="percentage" disabled></strong><br><br>
  115. Correct answers:<br>
  116. <textarea class="bgclr" name="solutions" wrap="virtual" rows="6" cols="30" disabled>
  117. </textarea>
  118. </form>
  119.  
  120. </body>
  121. </html>