<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,member-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link href="${pageContext.request.contextPath }/common/admin/css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/common/admin/css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/common/admin/lib/icheck/icheck.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/common/admin/lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/common/other/kingedit/themes/default/default.css" rel="stylesheet" type="text/css" />
<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>添加题目</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 题目管理 <span class="c-gray en">&gt;</span> 添加题目 <a class="btn btn-success radius r mr-20" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="pd-20">
	<form action="" class="form form-horizontal" id="form-coupon-add">
  
    <div class="row cl">
		<label class="form-label col-2"><span class="c-red">*</span>题目名称：</label>
		<div class="formControls col-8">
			<input id="questionName" name="questionName" type="text" class="input-text" value="" placeholder="">
		</div>
	</div>
	
	<div class="row cl">
		<label id="integralLabel" class="form-label col-2"><span class="c-red">*</span>题目状态：</label>
		<div id="integralDiv" class="formControls col-2">
			<span class="select-box">
			<select id="questionStatu" name="questionStatu" class="select">
					<option value="1">正常使用</option>
					<option value="2">停止使用</option>
			</select>
			</span>
		</div>
	</div>
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>题目简介：</label>
			<div id="integralDiv" class="formControls col-2">
				<textarea id="questionDesc" name="questionDesc" class="textarea-text" placeholder="" style="width:200px;height:60px;"></textarea>
			</div>
		</div>
	<div class="row cl">
		<label  class="form-label col-2"><span class="c-red">*</span>计分方式：</label>
		<div  class="formControls col-2">
			<span class="select-box">
			<select id="questionCalculation" name="questionCalculation" class="select">
					<option value="1">累计分数</option>
					<option value="2">最高分数</option>
			</select>
			</span>
		</div>
	</div>
	<div class="row cl">
		<label  class="form-label col-2"><span class="c-red">*</span>题目类型：</label>
		<div  class="formControls col-2">
			<span class="select-box">
			<select id="questionType" name="questionType" class="select">
					<option value="1">营养</option>
					<option value="2">发育</option>
					<option value="3">健康</option>
			</select>
			</span>
		</div>
	</div>
	<div class="row cl">
		<label  class="form-label col-2"><span class="c-red">*</span>介绍图：</label>
		<div  class="formControls col-2">
			<span class="select-box">
			<select id="questionPic" name="questionPic" class="select">
					<option value="1">图标一</option>
					<option value="2">图标二</option>
					<option value="3">图标三</option>
					<option value="4">图标四</option>
					<option value="5">图标五</option>
					<option value="6">图标六</option>
					<option value="7">图标七</option>
					<option value="8">图标八</option>
					<option value="9">图标九</option>
					<option value="10">图标十</option>
					<option value="11">图标十一</option>
					<option value="12">图标十二</option>
			</select>
			</span>
		</div>
	</div>
	
	<!-- <div  id="introductionFigure" class="row cl">
		<label class="form-label col-2"><span class="c-red">*</span>介绍图：</label>
			<div class="col-10 ">
				<img alt="介绍图" src="" id="introduceImg" width="90" height="80">
				<input type="hidden" id="productIntroduceImg" name="questionPic" value=""/>
				<input type="button" id="insertfileIntroduce" value="选择文件" />
			</div>
		</div>	 -->
		<div id="optionDiv" >
			<div id="removes1"  class="row cl">
				<label class="form-label col-2"><span class="c-red">*</span>问题选项1：</label>
					<div  class="formControls col-6">
						<input id="options1" name="options" type="text" class="input-text" value=""  placeholder="选项名称">
						<input id="score1" name="score" type="text" class="input-text" value=""  placeholder="题目分数" maxlength="14" onkeyup="digitalDigital(this);">
						 <select class="select" id="optionIsChekcbox1" name="optionIsChekcbox">
					    	<option value="">请选择状态</option>
					      	<option value="1" >多选</option>
							<option value="2" >单选</option>
					    </select>
					
					
					</div>
				</div><br>
			</div>	
		</div>
		<div class="row cl">
				<input id="optionNumber" type="hidden" value="1">
			<label class="form-label col-2"></label> 
			<input id="addOption" class="btn btn-primary radius" type="button" value="新增选项" />
			<input type="button" class="remove btn btn-primary radius" onclick="removes()" value="删除选项" />
		</div>	
		
		
    <div class="row cl">
      <div class="col-9 col-offset-3">
        <input class="btn btn-primary radius" onclick="return checkForm()" type="button" id="submitBtn" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
      </div>
    </div>
  </form>
