<?php use app\components\QuestionHelper; ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>查看</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="apple-mobile-web-app-status-bar-style" content="black"> 
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="format-detection" content="telephone=no">
  
  <link rel="stylesheet" href="/plugins/layui/css/layui.css">
  <link rel="stylesheet" href="/plugins/fontawesome/css/font-awesome.min.css" />
  <link rel="stylesheet" href="/public/css/global.css">

  <script src="/public/js/jquery-1.11.3.min.js"></script>
  <script src="/public/js/jquery.form-3.36.0.min.js"></script>
  
  <style type="text/css">
  .layui-form-radio {
      margin: 0;
      padding-right: 0;
  }
  .layui-form-checkbox[lay-skin=primary]{
    padding-right: 10px;
  }
  </style>
</head>
<body>

<div class="layui-fluid" style="padding-left: 10px; padding-right: 10px; margin-top: 10px;">

<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:4px;"></p>
  <?php if($onestem->typeid==1 || $onestem->typeid==2){ ?>
    <div style="margin: 10px 0;">
    <?php foreach ($onestem->options as $oneoption) { ?>
    <?php
      echo '<div style="float:left;"><span class="layui-badge layui-bg-blue">'. $oneoption->code .'</span>&nbsp;</div>';
      echo '<div class="quest-option-content" style="float:left;">'. htmlspecialchars_decode($oneoption->content) .'</div>';
      echo '<p style="clear:both;height:4px;"></p>';
    } ?>
    </div>
  <?php } ?>
  <div class="quest-answer-content" style="margin:10px 0;">
  答案：
  <?php if($onestem->typeid==1 || $onestem->typeid==2 || $onestem->typeid==5){
    echo htmlspecialchars_decode($onestem->answer);
  }elseif($onestem->typeid==3){
    if($onestem->answer=="1"){echo '正确';}else{echo '错误';}
  }elseif($onestem->typeid==4){
    foreach ($onestem->options as $oneopkey => $oneoption) {
      ?>
      <div class="layui-input-inline" style="width: 200px; margin-right:10px;"><input type="text" class="layui-input" disabled placeholder="填空<?php echo ($oneopkey+1); ?>" value="<?php echo $oneoption->content; ?>"></div>
      <?php
    }
  } ?>
  </div>
  <div style="margin:10px 0;">
  分值：
  <?php echo $onestem->points; ?>
  </div>
  <div style="margin:10px 0;">
  学生：
  <?php if($onestem->typeid==1 || $onestem->typeid==2 || $onestem->typeid==5){
    echo $onestem->doanswer->answer;
  }elseif($onestem->typeid==3){
    if($onestem->doanswer->answer=="1"){echo '正确';}else{echo '错误';}
  }elseif($onestem->typeid==4){
    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" disabled placeholder="填空<?php echo ($oneopkey+1); ?>" value="<?php echo $doanswerarr[$oneopkey]; ?>"></div>
      <?php
    }
  } ?>
  </div>
  <div style="margin:10px 0;">
  得分：
    <?php echo $onestem->doanswer->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="margin:10px 0;">总得分：<?php echo $doexam->points; ?></div>
<hr>

<div style="margin:10px 0;">
  评语：
  <?php echo $doexam->remark; ?>
</div>
<hr>

<div class="layui-form-item">
  <div class="layui-input-block">
    <button type="button" class="layui-btn" id="finished_button">重新批改</button>
  </div>
</div>

<div style="height:20px;"></div>
<input type="hidden" name="examid" value="<?php echo $exam->id; ?>">
<input type="hidden" name="studentid" value="<?php echo $doexam->userid; ?>">
</form>

</div>

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

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

<script type="text/javascript">
//重新批改
$("#finished_button").on("click", function(){
  window.location.href = "/glexam/pigaione/index?id="+ doexid;
});
</script>

<script src="/plugins/layui/layui.all.js"></script>
</body>
</html>