var form;
$(document).ready(function(){
  form = layui.form;
});

$("#finished_button").click(function(){
  var ketangid = $("#detail_form").find("input[name='ketangid']").val();
  var isrushed = $("#detail_form").find("input[name='isrushed']:checked").length;
  if(isrushed==0){
    layer.msg("请选择提问方式", {icon:2}); return false;
  }
  var hascontent = UE.getEditor('editor_cont').hasContents();
  if(hascontent==false){
    layer.msg("请填写题目内容", {icon:2}); return false;
  }
  var answercodes = $("#detail_form").find("input[name='answercode']:checked").length;
  if(answercodes==0){
    layer.msg("请选择正确答案", {icon:2}); return false;
  }
  $("#detail_form").ajaxSubmit({
    url: '/glketang/pptaskadd3/basicok', 
    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(){window.location.href = "/glketang/pptaskq/"+ ketangid;});
      }else{
        layer.msg(data.msg, {icon:2});
      }
    },
    error: function(){
      layer.msg("系统错误，请联系管理员", {icon:2});
    },
    complete: function(){
      layer.closeAll('loading');
    }
  });
  return false;
});