<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
<%@ include file="../common/init.jsp"%>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>试题中心</title>
<%@ include file="../common/top.jsp"%>
<link href="${ctx}/resources/css/main.css" rel="stylesheet"type="text/css" />

<link rel='stylesheet' href='${ctx}/resources/css/user-center-style.css'type='text/css' media='screen' />
<script type="text/javascript" src="${ctx}/resources/js/jquery.alerts.js"></script>
<script type="text/javascript" src="${ctx}/resources/js/question/edit.js"></script>
<%@ include file="../common/validation.jsp"%>
<style type="text/css">
.my-dialog .ui-dialog-titlebar-close{display: none;
 }
.select-knowledge{width:auto;}
.row {
	width: 100%
}

.row div,label {
	float: left;
}
</style>
<script type="text/javascript">
	function copyAdd(id){
		var obj = {
				"id" : id
			};
		var Question = JSON.stringify(obj);
		$.ajax({
			type : "POST",
			url : "${ctx }/question/copyAdd",
			data : Question, 
			contentType : "application/json; charset=utf-8",
			dataType : "json",
			success : function(callback) {
				callback = eval(callback);
				alert("复制新增成功!");
				//$.messager.alert('提示','复制新增成功!');
				location.href="${ctx}/question/view/"+callback.id;
			}
		});
	}
	
	function load(){
		var role="${role.code}";
		var status="${question.statusCode}";
		var setBy="${question.setBy}";
		var userId="${user.id}";
		if((role=="QUESTION_INPUTER"||role=="PROPOSITION_TEACHER")&&(status=="草稿"||status=="初审不通过"||status=="终审不通过")){
			$("#editBtn").show();
		}else if((role=="AUDIT_TEACHER")&&(status=="草稿"||status=="初审不通过"||status=="终审不通过")&&(setBy==userId)){
			$("#editBtn").show();
		}else if((role=="AUDIT_TEACHER")&&(status=="待审核"||status=="初审通过")&&(setBy!=userId)){
			$("#editBtn").show();
		}else if(role=="SECRETARY"&&(status=="待审核"||status=="初审通过")){
			$("#editBtn").show();
		}
	}
</script>
</head>

