<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="/WEB-INF/taglib/c.tld" prefix="c"%>
<%@ include file="../common/init.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="../common/top.jsp"%>
</head>
<body class="easyui-layout">
	<%@ include file="../common/header.jsp"%>
	<%@ include file="../common/menu.jsp"%>
	<div data-options="region:'center',title:'首页 -<a href=>【参数设置】</a>- 参数列表'">
          <div class="subjcethead-cont row-fluid" style="margin-top: 10px;margin-left: 10px;">
              <div class="span11">
                  <div class="subjcethead-cont-right-content">
                      <div class="right-content-tab">
                         <table class="table table-bordered table-hover">
                          <thead>
                            <tr>
                              <th style="text-align: center;">块名称</th>
                              <th style="text-align: center;">总分</th>
                              <th style="text-align: center;">总人数</th>
                              <th style="text-align: center;">未评人数</th>
                              <th style="text-align: center;">复评比例</th>
                              <th style="text-align: center;">自评频度</th>
                              <th style="text-align: center;">标准卷频度</th>
                              <th style="text-align: center;">误差值</th>
                              <th style="text-align: center;">均分任务</th>
                            </tr>
                          </thead>
                          <tbody>
                          	<c:forEach items="${subjectiveBlockList }" var="block">
                          		<tr>
									<td style="text-align: center;">${block.title }<input type='hidden' id='id' name='id' value="${block.id }"/></td>
									<td style="text-align: center;">${block.totalScore }</td>
									<td style="text-align: center;">${block.totalCount }</td>
									<td style="text-align: center;">${block.toDispatchedCount }</td>
									<td style="text-align: center;"><input class='input-mini' id='reMarkPercent' name='reMarkPercent' type='text' value="${block.reMarkPercent }"></td>
									<td style="text-align: center;"><input class='input-mini' id='markSelfFrequency' name='markSelfFrequency' type='text' value="${block.markSelfFrequency }"></td>
									<td style="text-align: center;"><input class='input-mini' id='standardFrequency' name='standardFrequency' type='text' value="${block.standardFrequency }"></td>
									<td style="text-align: center;"><input class='input-mini' id='mistakeValue' name='mistakeValue' type='text' value="${block.mistakeValue }"></td>
									<td style="text-align: center;"><div id="isAvg" class="btn-group"><button class="btn  btn-small <c:if test="${block.avg==false }"> btn-success</c:if>" onclick="changeAvg(this)" value="false">否</button><button class="btn  btn-small <c:if test="${block.avg==true }"> btn-success</c:if>" onclick="changeAvg(this)" value="true">是</button></div></td>
								</tr>
                          	</c:forEach>
                          </tbody>
                        </table>
	                      <div id="stage">
	                      	<table class="table table-bordered table-hover">
	                      		<tr>
	                      			<td style="font-weight: bolder;text-align: right; width: 19.5%;">当前科目评卷状态</td>
	                      			<td>${markSubjectStatus}</td>
	                      		</tr>
	                      		<tr>
	                      			<td style="font-weight: bolder; text-align: right;">评卷阶段</td>
	                      			<td>
	                      				    <div id="stages" class="btn-group">
											    <button id="stage0" class="btn  btn-small <c:if test="${stage==0}"> btn-success</c:if>" <c:if test="${stage>0}">disabled='disabled'</c:if> onclick="changeStage(this)">未开始</button>
											    <button id="stage1" class="btn  btn-small <c:if test="${stage==1}"> btn-success</c:if>" <c:if test="${stage>1}">disabled='disabled'</c:if> onclick="changeStage(this)">样卷</button>
											    <button id ="stage2" class="btn  btn-small <c:if test="${stage==2}"> btn-success</c:if>" <c:if test="${stage>2}">disabled='disabled'</c:if> onclick="changeStage(this)">试评</button>
											    <button id="stage3" class="btn  btn-small <c:if test="${stage==3}"> btn-success</c:if>" <c:if test="${stage>3}">disabled='disabled'</c:if> onclick="changeStage(this)">正评</button>
										    </div>
	                      			</td>
	                      		</tr>
		                    </table>
	                      </div>
                        <button id="distributeButton"  class="btn btn-primary" type="button">保&nbsp;存</button>
                      </div>
                  </div>
              </div>
          </div>
    </div>
</body>
<script type="text/javascript">
$("#distributeButton").click(function(){
	  var data = [];
	  var status={};
	  $("#stages").find(".btn-success").each(function(){
		  var buttonId = $(this).attr("id");
		  var stage = {};
		  stage.value = buttonId.substr(buttonId.length-1,buttonId.length);
		  data.push(stage);
	  });
	  
	  $("tbody:eq(0) tr").each(function(i){
		  var obj = {};
		  obj.id = $(this).find('[name="id"]').val(); 
		  obj.reMarkPercent = $(this).find('[name="reMarkPercent"]').val();
		  obj.markSelfFrequency = $(this).find('[name="markSelfFrequency"]').val();
		  obj.standardFrequency = $(this).find('[name="standardFrequency"]').val();
		  obj.mistakeValue = $(this).find('[name="mistakeValue"]').val();
		  obj.avg = $(this).find(".btn-success").val();
		  data.push(obj);
	  });
	  var url='${ctx}/subjectheader/distribute/do.json';
	    $.ajax( {
	    url : url,
	    type : "POST", 
	    dataType:"json",
	    contentType:'application/json;charset=UTF-8',
	    data:JSON.stringify(data),
	    success : function(val) {
	   		$.messager.alert('消息',"保存成功！");
	    },
		error:function(e){
	    	$.messager.alert("异常","保存失败，通信发生错误，请与管理员联系！");
	    }
	    })
});
function changeStage(obj){
	$("#stages").find("button").each(function(){
		  $(this).removeClass("btn-success");
	  });
	$(obj).addClass("btn-success");
}

function changeAvg(obj){
	$(obj).parent().find("button").each(function(){
		  $(this).removeClass("btn-success");
	  });
	$(obj).addClass("btn-success");
}
</script>
</html>
