 <%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ 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/swfupload/swfupload.js"></script>
<script type="text/javascript" src="${ctx}/resources/js/swfupload/swfupload.queue.js"></script>
<script type="text/javascript" src="${ctx}/resources/js/swfupload/import.jsp"></script>
<script type="text/javascript" src="${ctx}/resources/ckeditor4.4.7/ckeditor.js"></script>
<script type="text/javascript" src="${ctx}/resources/js/jquery.alerts.js"></script>
<script type="text/javascript" src="${ctx}/resources/js/question/add.jsp"></script>
<script language="javascript" type="text/javascript" src="${ctx}/resources/js/My97DatePicker/WdatePicker.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">
			var swfu;
			function load() {
				var id=${question.typeId};
				if(id=="1"){
					$("#Choose").show();
			        $(".RadioContent").show();
			        $("#RadioContent").hide();
			        $(".CheckboxContent").hide();
			        $("#answer-content").hide();
			        $(".radioAdd").html("");
				}else if(id=="2"){
					$("#Choose").show();
			        $(".CheckboxContent").show();
			        $("#CheckboxContent").hide();
			        $(".RadioContent").hide();
			        $("#answer-content").hide();
			        $(".checkboxAdd").html("");
				}else{
					$("#answer-content").show();
					$("#Choose").hide();
				}
				
				
				swfu = new SWFUpload({
					post_params: {"name" : "huliang"},
					 upload_url :"${ctx}/uploadFile",
					 use_query_string : false,
					 
					// File Upload Settings
					file_size_limit : "10 MB",	// 1000MB
					file_types : "*.*",
					file_types_description : "所有文件",
					file_upload_limit : "0",
									
					file_queue_error_handler : fileQueueError,
					file_dialog_complete_handler : fileDialogComplete,//选择好文件后提交
					file_queued_handler : AccessoryFileQueued,
					upload_progress_handler : uploadProgress,
					upload_error_handler : uploadError,
					upload_success_handler : uploadSuccess,
					upload_complete_handler : uploadComplete,
	
					// Button Settings
					button_image_url : '${ctx}/resources/images/SmallSpyGlassWithTransperancy_17x18.png',
					button_placeholder_id : "spanButtonPlaceholder",
					button_width: 180,
					button_height: 18,
					button_text : '<span class="button">添加附件 <span class="buttonSmall">(单个文件最大10 MB)</span></span>',
					button_text_style : '.button { font-family: Helvetica, Arial, sans-serif; font-size: 12px; } .buttonSmall { font-size: 10px; color: #ff0000;}',
					button_text_top_padding: 0,
					button_text_left_padding: 18,
					button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
					button_cursor: SWFUpload.CURSOR.HAND,
					
					// Flash Settings
					flash_url : '${ctx}/resources/js/swfupload/swfupload.swf',
	
					custom_settings : {
						upload_target : "divFileProgressContainer"
					},
					// Debug Settings
					debug: false,  //是否显示调试窗口
				});
			};

		</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"  >
			<input id="questionId" type="hidden" value="${question.id}"/>
			<input id="statusCode" type="hidden" value="${question.statusCode}"/>
			<input id="questionType" type="hidden" value="${question.typeId}"/>
			<div class="questions" style="margin:0;padding-top:10px;">
			    <table style="width:30%;float:left;" class="label-table">
						<tr>
							<td class="label-table-label">课程<span style="color:red">*</span></td>
							<td class="qBox label-table-content">
								<select  id="course" name="courseId" style="height: auto;" onchange="courseChange('${ctx}','${web_session_role.id }')" class="validate[groupRequired[courseId]] text-input">
									<option value="">请选择</option>
									<c:forEach items="${courses}" var="course">
										<c:choose>
											<c:when test="${course.id==question.courseId}">
												<option value="${course.id}" selected="selected">${course.code}-${course.name}</option>
											</c:when>
											<c:otherwise>
												<option value="${course.id}">${course.code}-${course.name}</option>
											</c:otherwise>
										</c:choose>
									</c:forEach>
								</select>
								<input id="subjectId" name="subjectId" type="hidden"/>
							</td>
						</tr>

						<tr>
							<td class="label-table-label">教材<span style="color:red">*</span></td>
							<td class="qBox label-table-content">
								<select id="bookId" name="bookId" class="validate[groupRequired[bookId]] text-input" style="height: auto;">
									<option value="">请选择</option>
									<c:forEach items="${ls_book}" var="book">
										<c:choose>
											<c:when test="${book.id==question.bookId}">
												<option value="${book.id}" selected="selected">${book.name}</option>
											</c:when>
											<c:otherwise>
												<option value="${book.id}">${book.name}</option>
											</c:otherwise>
										</c:choose>
									</c:forEach>
								</select>
							</td>
						</tr>
						
						<tr>
							<td class="label-table-label">题型<span style="color:red">*</span></td>
							<td class="qBox label-table-content">
								<select id="typeId" name="typeId" class="validate[groupRequired[typeId]] text-input" style="height: auto;" onchange="questionChange('edit')">
									<option value="0">请选择</option>
									<c:forEach items="${ls_questionType}" var="questionType">
										<c:choose>
											<c:when test="${questionType.id==question.typeId}">
												<option value="${questionType.id}" selected="selected">${questionType.name}</option>
											</c:when>
											<c:otherwise>
												<option value="${questionType.id}">${questionType.name}</option>
											</c:otherwise>
										</c:choose>
									</c:forEach>
								</select>
							</td>
						</tr>
						
						<tr>
							<td class="label-table-label">考核要求</td>
							<td class="qBox label-table-content">
								<input  type="radio" name="assessmentDemand" value="A" ${(question.assessmentDemand=='A')?'checked':'' }/>重点内容 &nbsp; &nbsp; &nbsp; 
								<input  type="radio" name="assessmentDemand" value="B" ${(question.assessmentDemand=='B')?'checked':'' }/>次重要内容  &nbsp; &nbsp; &nbsp; 
								<input  type="radio" name="assessmentDemand" value="C" ${(question.assessmentDemand=='C')?'checked':'' }/>一般内容 
							</td>
						</tr>
						<tr>
							<td class="label-table-label">预计难度</td>
							<td class="qBox label-table-content">
								<input  type="radio" name="estimateDifficultyCode" id="estimateDifficultyCode" value="10" ${(question.estimateDifficultyCode=='10')?'checked':'' }/>易&nbsp; &nbsp; &nbsp; &nbsp;
								<input  type="radio" name="estimateDifficultyCode" id="estimateDifficultyCode" value="20" ${(question.estimateDifficultyCode=='20')?'checked':'' }/>中等偏易  &nbsp; &nbsp; &nbsp; &nbsp;
								<input  type="radio" name="estimateDifficultyCode" id="estimateDifficultyCode" value="30" ${(question.estimateDifficultyCode=='30')?'checked':'' }/>中等偏难&nbsp; &nbsp; &nbsp; &nbsp;
								<input  type="radio" name="estimateDifficultyCode" id="estimateDifficultyCode" value="40" ${(question.estimateDifficultyCode=='40')?'checked':'' }/>难
							</td>
						</tr>
						<tr>
							<td class="label-table-label">认知层次</td>
							<td class="qBox label-table-content">
							    <div>
									<input  type="radio" name="abilityCode" value="A" ${(question.abilityCode=='A')?'checked':'' }/>识记&nbsp; &nbsp; &nbsp; 
									<input  type="radio" name="abilityCode"  value="B" ${(question.abilityCode=='B')?'checked':'' }/>理解  &nbsp; &nbsp; &nbsp;
							    </div>
								<div style="margin-top:5px;">
									<input  type="radio" name="abilityCode" value="C" ${(question.abilityCode=='C')?'checked':'' }/>简单应用&nbsp; &nbsp; &nbsp;
									<input  type="radio" name="abilityCode"  value="D" ${(question.abilityCode=='D')?'checked':'' }/>综合应用
								</div>
							</td>
						</tr>
						<tr>
							<td class="label-table-label">命题人<span style="color:red">*</span></td>
							<td class="qBox label-table-content">
								<input type="hidden" id="createdBy" name="createdBy"  value="${user.id}"/>
								<select name="setBy" id="setBy" class="text-input" style="height: auto;">
									<c:choose>
										<c:when test="${allTeacher!=null}">
											<c:forEach items="${allTeacher}" var="teacher">
												<c:choose>
													<c:when test="${teacher.name==question.setTeacherName}">
														<option value="${teacher.id}" selected="selected">${teacher.name}</option>
													</c:when>
													<c:otherwise>
														<option value="${teacher.id}" >${teacher.name}</option>													
													</c:otherwise>
												</c:choose>
											</c:forEach>
										</c:when>
										<c:otherwise>
											<option value="${question.createdBy}">${question.setTeacherName}</option>
										</c:otherwise>
									</c:choose>							
								</select>
								<!--  <input type="text" style="display: none" name="createdBy" value="${web_session_user.name }"/>-->
							</td>
						</tr>
						<tr>
							<td class="label-table-label">命题时间<span style="color:red">*</span></td>
							<td class="qBox label-table-content">
								<input type="text" id="setTime" name="setTime" class="validate[required] text-input" onclick='WdatePicker()'   readonly="readonly" value="<fmt:formatDate value="${question.setTime}" type="both" />"/>
							</td>
						</tr>
						<tr>
						    <td class="label-table-label">备注</td>
                            <td class="qBox label-table-content">
                                <textarea rows="1" cols="2" style="height:38px; width:200px;" name="remark" id="remark" class="validate[maxSize[250]]">${question.remark}</textarea>
                            </td>
						</tr>
			    </table>
				<table style="width:60%;float:left;margin-left:10px;" class="label-table">
					<tbody>
						<tr>
							<td class="label-table-label">满分值<span style="color:red">*</span></td>
							<td class="qBox label-table-content">
								<input type="text" name="score" id="score" class="validate[required,custom[integer],max[150],min[0]] text-input"  style="width:30px;" maxlength="3" value="${question.score}"/>
							</td>
						    <td class="label-table-label">知识点</td>
						    <td class="qBox label-table-content">
                                 <input type="text" id="chapter" name="chapter" class="validate[required,custom[integer],maxSize[2]] text-input" style="width:30px;" value="${question.chapter}"/>&nbsp;章<span style="color:red">*</span>&nbsp;&nbsp;&nbsp;
                                 <input type="text" id="section" name="section" class="text-input validate[custom[integer],maxSize[3]]" style="width:30px;"  value="${question.section}"/>&nbsp;节&nbsp;&nbsp;&nbsp;
                                 <input type="text" id="item" name="item" class="text-input validate[custom[integer],maxSize[4]]" style="width:30px;"  value="${question.item}"/>&nbsp;目&nbsp;&nbsp;&nbsp;
                                 <input type="text" id="ye" name="page" class="text-input validate[custom[integer],maxSize[5]]"  style="width:30px;" value="${question.page}"/>&nbsp;页
                            </td>
						</tr>
						<tr>
							<td class="label-table-label">题干*</td>
							<td colspan="3" class="qBox label-table-content">
								<div id="body-content" class="box-content" field="body" name="题干" title="点击输入内容" contenteditable="true" style="height:100px;">
									${question.body }
								</div>
							</td>
						</tr>
						<tr id="answer-tr">
							<td class="label-table-label" id="answer_td">选项及答案*</td>
							<td colspan="3" class="qBox label-table-content">
								<div id="answer-content" class="box-content" field="answer" name="选项及答案" title="点击输入内容"  contenteditable="true" style="height:120px;">
									${question.answer}
								</div>
								<div class="container" id="container">
									<div id="Choose" style="display: none">
									<div class="panel-body">
										<c:if test="${question.typeId==1}">
											<div class="RadioContent">
												<table style="width:100%">													
													<c:forEach items="${options}" var="option">
														<tr style="margin-bottom: 10px;">
															<td style="width:30px;">
																<c:choose>
																	<c:when test="${option.isCorrectOption==1}">
																		<input	type="radio" name="optionsRadios" value="${option.optionNoString}" class="validate[required] radio" checked="checked"/>${option.optionNoString}.
																		<input type="hidden" id="${option.optionNoString}_radio_id" value="${option.id}"/>
																	</c:when>
																	<c:otherwise>
																		<input	type="radio" name="optionsRadios" value="${option.optionNoString}" class="validate[required] radio"/>${option.optionNoString}.
																		<input type="hidden" id="${option.optionNoString}_radio_id" value="${option.id}"/>
																	</c:otherwise>
																</c:choose>
															</td>
															<td>
																<div class="col-lg-5 col-sm-5" id="${option.optionNoString}_radio_input" contenteditable="true" style="height:25px;">
																	${option.content}
																</div>
															</td>
														</tr>
													</c:forEach>
												</table>
											</div>
										</c:if>
										</div> 
										<c:if test="${question.typeId==2}">
											<div class="CheckboxContent">
												<table style="width:100%">
													<c:forEach items="${options}" var="option">
														<tr style="margin-bottom: 10px;">
															<td style="width:30px;">
																<c:choose>
																	<c:when test="${option.isCorrectOption==1}">
																		<input type="checkbox" name="optionsCKs"value="${option.optionNoString}" class="validate[required] checkbox " checked="checked" />${option.optionNoString}. 
																		<input type="hidden" id="${option.optionNoString}_checkbox_id" value="${option.id}"/>
																	</c:when>
																	<c:otherwise>
																		<input type="checkbox" name="optionsCKs"value="${option.optionNoString}" class="validate[required] checkbox "/>${option.optionNoString}. 
																		<input type="hidden" id="${option.optionNoString}_checkbox_id" value="${option.id}"/>
																	</c:otherwise>
																</c:choose>
															</td>
															<td>
																<div class="col-lg-5 col-sm-5" id="${option.optionNoString}_checkbox_input" contenteditable="true" style="height:25px;">
																	${option.content}
																</div>
															</td>
														</tr>
													</c:forEach>
												</table>
											</div>
										</c:if>
									</div>
								</div>
							</td>
						</tr>
						<tr>
							<td class="label-table-label" >题卡</td>
							<td colspan="3" class="qBox label-table-content">
								<div id="answerSheet" class="box-content " field="answerSheet" name="题卡" title="点击输入内容" contenteditable="true" style="height:50px;">
									${question.answerSheet}
								</div>
							</td>
						</tr>
						<tr id="answer-tr">
						  <td class="label-table-label" >附件</td>
						  <td colspan="3" class="qBox label-table-content">
						  	 	<div id="content">
									<div style="display: inline;   padding: 2px;">
										<span id="spanButtonPlaceholder"></span>
										<!--  <input id="btnCancel" type="button" value="取消所有上传"
											onclick="cancelUpload('infoTable');" disabled="disabled" class="btn3_mouseout" />-->
									</div>
									<div id="divFileProgressContainer" style="height: 20px;"></div>
									<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>
											<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;"><font color='red'>已上传成功</font></td>
												<td width="150px;"><a href="">删除</a></td>
											</tr>
										</c:forEach>
									</table>
									</div>
								</div>
						  </td>
						</tr>
					</tbody>
				</table>
			</div>
			</form>
			</div>
			<div class="page-footer">
				<input type="button" class="btn" onclick="update('${ctx }')" value="编辑并保存" />
				<input type="button" class="btn" onclick="window.location.href='${ctx}/question/view/${question.id}'" value="取消" />
			</div>
		</div>
	</div>
	
	<div id="editor-dialog" class="dialog hd">
		<div class="dialog-header" id="dialog-header">内容编辑</div>
		<div class="dialog-body">
		<textarea id="textarea"></textarea></div>
		<div class="dialog-footer">
			<input type="button" class="btn" id="save-button" value="保存" />
			<input type="button" class="btn close" value="关闭" />
		</div>
	</div>
	
	<script type="text/javascript">
		$(function() {
			//表单验证
		    $("#questionUpdateFrm").validationEngine(); 
		});
	</script>
</body>
</html>