<body onload="load()">
	<%@ include file="../common/header.jsp"%>
	<div id="content">
		<%@ include file="../common/sub_menu.jsp"%>
		<div id="page">
		<div class="page-header">查看试题</div>
		<div class="page-body">
			<form id="questionUpdateFrm" action="${ctx}/question/insert" method="post"  >
			<div class="questions" style="margin:0;padding-top:10px;">
				<table style="width:99%" class="label-table">
					<tbody>
						<tr>
							<td  style="width:15%;"colspan="1" class="label-table-label">试题编号</td>
							<td class="qBox label-table-content">${question.id}</td>
							<td  style="width:15%;"colspan="1" class="label-table-label">题号</td>
							<td class="qBox label-table-content">${question.questionNo}</td>
							<td  style="width:15%;"colspan="1" class="label-table-label">状态</td>
							<td class="qBox label-table-content">${question.statusCode}</td>
						</tr>
						<tr>
							<td  style="width:15%;"colspan="1" class="label-table-label">课程</td>
							<td class="qBox label-table-content">
									${course.name}
							</td>
							<td class="label-table-label">题型</td>
							<td class="qBox label-table-content">
									${questionType.name}
							</td>
							<td class="label-table-label">教材</td>
							<td class="qBox label-table-content">
								${book.name}
							</td>
						</tr>
						<tr>
							<td class="label-table-label">考核要求</td>
							<td class="qBox label-table-content">
								<c:choose>
									<c:when test="${question.assessmentDemand=='A' }">
										重点内容
									</c:when>
									<c:when test="${question.assessmentDemand=='B'}">
										次重要内容
									</c:when>
									<c:when test="${question.assessmentDemand=='C'}">
										一般内容
									</c:when>
								</c:choose>
							</td>
							<td class="label-table-label">预计难度</td>
							<td class="qBox label-table-content">
								<c:choose>
									<c:when test="${question.estimateDifficultyCode==10}">
										易
									</c:when>
									<c:when test="${question.estimateDifficultyCode==20}">
										中等偏易 
									</c:when>
									<c:when test="${question.estimateDifficultyCode==30}">
										中等偏难
									</c:when>
									<c:when test="${question.estimateDifficultyCode==40}">
										难
									</c:when>
								</c:choose>	
							</td>
							<td class="label-table-label">认知层次</td>
							<td class="qBox label-table-content">
								<c:choose>
									<c:when test="${question.abilityCode=='A' }">
										识记
									</c:when>
									<c:when test="${question.abilityCode=='B' }">
										理解 
									</c:when>
									<c:when test="${question.abilityCode=='C' }">
										简单应用
									</c:when>
									<c:when test="${question.abilityCode=='D' }">
										综合应用
									</c:when>
								</c:choose>
							</td>
						</tr>
						<tr>
							<td class="label-table-label">满分值</td>
							<td class="qBox label-table-content">
								${question.score}
							</td>
							<td class="label-table-label">命题人</td>
							<td class="qBox label-table-content">
								${question.setTeacherName}
							</td>
							<td class="label-table-label">命题时间</td>
							<td class="qBox label-table-content">
							<fmt:formatDate value="${question.setTime}" type="both" />
								
							</td>
						</tr>
						<tr>
						    <td class="label-table-label">知识点</td>
						    <td class="qBox label-table-content">
                                 ${question.chapter}&nbsp;章&nbsp;&nbsp;&nbsp;
                                 ${question.section}&nbsp;节&nbsp;&nbsp;&nbsp;
                                 ${question.item}&nbsp;目&nbsp;&nbsp;&nbsp;
                                 ${question.page}&nbsp;页
                            </td>
                            <td class="label-table-label">备注</td>
                            <td colspan="3" class="qBox label-table-content">
                            	${question.remark}
                            </td>
						</tr>
						<tr>
							<td class="label-table-label">题干</td>
							<td colspan="5" class="qBox label-table-content">
								<div id="body-content" class="box-content" >${question.body}</div>
							</td>
						</tr>
						<tr id="answer-tr">
							<td class="label-table-label">选项及答案</td>
							<td colspan="5" class="qBox label-table-content">
								<div id="answer-div">
									<c:choose>
										<c:when test="${question.typeId!=1&&question.typeId!=2}">
											<div id="answer-content" class="box-content">${question.answer}</div>
										</c:when>
										<c:otherwise>
											<c:forEach items="${options}" var="option">
												<div id="options">
													<div id="singleOption">
														<c:choose>
															<c:when test="${option.isCorrectOption==1}">
																<label id="radio" style="color: red">
																	${option.optionNoString}.
																</label>
															</c:when>
															<c:otherwise>
																<label id="radio" >
																	${option.optionNoString}.
																</label>
															</c:otherwise>
														</c:choose>
														
														<div id="">${option.contentHtml}</div>
													</div>
												</div>
											</c:forEach>
										</c:otherwise>
									</c:choose>
								</div>
							</td>
						</tr>
						<tr>
							<td class="label-table-label" >题卡</td>
							<td colspan="5" class="qBox label-table-content">
								<div id="answerSheet" class="box-content " >${question.answerSheet}</div>
							</td>
						</tr>
						<tr id="answer-tr">
						  <td class="label-table-label" >附件</td>
						  <td colspan="5" class="qBox label-table-content">
						  	 	<div id="content">
									<div id="thumbnails">
									<table id="infoTable" border="0" width="530" style="display: inline;  padding: 2px;margin-top:8px;">
										<tr bgcolor="CCCCCC" align="center">
											<td width="150PX;">文件名</td>
											<td width="150PX;">文件大小(字节)</td>
											<td width="150PX;">操作</td>
										</tr>
										<c:forEach items="${atts}" var="att">
											<tr align="center">
											<td width="150PX;">${att.name}</td>
											<td width="150PX;">${att.size}</td>
											<td width="150PX;"><a href='${ctx}/downLoadFile/${att.id}'>下载</a></td>
										</tr>
										</c:forEach>
									</table>
									</div>
								</div>
						  </td>
						</tr>
					</tbody>
				</table>
			</div>
			</form>
			</div>
			<div class="page-footer" id="page-footer" >
				<input type="button" class="btn" onclick="window.location.href='${ctx}/question/edit/${question.id}'" value="编辑" id="editBtn" style="display: none"/>
				<security:authorize ifNotGranted="SECRETARY">
					<input type="button" class="btn" onclick="copyAdd(${question.id})" value="复制新增" />
				</security:authorize>
			</div>
		</div> 
	</div>
</body>
</html>