如何使用户一次进行QUIZZ?

时间:2019-05-18 13:59:46

标签: javascript html css

我有一个Quizz,其中有两个问题,每个问题有3个复选框。 如果用户回答正确,则可以单击按钮以获取奖励。如果不是,则没有按钮。 我要用户一次输入该测验的问题,如果他回答错了,那么他将无法再次输入。 这是我的html代码:

<form name="qcm">
<center> <H3> Reduction survey </H3> 
<h3> QUIZ</h3>
</center>
 <hr>
 <p> Questionnaire in the form of multiple choice questions.Questions may 
 have one or more correct answers. </P>
 <p style="color:brown" > <strong>Answer the questions and check the right 
 choice(s) to get the "-40%" reduction in dress</strong> </p>
 <p> Question 1: </p>
  <p> <strong>Which occasions the dresses existes in this websites are 
  used?</strong> </p>
  <ul>
  <li><input type="checkbox" name="q11"> prom </input> </li>
   <li><input type="checkbox" name="q12" >wedding</input> </li>
   <li><input type="checkbox" name="q13">bar party</input></li>
  </ul>
   <p> Question 2: </p>
   <p><strong> What are the materials that are the dresses fabriquated ? 
   </strong> </p>
    <ul>
    <li><input type="checkbox"name="q21"> Wool </input></li>
    <li><input type="checkbox"name="q22">Lining </input></li>
    <li><input type="checkbox" name="q23"> Coton  </input></li>
     </ul>
    <center>
    <input type="button" value="Correction" onclick="testqcm(this.form)">
    <input type="reset" value="Reset">
    <script src="button.js"></script> 
    </center>
    </form>
    </body>

如果他单击“更正”按钮,这是我的javascript代码:

 function testqcm(form){
  var w=window.open("", "fenêtre 2","width=500, height=300" );
  var contenu = "<html><head><title>qcm</title></head><center><h1> 
   Correction dynamique of the reduction test </h1></center><body>";

   if (form.q11.checked==true && form.q12.checked==true && 
   form.q13.checked==false){


    contenu += "<ul><li>The answer of the question 1 is True.</li>";
    }

    else 
    contenu += "<li>The answer of the question 1 is<u style='color:red;'> 
    False</u>.</li>";

     contenu += "<br>";
     if (form.q22.checked==true && form.q21.checked==false && 
     form.q23.checked==false )
    {

    contenu += "<li>The answer of the question 2 is True.</li>";
    }
    else 
    contenu += "<li>The answer of the question 2 is<u style='color:red;'> 
    False</u>.</li></ul>";

     if (form.q11.checked==true && form.q12.checked==true 
     &&form.q22.checked==true && form.q13.checked==false && 
     form.q21.checked==false && form.q23.checked==false )   {
    contenu += "<p style='color:red;'><strong> CONGRATULATIONS</strong> 
     </p> <p> You received <strong> -40% </strong> reduction in one dress 
     </p>";



   contenu += " <center><input type='button' value='Congratulations' 
   onclick=window.location.href='reduction.html'></center></body></html>";
     }
     w.document.write(contenu);

      }

1 个答案:

答案 0 :(得分:1)

回答问题后,在用户浏览器中设置一个cookie。当用户初始化页面时,将查看他们回答或未回答哪些问题,并显示适当的状态,允许他们完成测验或已经完成测验并且无法再次回答。