<%@ page language="VB" autoeventwireup="false" enabletheming="false" inherits="WebExam.Web.secure_editmultest, App_Web_w5uoad04" %>
<%@ Register src="../modul/WebMsg.ascx" tagname="WebMsg" tagprefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>编辑试题</title>

    <script src="../paperStyle/3.1/key.js" type="text/javascript"></script>

    <link href="../../style/main.css" type="text/css" rel="stylesheet" />
 <script src="/jslib/jquery/jquery-lastest.js" type="text/javascript"></script>
<link type="text/css" href="/jslib/jquery/plugins/SpinButton/JQuerySpinBtn.css" rel="stylesheet" />
    <script type="text/javascript" src="/jslib/jquery/plugins/SpinButton/JQuerySpinBtn.js"></script>
    

</head>
<body onload="return window_onload()"><script type="text/javascript">
                                          $().ready(
        function() {
            $("#<%= TB_score.ClientId() %>").SpinButton({ min: 0 });
        });

       function getScoreABox(){return document.getElementById('<%= D_A.ClientID %>');}
       function getScoreBBox(){return document.getElementById('<%= D_B.ClientID %>');}
       function getScoreCBox(){return document.getElementById('<%= D_C.ClientID %>');}
       function getScoreDBox(){return document.getElementById('<%= D_D.ClientID %>');}
       
       function getOtherBox(){return document.getElementById('<%= D_other.ClientID %>');}
       function getScoreBox(){return document.getElementById('<%= TB_score.ClientID %>');}
      function getKPBox(){return document.getElementById('<%= LB_keyPoint.ClientID %>');}
      
      function getKBox1(){return document.getElementById('<%= TB_k1.ClientID %>');}
      function getKBox2(){return document.getElementById('<%= TB_k2.ClientID %>');}
      function getKBox3(){return document.getElementById('<%= TB_k3.ClientID %>');}
      function getKBox4(){return document.getElementById('<%= TB_k4.ClientID %>');}
       function degreeBox(){return document.getElementById('<%= DDLdi.ClientID %>');}
       
       function submitInfo(plain,tests) {
         var kpidstr="";
         var kpidname="";
         var kpBox=getKPBox();
         for(var i=0;i<kpBox.options.length;i++){
           if(kpBox.options[i].selected){
             kpidstr+=","+kpBox.options[i].value;
             kpidname+=","+kpBox.options[i].text;
           }
         }
         if(kpidname.length>0){kpidname =kpidname.substr(1)}
         if(kpidstr.length>0){kpidstr =kpidstr.substr(1)}
      

         var arr=new Array();
         for(var i=0;i<tests.length;i++)
          {   
              
              switch (i){
               case 0:
                 if(tests[i].content==""){alert("题目内容必须输入！");return false;};
                 break;
               case 1:
                 if(tests[i].content==""){alert("选项A必须输入！");return false;};break;
               case 2:
                 if(tests[i].content==""){alert("选项B必须输入！");return false;};break;       
     
              }
             
             arr[i]=tests[i].content;
             
         }
       var score=getScoreBox().value;
       if(parseFloat(score) <=0){
       
         alert("满分不能为0");return false;
       }
       
       
       if(getKBox1().value=="")
       {alert("必须至少有一个答案！");return false;}
       var scoreArr=new Array();var keyArr=new Array();var hasFullScore=false;
       var SB1=getScoreABox();
       if(SB1.value==0){alert("请输入所占比值！");SB1.focus();return false;}
       if(SB1.value==1)hasFullScore=true;
       scoreArr[scoreArr.length]=SB1.value;
       keyArr[keyArr.length]=getKBox1().value;
       if(getKBox2().value!=""){
         var SB2=getScoreBBox();
         if(SB2.value==0){alert("请输入所占比值！");SB2.focus();return false;}
         if(SB2.value==1)hasFullScore=true;
         scoreArr[scoreArr.length]=SB2.value;
         keyArr[keyArr.length]=getKBox2().value;       
       }
       if(getKBox3().value!=""){
         var SB3=getScoreCBox();
         if(SB3.value==0){alert("请输入所占比值！");SB3.focus();return false;}
         if(SB3.value==1)hasFullScore=true;
         scoreArr[scoreArr.length]=SB3.value;
         keyArr[keyArr.length]=getKBox3().value;       
       }
       if(getKBox4().value!=""){
         var SB4=getScoreDBox();
         if(SB4.value==0){alert("请输入所占比值！");SB4.focus();return false;}
         if(SB4.value==1)hasFullScore=true;
         scoreArr[scoreArr.length]=SB4.value;
         keyArr[keyArr.length]=getKBox4().value;       
       }
       if(!hasFullScore)
       {alert("必须至少有一个答案所占比值为100%！");return false;}
       for(var i=0;i<keyArr.length-1;i++){
         for(var j=i+1;j<keyArr.length;j++){
           var kk1=keyArr[i];var kk2=keyArr[j];
           if(kk1==kk2){
             alert("不能存在相同的答案！");return false;
           
           }
         
         
         }
       
       
       }
       var ps=_para[0];
       scoreArr[4] = getOtherBox().value;

       ps.saveMulTest(document.getElementById('<%= TB_note.ClientID %>').value, score, plain, arr, scoreArr, keyArr, degreeBox().value, kpidstr, kpidname);
       
       //return true;
      }
       /*
       function setKey(scoreArr,keyArr){
         var SB1=getScoreABox();var SB2=getScoreBBox();var SB3=getScoreCBox();var SB4=getScoreDBox();
         SB1.value=0;SB2.value=0;SB3.value=0;SB4.value=0;
         var KB1=getKBox1();var KB2=getKBox2();var KB3=getKBox3();var KB4=getKBox4();
         KB1.value="";KB2.value="";KB3.value="";KB4.value="";
         for(var i=0;i<keyArr.length;i++){
           switch(i){
             case 0:
               KB1.value=keyArr[i];SB1.value=scoreArr[i];
               break;
             case 1:
               KB2.value=keyArr[i];SB2.value=scoreArr[i];
               break;
             case 2:
               KB3.value=keyArr[i];SB3.value=scoreArr[i];
               break; 
             case 3:
               KB4.value=keyArr[i];SB4.value=scoreArr[i];
               break;
               
           }
         
         }
         
       }
       */
