<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>评卷质量监控</title>
	<meta name="decorator" content="default"/>
	<%@include file="/WEB-INF/views/include/head.jsp" %>
	<style type="text/css">.sort{color:#0663A2;cursor:pointer;}</style>
	<script src="${ctxStatic}/echarts/echarts.min.js" type="text/javascript"></script>
</head>
<body>
    <ul class="nav nav-tabs">
        <li class="active"><a href="#">${subject.code}-${subject.name}&nbsp;&nbsp;${group.number}-${group.title}</a></li>
        <li><a href="${ctx}/admin/exam/quality?subjectCode=${subject.code}&groupNumber=${group.number}">返回</a></li>
    </ul>
	<tags:message content="${message}"/>
	<div id="main" style="width: 800px;height:400px;"></div>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>评卷员</th>
				<th>姓名</th>
				<c:forEach items="${scores}" var="score">	
					<th><c:out value="${score}"/>分</th>
				</c:forEach>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${markers}" var="marker">
			<tr>
				<td>${marker.loginName}</td>
				<td>${marker.name}</td>
				<c:forEach items="${scores}" var="score">
					<td>
					<c:if test="${marker.scoreCount[score]!=null}">
					<a href="##" onclick="openTab(${marker.id},${score})">${marker.scoreCount[score] }</a></c:if>
					<c:if test="${marker.scoreCount[score]==null }">0</c:if>
					</td>
				</c:forEach>
			</tr>
		</c:forEach>
		</tbody>
	</table>
<script type="text/javascript">
var groupNumber='${groupNumber}';
var subjectCode='${subjectCode}';
var markerArray= [] ;
var nameList = [];
var scores = ${scores};
/* var scoreArray = new Array();
for(var i=0;scores< scores.length;i++){
	scoreArray.push(scores[i]);
} */
$.post('${ctx}/admin/exam/quality/getChart', {subjectCode: subjectCode,groupNumber:groupNumber}, function(result){
	for(var i=0;i<result.length;i++){
        var marker = result[i];
        var scorePercents= [];
		
		for(var j=0;j< scores.length;j++){
			var key = scores[j];
			if(String(scores[j]).indexOf(".")==-1){
	        	key=scores[j]+".0";
			}
			var percent = marker.scorePercent[key];
        	if(percent==undefined){
        		scorePercents.push(0);
        	}else{
        		scorePercents.push(percent);
        	}
        }
        var option  = {
            name:marker.loginName,
            type:'line',
            data:scorePercents
        }
        markerArray.push(option);
        nameList.push(marker.loginName);
    }
	var myChart = echarts.init(document.getElementById('main'));
	option = {
		    tooltip : {
		        trigger: 'axis'
		    },
		    legend: {
		        x: 100, 
		        data:nameList
		    },
		    toolbox: {
		        show : true
		    },
		    calculable : true,
		    xAxis : [
		        {
		            type : 'category',
		            boundaryGap : false,
		            name :'分值',
		            data : scores
		        }
		    ],
		    yAxis : [
		        {
		            type : 'value',
		            name :'百分比'
		        }
		    ],
		    series : markerArray
		    
		};
	myChart.setOption(option);
});
function openTab(markerId,markerScore){
    window.open('${ctx}/web/admin/exam/quality?subjectCode='+subjectCode+'&markerId='+markerId+'&markerScore='+markerScore,"_blank");    
}
</script>	
</body>
</html>