<wxs module="util" src="../../utils/pub.wxs"></wxs>
<view class="top" wx:if="{{status != 1}}"> 
  <text bindtap="openAns">答题卡</text>
  总题数：{{idx}}/{{data.questions.length}}
   <view>{{time}}</view>
  
</view>
<view class="top" wx:else>
  <text bindtap="reDo">重做试卷</text>
  总题数 <view>{{idx}}/{{data.questions.length}}</view>
</view>
<!-- 判断 -->
<view class="content" wx:for="{{data.questions}}"  hidden="{{idx != index+1}}" wx:key="idx">
    <view class="num">{{index+1}}、
      <view> 
        <image wx:if="{{item.qtype == 1}}" src="../../images/danx.svg" mode="widthFix"></image>
        <image wx:if="{{item.qtype == 2}}" src="../../images/duox.svg" mode="widthFix"></image>
        <image wx:if="{{item.qtype == 3}}" src="../../images/pd.svg" mode="widthFix"></image>
      {{item.title}}
      </view>
    </view>
    <!-- <view class="ques">  {{item.title}}  </view> -->
    <view class="ans" wx:if="{{status}}">
      <view class="option"  wx:for="{{item.options}}" wx:for-item="opt" wx:key="*this" wx:if='{{item.qtype == 1}}'>
            <view wx:if='{{opt[0] == item.answer}}' class="correct">
              {{opt}}
            </view>
            <view wx:elif='{{opt[0] == item.post_answer && !item.correct}}' class="error">
              {{opt}}
            </view>
            <view wx:else>
              {{opt}}
            </view>  
      </view>
      <view class="option"  wx:for="{{item.options}}" wx:for-item="opt" wx:key="*this" wx:if='{{item.qtype == 2}}'>
            <view wx:if='{{util.includes(item.post_answer, opt[0]) && item.correct}}' class="correct">
              {{opt}} 
            </view>
            <view wx:elif='{{util.includes(item.post_answer, opt[0]) && !item.correct}}' class="error">
              {{opt}}
            </view>
            <view wx:else>
              {{opt}}
            </view>  
      </view>
      <view class="option" wx:if='{{item.qtype == 3}}'  wx:for="{{flag}}" wx:for-item="opt">
        <view wx:if='{{opt.value == item.answer}}' class="correct">{{opt.name}}</view>
        <view wx:elif='{{opt.value == item.post_answer && !item.correct}}' class="error">{{opt.name}}</view>
        <view wx:else>{{opt.name}}</view>
      </view>
      <view>
          <view  style="color:#000;margin-bottom: 15rpx;"><text style="color: #666;">正确答案：</text>{{item.answer}}   
          <text style="padding: 0 10px;"></text>
          <text style="color: #666;">您的答案：</text>{{item.post_answer?item.post_answer:''}}
          </view>
          <view style="color:#666">答案解析：</view>
          <view class="analysis">{{item.analysis}}</view>
      </view>
    </view>

    <view class="ans" wx:if="{{!status}}">
    
      <radio-group class="option"  wx:if="{{item.qtype == 3}}" bindchange='answer' data-id='{{item.id}}'>
              <view><radio color="#358BFF"   value="对">正确</radio></view>
              <view><radio color="#358BFF"   value="错">错误</radio></view>
        </radio-group>
        <checkbox-group  class="option" wx:elif="{{item.qtype == 2}}" bindchange='answer' data-id='{{item.id}}'>
            <view wx:for="{{item.options}}" wx:for-item="opt" wx:key="*this">
            <checkbox color="#358BFF" value="{{opt[0]}}">{{opt}}</checkbox></view>
        </checkbox-group>
        <radio-group wx:else bindchange='answer' data-id='{{item.id}}'>
            <view wx:for="{{item.options}}" wx:for-item="opt" wx:key="*this">
              <radio color="#358BFF"  value="{{opt[0]}}">{{opt}}</radio>
            </view>
        </radio-group> 
    </view>

</view> 

<view class="btn">
    <text class="{{idx<=1?'hide':''}}" bindtap="prev">上一题</text>
    <text class="{{idx>=data.questions.length?'hide':''}}" bindtap="next">下一题</text>
    <view bindtap="post" wx:if='{{status != 1}}'>交卷</view>
</view>

<view class="ans_bg" wx:if='{{show}}'>
  <view class="ans_card">
    <view>答题卡  <image bindtap="closeAns" class="close" mode="widthFix" src="../../images/back.png"></image></view>
    <text wx:for="{{data.questions}}" class="{{item.post_answer ? 'act':''}}" bindtap="skip" data-id='{{index}}'>{{index+1}}</text>
  </view>
</view>