var tests;var _para;
function window_onload() {
  if((_para==null)&&(window.dialogArguments!=null)) {
     if(window.dialogArguments.length >0){_para=window.dialogArguments;}

  }
  
  tests=null;if(_para==null)return ;
  var para=_para;
  if(para.length>1){
     var level=para[1];
     var kpIdStr=para[2];
     tests=para[3];
     var scores=para[4];
     var fullScore=para[5];
     var keyArr = para[6]; var note = para[7];
     if (note == null) note = "";
     document.getElementById('<%= TB_note.ClientID %>').value = note;
     for(var i=0;i<keyArr.length;i++){
       if(i==0)getKBox1().value=keyArr[i];
       if(i==1)getKBox2().value=keyArr[i];
       if(i==2)getKBox3().value=keyArr[i];
       if(i==3)getKBox4().value=keyArr[i];
       
     
     }
     getScoreABox().value=to2bits(scores[0]);
     getScoreBBox().value=to2bits(scores[1]);
     getScoreCBox().value=to2bits(scores[2]);
     getScoreDBox().value=to2bits(scores[3]);
     getOtherBox().value=to2bits(scores[4]);
     getScoreBox().value=fullScore;
     degreeBox().value=level;
     var kpBox=getKPBox();
     var kpArr=kpIdStr.split(",");
     
     for(var i=0;i<kpBox.options.length;i++){
           var kpid=kpBox.options[i].value;
           var selected=false;
           for(var J=0;J<kpArr.length;J++){
             if(kpArr[J]==kpid){selected =true;break;}
     
           }
         
           kpBox.options[i].selected=selected;
         
    }
     
  }
  
}
// Float数据四舍五入到2位小数; 
function to2bits(flt) { 
  var uu=String(flt);
  
  var dot=uu.indexOf(".",0);
  if(dot==-1)uu+=".00";else{
    
     while (uu.length-dot-1<2){
       uu+="0";
     
     }
  
  }
  return uu;
}
function initData(note, fullScore, level, kpIdStr, scores, tests, keyArr) {
  editorFrame.init(tests);

  if (note == null) note = "";
  document.getElementById('<%= TB_note.ClientID %>').value = note;
     getScoreBox().value=fullScore;
     getScoreABox().value=to2bits(scores[0]);
     getScoreBBox().value=to2bits(scores[1]);
     getScoreCBox().value=to2bits(scores[2]);
     getScoreDBox().value=to2bits(scores[3]);
     getOtherBox().value=to2bits(scores[4]);
     getKBox1().value="";
     getKBox2().value="";
     getKBox3().value="";
     getKBox4().value="";
     
     if(keyArr.length>0){
       getKBox1().value=keyArr[0];
       if(keyArr.length>1)getKBox2().value=keyArr[1];
       if(keyArr.length>2)getKBox3().value=keyArr[2];
       if(keyArr.length>3)getKBox4().value=keyArr[3];
     }
     
     degreeBox().value=level;
     var kpBox=getKPBox();
     var kpArr=kpIdStr.split(",");
     
     for(var i=0;i<kpBox.options.length;i++){
           var kpid=kpBox.options[i].value;
           var selected=false;
           for(var J=0;J<kpArr.length;J++){
             if(kpArr[J]==kpid){selected =true;break;}
     
           }
         
           kpBox.options[i].selected=selected;
         
    }
     

}
function checkKey(e){
  
  var keynum;
  var keychar;
  
  if(window.event) // IE
  {
    keynum = e.keyCode;
   }
  else if(e.which) // Netscape/Firefox/Opera
  {
    keynum = e.which;
  }
  keychar = String.fromCharCode(keynum).toLowerCase();
  if((keychar=="a")||(keychar=="b")||(keychar=="c")||(keychar=="d")||(keychar=="e")||(keychar=="f"))
    return true;
  else
    return false;
}
function sortKey(keyBox){
  var key=keyBox.value.toLowerCase();
  var arr=new Array();
  for(var i=0;i<key.length;i++){
    arr[i]=key.substr(i,1); 
  
  }
  arr.sort(null);
  key=arr.join("")
  keyBox.value=key;
}
    </script>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager><uc1:WebMsg ID="WebMsg1" runat="server" />
    <iframe frameborder="0" id="editorFrame" align="center" name="mytext" marginwidth="0"
        marginheight="0" src="../../../richedit/_samples/html/richedit.htm?testclass=a"
        frameborder="no" width="770" height="399" scrolling="no"></iframe>
   
    <table bgcolor="#99FF66" width="100%">
    <tr><td>解析<asp:TextBox ID="TB_note" runat="server" Text="" Width="720"></asp:TextBox></td></tr>
        <tr>
            <td>
                满分<asp:TextBox ID="TB_score" runat="server" Text="1" Width="20"></asp:TextBox>
                
                答案
                <asp:TextBox ID="TB_k1" runat="server" Width="38px" ToolTip="请填写答案" onkeypress="return checkKey(event)" onchange="sortKey(this)"></asp:TextBox>
                比值<asp:DropDownList ID="D_A" runat="server">
                    <asp:ListItem Text="+100%" Value="1.00"></asp:ListItem>
                    <asp:ListItem Text="+90%" Value="0.90"></asp:ListItem>
                    <asp:ListItem Text="+80%" Value="0.80"></asp:ListItem>
                    <asp:ListItem Text="+70%" Value="0.70"></asp:ListItem>
                    <asp:ListItem Text="+60%" Value="0.60"></asp:ListItem>
                    <asp:ListItem Text="+50%" Value="0.50"></asp:ListItem>
                    <asp:ListItem Text="+40%" Value="0.40"></asp:ListItem>
                    <asp:ListItem Text="+30%" Value="0.30"></asp:ListItem>
                    <asp:ListItem Text="+20%" Value="0.20"></asp:ListItem>
                    <asp:ListItem Text="+10%" Value="0.10"></asp:ListItem>
                    <asp:ListItem Text="0%" Value="0.00" Selected="True"></asp:ListItem>
                    <asp:ListItem Text="-10%" Value="-0.10"></asp:ListItem>
                    <asp:ListItem Text="-20%" Value="-0.20"></asp:ListItem>
                    <asp:ListItem Text="-30%" Value="-0.30"></asp:ListItem>
                    <asp:ListItem Text="-40%" Value="-0.40"></asp:ListItem>
                    <asp:ListItem Text="-50%" Value="-0.50"></asp:ListItem>
                    <asp:ListItem Text="-60%" Value="-0.60"></asp:ListItem>
                    <asp:ListItem Text="-70%" Value="-0.70"></asp:ListItem>
                    <asp:ListItem Text="-80%" Value="-0.80"></asp:ListItem>
                    <asp:ListItem Text="-90%" Value="-0.90"></asp:ListItem>
                    <asp:ListItem Text="-100%" Value="-1.00"></asp:ListItem>
                </asp:DropDownList>
                 
                <asp:TextBox ID="TB_k2" runat="server" Width="38px" ToolTip="请填写答案" onkeypress="return checkKey(event)" onchange="sortKey(this)"></asp:TextBox>
                比值<asp:DropDownList ID="D_B" runat="server">
                   <asp:ListItem Text="+100%" Value="1.00"></asp:ListItem>
                    <asp:ListItem Text="+90%" Value="0.90"></asp:ListItem>
                    <asp:ListItem Text="+80%" Value="0.80"></asp:ListItem>
                    <asp:ListItem Text="+70%" Value="0.70"></asp:ListItem>
                    <asp:ListItem Text="+60%" Value="0.60"></asp:ListItem>
                    <asp:ListItem Text="+50%" Value="0.50"></asp:ListItem>
                    <asp:ListItem Text="+40%" Value="0.40"></asp:ListItem>
                    <asp:ListItem Text="+30%" Value="0.30"></asp:ListItem>
                    <asp:ListItem Text="+20%" Value="0.20"></asp:ListItem>
                    <asp:ListItem Text="+10%" Value="0.10"></asp:ListItem>
                    <asp:ListItem Text="0%" Value="0.00" Selected="True"></asp:ListItem>
                    <asp:ListItem Text="-10%" Value="-0.10"></asp:ListItem>
                    <asp:ListItem Text="-20%" Value="-0.20"></asp:ListItem>
                    <asp:ListItem Text="-30%" Value="-0.30"></asp:ListItem>
                    <asp:ListItem Text="-40%" Value="-0.40"></asp:ListItem>
                    <asp:ListItem Text="-50%" Value="-0.50"></asp:ListItem>
                    <asp:ListItem Text="-60%" Value="-0.60"></asp:ListItem>
                    <asp:ListItem Text="-70%" Value="-0.70"></asp:ListItem>
                    <asp:ListItem Text="-80%" Value="-0.80"></asp:ListItem>
                    <asp:ListItem Text="-90%" Value="-0.90"></asp:ListItem>
                    <asp:ListItem Text="-100%" Value="-1.00"></asp:ListItem>
                </asp:DropDownList>
                 
                <asp:TextBox ID="TB_k3" runat="server" Width="38px" ToolTip="请填写答案" onkeypress="return checkKey(event)" onchange="sortKey(this)"></asp:TextBox>
                比值<asp:DropDownList ID="D_C" runat="server">
                    <asp:ListItem Text="+100%" Value="1.00"></asp:ListItem>
                    <asp:ListItem Text="+90%" Value="0.90"></asp:ListItem>
                    <asp:ListItem Text="+80%" Value="0.80"></asp:ListItem>
                    <asp:ListItem Text="+70%" Value="0.70"></asp:ListItem>
                    <asp:ListItem Text="+60%" Value="0.60"></asp:ListItem>
                    <asp:ListItem Text="+50%" Value="0.50"></asp:ListItem>
                    <asp:ListItem Text="+40%" Value="0.40"></asp:ListItem>
                    <asp:ListItem Text="+30%" Value="0.30"></asp:ListItem>
                    <asp:ListItem Text="+20%" Value="0.20"></asp:ListItem>
                    <asp:ListItem Text="+10%" Value="0.10"></asp:ListItem>
                    <asp:ListItem Text="0%" Value="0.00" Selected="True"></asp:ListItem>
                    <asp:ListItem Text="-10%" Value="-0.10"></asp:ListItem>
                    <asp:ListItem Text="-20%" Value="-0.20"></asp:ListItem>
                    <asp:ListItem Text="-30%" Value="-0.30"></asp:ListItem>
                    <asp:ListItem Text="-40%" Value="-0.40"></asp:ListItem>
                    <asp:ListItem Text="-50%" Value="-0.50"></asp:ListItem>
                    <asp:ListItem Text="-60%" Value="-0.60"></asp:ListItem>
                    <asp:ListItem Text="-70%" Value="-0.70"></asp:ListItem>
                    <asp:ListItem Text="-80%" Value="-0.80"></asp:ListItem>
                    <asp:ListItem Text="-90%" Value="-0.90"></asp:ListItem>
                    <asp:ListItem Text="-100%" Value="-1.00"></asp:ListItem>
                </asp:DropDownList>
                 
                <asp:TextBox ID="TB_k4" runat="server" Width="38px" ToolTip="请填写答案" onkeypress="return checkKey(event)" onchange="sortKey(this)"></asp:TextBox>
                比值<asp:DropDownList ID="D_D" runat="server">
                    <asp:ListItem Text="+100%" Value="1.00"></asp:ListItem>
                    <asp:ListItem Text="+90%" Value="0.90"></asp:ListItem>
                    <asp:ListItem Text="+80%" Value="0.80"></asp:ListItem>
                    <asp:ListItem Text="+70%" Value="0.70"></asp:ListItem>
                    <asp:ListItem Text="+60%" Value="0.60"></asp:ListItem>
                    <asp:ListItem Text="+50%" Value="0.50"></asp:ListItem>
                    <asp:ListItem Text="+40%" Value="0.40"></asp:ListItem>
                    <asp:ListItem Text="+30%" Value="0.30"></asp:ListItem>
                    <asp:ListItem Text="+20%" Value="0.20"></asp:ListItem>
                    <asp:ListItem Text="+10%" Value="0.10"></asp:ListItem>
                    <asp:ListItem Text="0%" Value="0.00" Selected="True"></asp:ListItem>
                    <asp:ListItem Text="-10%" Value="-0.10"></asp:ListItem>
                    <asp:ListItem Text="-20%" Value="-0.20"></asp:ListItem>
                    <asp:ListItem Text="-30%" Value="-0.30"></asp:ListItem>
                    <asp:ListItem Text="-40%" Value="-0.40"></asp:ListItem>
                    <asp:ListItem Text="-50%" Value="-0.50"></asp:ListItem>
                    <asp:ListItem Text="-60%" Value="-0.60"></asp:ListItem>
                    <asp:ListItem Text="-70%" Value="-0.70"></asp:ListItem>
                    <asp:ListItem Text="-80%" Value="-0.80"></asp:ListItem>
                    <asp:ListItem Text="-90%" Value="-0.90"></asp:ListItem>
                    <asp:ListItem Text="-100%" Value="-1.00"></asp:ListItem>
                </asp:DropDownList>
                其他<asp:DropDownList ID="D_other" runat="server">
                   <asp:ListItem Text="+100%" Value="1.00"></asp:ListItem>
                    <asp:ListItem Text="+90%" Value="0.90"></asp:ListItem>
                    <asp:ListItem Text="+80%" Value="0.80"></asp:ListItem>
                    <asp:ListItem Text="+70%" Value="0.70"></asp:ListItem>
                    <asp:ListItem Text="+60%" Value="0.60"></asp:ListItem>
                    <asp:ListItem Text="+50%" Value="0.50"></asp:ListItem>
                    <asp:ListItem Text="+40%" Value="0.40"></asp:ListItem>
                    <asp:ListItem Text="+30%" Value="0.30"></asp:ListItem>
                    <asp:ListItem Text="+20%" Value="0.20"></asp:ListItem>
                    <asp:ListItem Text="+10%" Value="0.10"></asp:ListItem>
                    <asp:ListItem Text="0%" Value="0.00" Selected="True"></asp:ListItem>
                    <asp:ListItem Text="-10%" Value="-0.10"></asp:ListItem>
                    <asp:ListItem Text="-20%" Value="-0.20"></asp:ListItem>
                    <asp:ListItem Text="-30%" Value="-0.30"></asp:ListItem>
                    <asp:ListItem Text="-40%" Value="-0.40"></asp:ListItem>
                    <asp:ListItem Text="-50%" Value="-0.50"></asp:ListItem>
                    <asp:ListItem Text="-60%" Value="-0.60"></asp:ListItem>
                    <asp:ListItem Text="-70%" Value="-0.70"></asp:ListItem>
                    <asp:ListItem Text="-80%" Value="-0.80"></asp:ListItem>
                    <asp:ListItem Text="-90%" Value="-0.90"></asp:ListItem>
                    <asp:ListItem Text="-100%" Value="-1.00"></asp:ListItem>
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td valign="top">
                难度
                <asp:DropDownList ID="DDLdi" runat="server">
                    <asp:ListItem Value="0">0</asp:ListItem>
                    <asp:ListItem Value="1" Selected="True">1</asp:ListItem>
                    <asp:ListItem Value="2">2</asp:ListItem>
                    <asp:ListItem Value="3">3</asp:ListItem>
                    <asp:ListItem Value="4">4</asp:ListItem>
                    <asp:ListItem Value="5">5</asp:ListItem>
                </asp:DropDownList>
                &nbsp;&nbsp; 选择知识点
                <asp:ListBox ID="LB_keyPoint" runat="server" SelectionMode="Multiple" CssClass="FormText1">
                </asp:ListBox>

                <input type="button" value="保存" class="bigButton" onclick="return editorFrame.getTest();" />
            </td>
        </tr>
    </table>
    </form>
</body>
</html>
