<?php use app\components\QuestionHelper; ?>
<style type="text/css">
.layui-form-radio {
    margin: 0;
    padding-right: 0;
}
.layui-form-checkbox[lay-skin=primary]{
  padding-right: 10px;
}
</style>
<h2><?php echo $exam->title; ?></h2>
<div style="margin:5px 0">开始时间：<?php echo $exam->begintime; ?></div>
<div style="margin:5px 0">结束时间：<?php echo $exam->endtime; ?></div>
<div style="margin:5px 0">考试说明：<?php echo $exam->descrip; ?></div>
<hr>
<form class="layui-form" id="exstems_form" method="post">
<?php foreach ($exstems as $onestkey => $onestem) { ?>
  <div style="margin: 10px 0;">
  <div style="float:left;"><span class="layui-badge"><?php echo $onestkey+1; ?>.</span>
  <span class="layui-badge layui-bg-blue"><?php echo QuestionHelper::ShowStemtypeName($onestem->typechild); ?></span>&nbsp;</div>
  <div class="quest-stem-content" style="float:left;"><?php echo htmlspecialchars_decode($onestem->content); ?></div>
  </div>
  <p style="clear:both;height:5px;"></p>
  <?php if($onestem->typeid==1 || $onestem->typeid==2){ ?>
    <?php foreach ($onestem->options as $oneoption) { ?>
    <div style="float:left;">
      <?php
      if($onestem->typeid==1){
      ?>
      <input type="radio" name="stem_<?php echo $onestem->id; ?>_answer" value="<?php echo $oneoption->code; ?>"<?php if(stripos($onestem->doanswer->answer, $oneoption->code)!==false){echo ' checked';} ?>>
      <?php
      }else{
      ?>
      <input type="checkbox" name="stem_<?php echo $onestem->id; ?>_answer[]" lay-skin="primary" value="<?php echo $oneoption->code; ?>"<?php if(stripos($onestem->doanswer->answer, $oneoption->code)!==false){echo ' checked';} ?>>
      <?php
      }
    ?>
    <?php
      echo '<span class="layui-badge layui-bg-blue">'. $oneoption->code .'</span>&nbsp;';
    ?>
    </div>
    <div class="quest-option-content" style="float:left;<?php if($onestem->typeid==1){echo 'padding-top:4px;';} ?>">
    <?php
      echo htmlspecialchars_decode($oneoption->content);
    ?>
    </div>
    <p style="clear:both;height:4px;"></p>
    <?php
    }
    ?>
  <?php }elseif($onestem->typeid==3){ ?>
    <div style="margin:10px 0;">
    <input type="radio" name="stem_<?php echo $onestem->id; ?>_answer" value="1" title="正确"<?php if($onestem->doanswer->answer=="1"){echo ' checked';} ?>>&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="radio" name="stem_<?php echo $onestem->id; ?>_answer" value="2" title="错误"<?php if($onestem->doanswer->answer=="2"){echo ' checked';} ?>>
    </div>
  <?php }elseif($onestem->typeid==4){ ?>
    <div style="margin:10px 0;">
    <?php foreach ($onestem->options as $oneopkey => $oneoption) {
      $doanswerarr = explode("#{#--#}#", $onestem->doanswer->answer);
    ?>
    <div class="layui-input-inline" style="width: 200px; margin-right:10px;"><input type="text" class="layui-input" name="stem_<?php echo $onestem->id; ?>_answer[]" placeholder="填空<?php echo ($oneopkey+1); ?>" value="<?php echo $doanswerarr[$oneopkey]; ?>"></div>
    <?php
    }
    ?>
    </div>
  <?php }elseif($onestem->typeid==5){ ?>
    <div style="margin:10px 0;">
    <textarea placeholder="请输入" class="layui-textarea" style="width:80%;" name="stem_<?php echo $onestem->id; ?>_answer"><?php echo $onestem->doanswer->answer; ?></textarea>
    </div>
  <?php } ?>
  <div style="margin:10px 0;">分值：<?php echo $onestem->points; ?></div>
  <input type="hidden" name="exstemid[]" value="<?php echo $onestem->id; ?>">
  <input type="hidden" name="exstemtype[]" value="<?php echo $onestem->typeid; ?>">
  <hr>
<?php } ?>
<div style="height:40px;"></div>
<input type="hidden" name="examid" value="<?php echo $exam->id; ?>">
<input type="hidden" name="savetype" value="1">
</form>

<div style="position:fixed; left:220px; bottom:60px;"><button type="button" class="layui-btn" id="finished_button">提交试卷</button></div>
<div style="position:fixed; right:20px; bottom:60px;"><button type="button" class="layui-btn" id="savepoints_button">保存进度</button></div>

<div id="timer_box" class="layui-bg-red" style="position:fixed; right:20px; top:70px; font-size:24px; padding:10px; border-radius:10px;"><i class="fa fa-clock-o"></i> <span>00:00:00</span></div>

<script type="text/javascript">
var examid = <?php echo $exam->id; ?>;
var begintime = "<?php echo $exam->begintime; ?>";
var endtime = "<?php echo $exam->endtime; ?>";

$(document).ready(function(){ 
  var form = layui.form;
});
</script>

<script src="/public/modules/doexam/question/index.js"></script>