使用javascript从xml文件中随机测验问题

时间:2015-04-14 17:47:44

标签: javascript xml random

我刚刚在xml文件中创建了一个测验。我设法使孔代码正常工作。我现在陷入困境,如何让测验问题随机出现?你可以在Javascript中看到其中一个问题。

<!-- question 1 -->
        <question id="q1" time="15" event="">

    <box id="col1" position="relative" class="col-md-6" />
    <box id="col2" position="relative" class="col-md-6" />

    <text id="question1" position="relative" target="col1" x="0" margin-top="150" margin-bottom="40" anim="left" animtime="0.5"><![CDATA[<p class="p_24">What's my name?</p>]]></text>
    <image id="fb1image" position="relative" target="col1" x="0" y="0" margin-bottom="30" anim="none" class="img-responsive"><![CDATA[lib/assets/c1.jpg]]></image>
<!--option 1 -->
<option correct="true">
<text id="option1_1" position="relative" target="col1" x="match" width="100%" margin-bottom="5" anim="left" animtime="0.5" animdelay="0.5" event="optionover,selectandsubmit" class="optionBox"><![CDATA[<p class="p_16 white">Pontus</p>]]></text>
</option>
<!--option 2 -->
<option correct="false">
<text id="option1_2" position="relative" target="col1" x="match" width="100%" margin-bottom="5" anim="left" animtime="0.5" animdelay="0.6" event="optionover,selectandsubmit" class="optionBox"><![CDATA[<p class="p_16 white">Peter/Bb</p>]]></text>
</option>
<!--/options -->
<!-- feedbacks -->
<fb id="pass" event="">

<box id="fb" position="relative" target="col2" margin-top="150" clear="both" anim="show" animtime="0.5">
<image id="passimage" position="relative" x="0" y="0" margin-bottom="30" anim="none" class="img-responsive"><![CDATA[lib/assets/c1_correct.jpg]]></image>

<text id="txt1" position="relative" anim="none" margin-bottom="30"><![CDATA[<p class="p_24">Correct!</p><p>My name is Pontus.</p><p>Good job!</p>]]></text>
<button id="nextQBtn" position="relative" width="150" margin-bottom="10" anim="none" event="btnover,loadNextQuestion"><![CDATA[Next]]></button>

<text id="bottompad" position="relative" anim="none"><![CDATA[<p>&nbsp;</p>]]></text>
</box>
</fb>
<fb id="fail" event="">
<box id="fb" position="relative" target="col2" margin-top="150" clear="both" anim="show" animtime="0.5">
<image id="failimage" position="relative" x="0" y="0" margin-bottom="30" anim="none" class="img-responsive"><![CDATA[lib/assets/c1_correct.jpg]]></image>

<text id="txt1" position="relative" anim="none" margin-bottom="30"><![CDATA[<p class="p_24">Wrong!</p><p>My name is Pontus.</p><p>Be careful!</p>]]></text>
<button id="nextQBtn" position="relative" width="150" margin-bottom="10" anim="none" event="btnover,loadNextQuestion"><![CDATA[Next]]></button>

<text id="bottompad" position="relative" anim="none"><![CDATA[<p>&nbsp;</p>]]></text>
</box>
</fb>
</question>

0 个答案:

没有答案