<{$bootstrap}>
<{$jquery}>
<{$toolbar}>


<{if $op=="trial"}>

<h4>剛剛您寫錯的題目（變色為正確的選項）：</h4>
<table border=1 class="table table-striped table-bordered table-hover">
  <tr><td>題號</td><td>級別</td><td>選項1</td><td>選項2</td><td>選項3</td><td>選項4</td></tr>
  <{foreach from=$quest_data item=one_quest}>
    <tr><td><{$one_quest.id}></td><td><{$one_quest.level}></td>
      <{if $one_quest.answer==1}>
        <td class="red header headerSortDown"><{$one_quest.op1}></td>
      <{else}>
        <td><{$one_quest.op1}></td>
      <{/if}>
      <{if $one_quest.answer==2}>
        <td class="red header headerSortDown"><{$one_quest.op2}></td>
      <{else}>
        <td><{$one_quest.op2}></td>
      <{/if}>
      <{if $one_quest.answer==3}>
        <td class="red header headerSortDown"><{$one_quest.op3}></td>
      <{else}>
        <td><{$one_quest.op3}></td>
      <{/if}>
      <{if $one_quest.answer==4}>
        <td class="red header headerSortDown"><{$one_quest.op4}></td>
      <{else}>
        <td><{$one_quest.op4}></td>
      <{/if}>

    </tr>
    <tr><td colspan=6><{$one_quest.quest}></td></tr>
    <tr><td colspan=6>　</td></tr>
  <{/foreach}>
</table>

<{else}>
<h4>
  <table>
      <tr><th colspan=4>目前設定為</th></tr>
      <tr>
        <td>初級題數：<{$qty.level1}></td>
        <td>中級題數：<{$qty.level2}></td>
        <td>中高級題數：<{$qty.level3}></td>
        <td>高級題數：<{$qty.level4}></td>
      </tr>
    </table>
</h4>

<form name='paper' method=post action='index.php'>
  <table border=1 class="table table-striped table-bordered table-hover">
    <tr><td>題號</td><td>級別</td><td>選項1</td><td>選項2</td><td>選項3</td><td>選項4</td></tr>
    <{foreach from=$tmp_ans_level1 item=level_quest}>
      <tr><td><{$level_quest.id}></td><td><{$level_quest.level}></td><td><input type=radio value=1 name=op<{$level_quest.id}>><{$level_quest.op1}></td><td><input type=radio value=2 name=op<{$level_quest.id}>><{$level_quest.op2}></td><td><input type=radio value=3 name=op<{$level_quest.id}>><{$level_quest.op3}></td><td><input type=radio value=4 name=op<{$level_quest.id}>><{$level_quest.op4}></td></tr>
      <tr><td colspan=6><{$level_quest.quest}></td></tr>
      <tr><td colspan=6>　</td></tr>
    <{/foreach}>
    <{foreach from=$tmp_ans_level2 item=level_quest}>
      <tr><td><{$level_quest.id}></td><td><{$level_quest.level}></td><td><input type=radio value=1 name=op<{$level_quest.id}>><{$level_quest.op1}></td><td><input type=radio value=2 name=op<{$level_quest.id}>><{$level_quest.op2}></td><td><input type=radio value=3 name=op<{$level_quest.id}>><{$level_quest.op3}></td><td><input type=radio value=4 name=op<{$level_quest.id}>><{$level_quest.op4}></td></tr>
      <tr><td colspan=6><{$level_quest.quest}></td></tr>
      <tr><td colspan=6>　</td></tr>
    <{/foreach}>
    <{foreach from=$tmp_ans_level3 item=level_quest}>
      <tr><td><{$level_quest.id}></td><td><{$level_quest.level}></td><td><input type=radio value=1 name=op<{$level_quest.id}>><{$level_quest.op1}></td><td><input type=radio value=2 name=op<{$level_quest.id}>><{$level_quest.op2}></td><td><input type=radio value=3 name=op<{$level_quest.id}>><{$level_quest.op3}></td><td><input type=radio value=4 name=op<{$level_quest.id}>><{$level_quest.op4}></td></tr>
      <tr><td colspan=6><{$level_quest.quest}></td></tr>
      <tr><td colspan=6>　</td></tr>
    <{/foreach}>
    <{foreach from=$tmp_ans_level4 item=level_quest}>
      <tr><td><{$level_quest.id}></td><td><{$level_quest.level}></td><td><input type=radio value=1 name=op<{$level_quest.id}>><{$level_quest.op1}></td><td><input type=radio value=2 name=op<{$level_quest.id}>><{$level_quest.op2}></td><td><input type=radio value=3 name=op<{$level_quest.id}>><{$level_quest.op3}></td><td><input type=radio value=4 name=op<{$level_quest.id}>><{$level_quest.op4}></td></tr>
      <tr><td colspan=6><{$level_quest.quest}></td></tr>
      <tr><td colspan=6>　</td></tr>
    <{/foreach}>
  </table>
  <input type="hidden" name="op"  value="judge_score" />
  <input type="hidden" name="serial_num"  value=<{$serial_num}> />
  <input type="button" name="button"  value="考好了，看分數" onClick="check()" />
</form>

<{/if}>

<SCRIPT type="text/javascript">
  function check(){
    var flag = 1;
    <{foreach from=$tmp_ans_level1 item=level_quest}>
      if(!paper.op<{$level_quest.id}>[0].checked && !paper.op<{$level_quest.id}>[1].checked && !paper.op<{$level_quest.id}>[2].checked && !paper.op<{$level_quest.id}>[3].checked){
        alert("題號<{$level_quest.id}>尚未做答");
        flag = 0;
      }
    <{/foreach}>
    <{foreach from=$tmp_ans_level2 item=level_quest}>
      if(!paper.op<{$level_quest.id}>[0].checked && !paper.op<{$level_quest.id}>[1].checked && !paper.op<{$level_quest.id}>[2].checked && !paper.op<{$level_quest.id}>[3].checked){
        alert("題號<{$level_quest.id}>尚未做答");
        flag = 0;
      }
    <{/foreach}>
    <{foreach from=$tmp_ans_level3 item=level_quest}>
      if(!paper.op<{$level_quest.id}>[0].checked && !paper.op<{$level_quest.id}>[1].checked && !paper.op<{$level_quest.id}>[2].checked && !paper.op<{$level_quest.id}>[3].checked){
        alert("題號<{$level_quest.id}>尚未做答");
        flag = 0;
      }
    <{/foreach}>
    <{foreach from=$tmp_ans_level4 item=level_quest}>
      if(!paper.op<{$level_quest.id}>[0].checked && !paper.op<{$level_quest.id}>[1].checked && !paper.op<{$level_quest.id}>[2].checked && !paper.op<{$level_quest.id}>[3].checked){
        alert("題號<{$level_quest.id}>尚未做答");
        flag = 0;
      }
    <{/foreach}>
    if (flag){paper.submit();}
  }
</SCRIPT>