</div>
</div>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/icheck/jquery.icheck.min.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/Validform/5.3.2/Validform.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/layer/1.9.3/layer.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/js/tips.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/js/H-ui.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/My97DatePicker/WdatePicker.js"></script>  
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/js/H-ui.admin.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/other/kingedit/kindeditor.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/other/kingedit/lang/zh_CN.js"></script> 	
<script type="text/javascript">
$(function(){

});
$("#addOption").click(function() {
	var optionNumber = parseFloat($("#optionNumber").val());
	optionNumber = optionNumber+1;
		$('div#optionDiv').append(
				'<div id="removes'+optionNumber+'"  class="row cl">'+
				'<label class="form-label col-2"><span class="c-red">*</span>问题选项'+optionNumber+'：</label>'+
				'<div class="formControls col-6">'+
				'<input id="options'+optionNumber+'" name="options" type="text" class="input-text" value="" plac eholder="选项名称">'+
				'<input id="score'+optionNumber+'" name="score" type="text" class="input-text" value=""  placeholder="题目分数" maxlength="14" onkeyup="digitalDigital(this);">'+
				'<select class="select" id="optionIsChekcbox'+optionNumber+'" name="optionIsChekcbox">'+
		    	'<option value="">请选择状态</option>'+
		      	'<option value="1" >多选</option>'+
				'<option value="2" >单选</option>'+
		    	'</select>'+
				'</div>'+
				'</div>'+
				'</div>')
			 //修改选项条数
			   $("#optionNumber").val(optionNumber);
})
function removes(){
	var optionNumber = parseFloat($("#optionNumber").val());
	if(optionNumber == 1){
		alert("至少保留一个选项");
		return;
	}
	
	$("#removes"+optionNumber).remove();
	//修改选项条数
	   $("#optionNumber").val(optionNumber-1);
}
//上传介绍图
KindEditor.ready(function(K) {
	var editor = K.editor({
    	fileManagerJson : '${pageContext.request.contextPath }/common/other/kingedit/jsp/file_manager_json.jsp',
        uploadJson : '${pageContext.request.contextPath }/common/other/kingedit/jsp/upload_json.jsp',
		allowFileManager : true
	});
	K('#insertfileIntroduce').click(function() {
	     var imgid = $(this).attr("id");//获取当前ID
		editor.loadPlugin('image', function() {
			editor.plugin.imageDialog({
				showRemote : false,
				imageUrl : K('#productIntroduceImg').val(),
				clickFn : function(url, title, width, height, border, align) {
					K('#introduceImg').attr("src",url);
					K('#productIntroduceImg').val(url);
					editor.hideDialog();
					return false; 
				}
			});
		});
	}); 
	
});
function checkForm(){
	//名称验证
	 if(!commonTypeJdg('questionName',null,null,true)){
		layer.msg("题目名称不能为空",{icon: 2,time:2000});
		return false;
	} 
	 if(!commonTypeJdg('questionDesc',null,null,true)){
			layer.msg("题目简介不能为空",{icon: 2,time:2000});
			return false;
		} 
	 /* if(!commonTypeJdg('productIntroduceImg',null,null,true)){
			layer.msg("题目图片不能为空",{icon: 2,time:2000});
			return false;
		}  */
	 
	 
	
	$.ajax({
		url: '${pageContext.request.contextPath }/admin/answer/insertQuestion',
		data:$('#form-coupon-add').serialize(),
		dataType:'json',//服务器返回json格式数据
		type:'post',	//HTTP请求类型
		error:function(data){
			//alert("-----error:function----->>" + data);
      	  	layer.msg("添加失败!",{icon: 5,time:2000});
        },
        success:  function(data){
        	layer.msg(data.status,{icon:1,time:2000},function(){
				 parent.window.location.href = '${pageContext.request.contextPath }/admin/answer/getAllProblem';
			});
        }
	});
}
function reloadWindow() {
	window.location.reload();
}


//关闭隐藏div
function closeDiv() {
	$("#userInfoList").hide();
}
//输入数字校验
function digitalDigital(obj){
	obj.value=obj.value.replace(/\D/gi,"");
}
</script>
</body>
</html>