<%@ Page Title="" Language="C#" ClientIDMode="Static"  EnableEventValidation="false"  MasterPageFile="admin.Master" AutoEventWireup="true" EnableViewState="false" CodeBehind="question_new.aspx.cs" Inherits="Math.math.question_new" %>
<%@ Register src="../userControls/MdEditor.ascx" tagname="MdEditor" tagprefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <style>
        legend{ color:#ff6a00 }
    </style>
 
     <link href="../javascript/pandao-markdown/lib/katex/katex.min.css" rel="stylesheet" />
     <script src="../javascript/pandao-markdown/lib/katex/katex.min.js"></script>  
      <link href="../javascript/pandao-markdown/css/editormd.min.css" rel="stylesheet" />
     <script src="../javascript/pandao-markdown/editormd.js"></script>
    <script src="../javascript/math_editor.js"></script>
    
    <style>
      .layui-btn+.layui-btn {
     margin-left:0px;
     }
        .submenu-item {
    margin-left:0px;
    margin-right:10px;
    margin-top:10px;
    min-width:40px;
  }
    </style>

        <div>

             <a href="javascript:history.go(-1);"><i class="layui-icon layui-icon-return" style="font-size:12px; color: #1E9FFF;"></i>返回</a> 

            </div>


    <div>
  <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>1.试题题目</legend>
</fieldset>
      <div  >
     <uc1:MdEditor ID="MdEditor1" runat="server" gid="md1"  height="300px" autoFocus="true" />
 </div>
  </div>


   <div>
  <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>2.试题答案</legend>
</fieldset>
  <asp:TextBox runat="server"  AutoComplete="Off" class="layui-input" ID="txt_answer"></asp:TextBox>
    </div>


     <div>
   <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>3.试题解析</legend>
  </fieldset> 

     <div >
     <uc1:MdEditor ID="MdEditor2" runat="server"  gid="md2"/>
    </div>
  </div> 


      <div>
     <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>4.题目数学</legend>
</fieldset>




  <div class="layui-form-item">
    <div class="layui-inline">
      <label class="layui-form-label">课程分类</label>
      <div class="layui-input-inline">
               <asp:DropDownList runat="server" ID="ddl_qcat" ClientIDMode="Static"
           AppendDataBoundItems="true"  >
          <asp:ListItem Text="未分类" Value="0"></asp:ListItem>
        </asp:DropDownList>

     </div>
    </div>
    
      
      
      <div class="layui-inline">
     

    
          <label class="layui-form-label">试题类别</label>
          <div class="layui-input-block">
            <input type="radio" name="qtype" value="单选题" title="单选题" <%=initcheck %> >
            <input type="radio" name="qtype" value="多选题" title="多选题" >
            <input type="radio" name="qtype" value="判断题" title="判断题" >
            <input type="radio" name="qtype" value="填空题" title="填空题" >
            <input type="radio" name="qtype" value="问答题" title="问答题" >
          </div>
       

    </div>

</div>






          
  <div class="layui-form-item">
    <div class="layui-inline">
              <label class="layui-form-label">试题来源</label>
      <div class="layui-input-inline">
            <asp:TextBox runat="server"  ClientIDMode="Static"  Class="layui-input" ID="txt_source"></asp:TextBox>
          </div>
        

        </div>


       <div class="layui-inline">
              <label class="layui-form-label">试题分值</label>
      <div class="layui-input-inline">
            <asp:TextBox runat="server" Text="2"  ClientIDMode="Static"  Class="layui-input" ID="txt_score"></asp:TextBox>
          </div>
           </div>


      <div class="layui-inline">
              <label class="layui-form-label">难度等级</label>
      <div class="layui-input-inline">
          <div id="hard"></div>


            <input type="hidden" id="hf_hard"  name="hf_hard" value="<%=inithard %>"/>
          </div>
          </div>




      </div>





 
</div>


 

      <div>
       <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>5.标签</legend>
</fieldset>

    <asp:TextBox runat="server"  Class="layui-input"  ClientIDMode="Static" ID="txt_tags"></asp:TextBox>
</div>


 



  <div style="margin:20px;">

  </div>

    <asp:PlaceHolder runat="server" ID="ph_add">


          <div class="layui-form-item">
    <div class="layui-input-block">

    <a href="###" class="layui-btn" lay-submit  >添加</a>
      
     </div>
 </div>

    
    <script>




        layui.use( function(){
            var form = layui.form;
            form.on('submit', function (data) {
                var f = data.field;

                var question = Editor_md1.getMarkdown();
                var question2 = Editor_md1.getHTML();
                var answer = data.field.ctl00$ContentPlaceHolder1$txt_answer;
                var analyse = Editor_md2.getMarkdown();
                var analyse2 = Editor_md2.getHTML();

                var catId = f.ctl00$ContentPlaceHolder1$ddl_qcat;
                var qtype = f.qtype;

                var source = f.ctl00$ContentPlaceHolder1$txt_source;
                var score =f.ctl00$ContentPlaceHolder1$txt_score;
                var tags = f.ctl00$ContentPlaceHolder1$txt_tags;
               
                var hard = $("#hf_hard").val();
              

                $.ajax({
                    url: "../api/new.aspx",
                    data: {
                        question: question,
                        question2: question2,
                        answer: answer,
                        analyse: analyse,
                        analyse2: analyse2,
                        catId: catId,
                        qtype: qtype,
                        source: source,
                        score: score,
                        tags: tags,
                        hard: hard
                    },
                    type: "post",
                    cache: false,
                    async: false,
                    success: function (id) {


                        location.href = "done.aspx?id="+id;

                    }
                });
            });
           
        }); 
    
        layui.use(['rate'], function () {
            var rate = layui.rate;
            //基础效果
            rate.render({
                elem: '#hard',
                value: <%=inithard%>,
                choose: function(value){
                    $("#hf_hard").val(value);
                }
            })
        });

    </script>



      </asp:PlaceHolder>







    

      <asp:PlaceHolder runat="server" ID="ph_edit">
          
               <div class="layui-form-item">
    <div class="layui-input-block">
    <a href="###" class="layui-btn" lay-submit  >更新</a>

           <a  href="###" onclick="del();" class="layui-btn layui-btn-danger">删除</a>
     
        </div>
            </div>

             

          <script>
              function del()
              {
                  var id ='<%=id%>';
              if (confirm('确定删除吗？')) {
                  
                  $.get("../api/del.aspx?t=del&id=" + id);
                  window.location="question_my.aspx";

              }
              }


          </script>






    <script>
        var sel='<%=qtype%>';
        $("input[name=qtype]").each(function()
        {
            if($(this).val()==sel)
            {
                $(this).attr("checked",true);
            }
        
        });


        layui.use( function(){
            var form = layui.form;
            form.on('submit', function (data) {
                
                var f = data.field;

                var question = Editor_md1.getMarkdown();
                var question2 = Editor_md1.getHTML();
                var answer = data.field.ctl00$ContentPlaceHolder1$txt_answer;
                var analyse = Editor_md2.getMarkdown();
                var analyse2 = Editor_md2.getHTML();

                var catId = f.ctl00$ContentPlaceHolder1$ddl_qcat;
                var qtype = f.qtype;

                var source = f.ctl00$ContentPlaceHolder1$txt_source;
                var score =f.ctl00$ContentPlaceHolder1$txt_score;
                var tags = f.ctl00$ContentPlaceHolder1$txt_tags;
               
                var hard = $("#hf_hard").val();
                var id ='<%=id%>';

                $.ajax({
                    url: "../api/new.aspx",
                    data: {
                        question: question,
                        question2: question2,
                        answer: answer,
                        analyse: analyse,
                        analyse2: analyse2,
                        catId: catId,
                        qtype: qtype,
                        source: source,
                        score: score,
                        tags: tags,
                        hard: hard,
                        id:id
                    },
                    type: "post",
                    cache: false,
                    async: false,
                    success: function (id) {

                        location.href = "done.aspx?id="+id;
                        /*
                        layer.msg('保存成功', {
                            time: 500,
                            end: function () {
                                location.href = "question_my.aspx";
                            }
                        }) */


                    }
                });
            });
           
        }); 
    </script>




    <script>
        layui.use(['rate'], function () {
            var rate = layui.rate;
            //基础效果
            rate.render({
                elem: '#hard',
                value: <%=inithard%>,
                choose: function(value){
                    $("#hf_hard").val(value);
                }
            })



        });

    </script>


   </asp:PlaceHolder>






</asp:Content>
