//提交试卷
$("#finished_button").on("click", function(){
  var exstemidarr = $("#exstems_form").find("input[name='exstemid[]']");
  var exstemtypearr = $("#exstems_form").find("input[name='exstemtype[]']");
  var expointsarr = $("#exstems_form").find("input[name='expoints[]']");
  var thereiserror = 0;
  $(exstemidarr).each(function(index, elem) {
    var onestemid = $(elem).val();
    var onetypeid = $(exstemtypearr).eq(index).val();
    var onepoints = $(expointsarr).eq(index).val();
    if(onepoints=="" || isNaN(onepoints)){
      thereiserror = 1;
    }
  });
  if(thereiserror==1){
    layer.msg("您还有题目没有打分", {icon:2});
    return false;
  }
  $("#exstems_form").ajaxSubmit({
    url: '/glexam/pigaione/finishedok', 
    type: 'POST',
    dataType: "json", 
    beforeSend: function(){
      layer.load(0, {shade: [0.2, '#393D49']});
    },
    success: function(data){
      if(data.code=="success"){
        layer.msg("成功", {icon:1}, function(){parent.location.reload();});
      }else{
        layer.msg(data.msg, {icon:2});
      }
    },
    error: function(){
      layer.msg("系统错误，请联系管理员", {icon:2});
    },
    complete: function(){
      layer.closeAll('loading');
    }
  });
  return false;
});