341 lines
9.5 KiB
Plaintext
341 lines
9.5 KiB
Plaintext
<%@ page contentType="text/html;charset=UTF-8" %>
|
|
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
|
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
|
<%@ taglib prefix="fns" uri="/WEB-INF/tlds/fns.tld" %>
|
|
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<%@include file="../baseset.jsp" %>
|
|
<%@include file="../systemset.jsp" %>
|
|
<script src="${bonuspath}/static/plugins/layer/2.1/extend/layer.ext.js"></script>
|
|
<title></title>
|
|
<style type="text/css">
|
|
|
|
</style>
|
|
|
|
</head>
|
|
<body>
|
|
<div class="">
|
|
<div style="font-size: 20px;width: 80%; display: inline-block;">
|
|
<input id="add" value="" type="hidden"/>
|
|
<input id="sub" value="" type="hidden"/>
|
|
<input id="didQuestion" value="" type="hidden"/>
|
|
<c:choose>
|
|
<c:when test="${not empty shortAnswer}">
|
|
<c:forEach items="${shortAnswer}" var="sin" varStatus="index">
|
|
<div id="questiontitleId${index.count}" value="${index.count}" name="questiontitleId">
|
|
<div id="titleId">
|
|
<input id="selectAnswerId" type="hidden" value="${sin.selectAnswer}"/>
|
|
<input id="answerId" type="hidden" value="${sin.answer}"/>
|
|
<input id="questionId" type="hidden" value="${sin.questionId}"/>
|
|
<span>${index.count}</span>、 <span>${sin.content }</span>
|
|
</div>
|
|
<div id="shortAnswer">
|
|
<textarea name="content" style="height: 400px;width: 100%" placeholder="请在此处作答..." rows="6" cols="80" onpropertychange="if(this.scrollHeight>80) this.style.posHeight=this.scrollHeight+5" id="content"></textarea>
|
|
</div>
|
|
|
|
<div style="position: fixed; bottom: 4%; margin-left: 60%;display: inline-flex;">
|
|
<button class="btns" onclick="prevQuestion(${index.count})">上一题</button>
|
|
<button class="btns" onclick="nextQuestion(${index.count})">下一题</button>
|
|
<button class="btns" onclick="submit(${shortAnswerNum})">提交简答题答案</button>
|
|
</div>
|
|
</div>
|
|
</c:forEach>
|
|
</c:when>
|
|
<c:otherwise>
|
|
本专业没有相关题型,系统将于一秒后自动调往下一题型;
|
|
</c:otherwise>
|
|
</c:choose>
|
|
|
|
</div>
|
|
<div style="width: 16%;display: inline-block;position: absolute;padding-left: 1%;font-size: 20px;">
|
|
<div id="questionSelectId">
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
var shorteselect = "";
|
|
var shorttrue = "";
|
|
$(function() {
|
|
showSelectContent();
|
|
$("#questiontitleId1").css("display","");
|
|
$("#questiontitleId1").nextAll().css("display","none");
|
|
showQuestionSelectId();
|
|
qsiNum(1);
|
|
var shortAnswerNum ='${shortAnswerNum}';
|
|
console.log(shortAnswerNum)
|
|
if(shortAnswerNum == 0){
|
|
jumpExam();
|
|
}
|
|
})
|
|
|
|
function showSelectContent() {
|
|
for(var i=1;i<=shortAnswerNum;i++) {
|
|
var nowId = "";
|
|
nowId = "#questiontitleId" + i;
|
|
var selectAnswer = $(nowId).find("#titleId").find("#selectAnswerId").val();
|
|
if(selectAnswer!=null) {
|
|
$(nowId).find("#content").val(selectAnswer);
|
|
}
|
|
}
|
|
}
|
|
|
|
//setTimeout(jumpExam,1000);
|
|
function jumpExam(){
|
|
if(shortAnswerNum == 0){
|
|
var add=0;
|
|
var examId = localStorage.getItem("examId");
|
|
var data = {
|
|
soluAnswer:"无",
|
|
soluTrue:"无",
|
|
soluGrade:add,
|
|
examId:examId
|
|
};
|
|
//alert("自己所选的"+singleselect+"正确"+singletrue+"分数"+add+"试卷id"+examId)
|
|
$.ajax({
|
|
type:"POST",
|
|
url:bonuspath +'/backstage/score/temporaryUpdate',
|
|
data: JSON.stringify(data),
|
|
dataType:"json",
|
|
contentType:"application/json",
|
|
success:function(data){
|
|
menuClick(6);
|
|
},
|
|
error:function(data){
|
|
alert("ajax请求错误!");
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
function dblSelectContent(index,itemNum) {
|
|
var parentId = "#selectContent"+index+"-"+itemNum;
|
|
$(parentId).find('input[type="checkbox"]').prop("checked","checked");
|
|
$(parentId).prevAll('.selectContent').find('input[type="checkbox"]').prop("checked",false);
|
|
$(parentId).nextAll('.selectContent').find('input[type="checkbox"]').prop("checked",false);
|
|
}
|
|
|
|
var shortAnswerNum = '${shortAnswerNum}';
|
|
|
|
//上一题
|
|
function prevQuestion(index) {
|
|
if(index==1){
|
|
var indexMsg = layer.confirm("<h4 style='color:red'>已是第一题,无法再选择上一题!</h4>", {btn: ['确认','取消']},function(){
|
|
layer.close(indexMsg);
|
|
});
|
|
qsiNum(index);
|
|
}else{
|
|
var nowindex = index-1;
|
|
goIndexQuestion(nowindex);
|
|
qsiNum(nowindex);
|
|
judgeDid(nowindex);
|
|
judgeTrue();
|
|
}
|
|
|
|
}
|
|
function submit(index){
|
|
nextQuestion(index);
|
|
}
|
|
//下一题
|
|
function nextQuestion(index) {
|
|
judgeDid(index);
|
|
var didQuestion = $("#didQuestion").val();
|
|
var nodoQuestion = shortAnswerNum-didQuestion;
|
|
if(index==shortAnswerNum){
|
|
var indexMsg = layer.confirm("<h4 style='color:red'>已做"+didQuestion+"题,还有"+nodoQuestion+"题未做</h4>", {btn: ['提交','取消']},function(){
|
|
var add=$("#add").val();
|
|
var examId = localStorage.getItem("examId");
|
|
var typeNum = 5;
|
|
var data = {
|
|
soluAnswer:shorteselect,
|
|
soluTrue:shorttrue,
|
|
soluGrade:add,
|
|
examId:examId,
|
|
typeNum: typeNum
|
|
};
|
|
$.ajax({
|
|
type:"POST",
|
|
url:bonuspath +'/backstage/score/temporaryUpdate',
|
|
data: JSON.stringify(data),
|
|
dataType:"json",
|
|
contentType:"application/json",
|
|
success:function(data){
|
|
layer.close(indexMsg);
|
|
menuClick(6);
|
|
},
|
|
error:function(data){
|
|
alert("ajax请求错误!");
|
|
}
|
|
})
|
|
});
|
|
qsiNum(index);
|
|
}else{
|
|
var nowindex = index+1;
|
|
goIndexQuestion(nowindex);
|
|
qsiNum(nowindex);
|
|
judgeDid(nowindex);
|
|
judgeTrue();
|
|
}
|
|
}
|
|
|
|
// setInterval("saveQuestion()",1000);
|
|
|
|
function saveQuestion() {
|
|
var add=$("#add").val();
|
|
var examId = localStorage.getItem("examId");
|
|
var typeNum = 5;
|
|
var data = {
|
|
soluAnswer:shorteselect,
|
|
soluTrue:shorttrue,
|
|
soluGrade:add,
|
|
examId:examId,
|
|
typeNum: typeNum
|
|
};
|
|
$.ajax({
|
|
type:"POST",
|
|
url:bonuspath +'/backstage/score/temporaryUpdate',
|
|
data: JSON.stringify(data),
|
|
dataType:"json",
|
|
contentType:"application/json",
|
|
success:function(data){
|
|
},
|
|
error:function(data){
|
|
alert("ajax请求错误!");
|
|
}
|
|
})
|
|
//judgeDid(index);
|
|
judgeTrue();
|
|
}
|
|
|
|
//展示index题数的题目
|
|
function goIndexQuestion(index) {
|
|
var nowId = "#questiontitleId"+index;
|
|
$(nowId).css("display","");
|
|
$(nowId).nextAll().css("display","none");
|
|
$(nowId).prevAll().css("display","none");
|
|
}
|
|
//展示所有题数
|
|
function showQuestionSelectId() {
|
|
|
|
var selectHtml = "";
|
|
for(var i=1;i<=shortAnswerNum;i++){
|
|
var showQuestionSelect = document.getElementById("questionSelectId");
|
|
if( i%5 == 0 ){
|
|
selectHtml += "<div id='qsiNumId"+i+"' onclick='qsiNum("+i+")' style='border: 1px solid #000;display:inline-block;width:15%;text-align:center;'>"+i+"</div><br>"
|
|
}else{
|
|
selectHtml += "<div id='qsiNumId"+i+"' onclick='qsiNum("+i+")' style='border: 1px solid #000;display:inline-block;width:15%;text-align:center;margin-right:4%;margin-bottom: 4%;'>"+i+"</div>"
|
|
}
|
|
|
|
showQuestionSelect.innerHTML = selectHtml;
|
|
}
|
|
}
|
|
function qsiNum(index) {
|
|
var indexI = "#qsiNumId"+index;
|
|
$(indexI).css("background-color",'#c66778');
|
|
judgeDid(index);
|
|
judgeTrue();
|
|
goIndexQuestion(index);
|
|
}
|
|
|
|
|
|
|
|
//判断题目是否做了
|
|
function judgeDid(index) {
|
|
var didQuestion = 0;
|
|
for(var i=1;i<=shortAnswerNum;i++){
|
|
var nowId = "";
|
|
var flage = "";
|
|
var num = 0;
|
|
nowId = "#questiontitleId"+i;
|
|
|
|
flage = $(nowId).find("#shortAnswer").find("#content").val();
|
|
if(flage != null && flage != "") {
|
|
didQuestion++;
|
|
}
|
|
|
|
var indexI = "#qsiNumId"+i;
|
|
if(flage!=""){
|
|
$(indexI).css("background-color",'#c6febf');
|
|
}else if(index==i){
|
|
$(indexI).css("background-color",'#c9e1fe');
|
|
}else{
|
|
$(indexI).css("background-color",'#eee');
|
|
}
|
|
}
|
|
$("#didQuestion").attr("value",didQuestion);
|
|
}
|
|
//判断题目是否正确,统计分数
|
|
function judgeTrue() {
|
|
// 得分数
|
|
var add = 0;
|
|
var temp = "";
|
|
var tempT = "";
|
|
for(var i=1;i<=shortAnswerNum;i++){
|
|
var nowId = "";
|
|
var flage = "";
|
|
var num = 0;
|
|
var trueGrade = 0;
|
|
var selectAllContent = "";
|
|
|
|
nowId = "#questiontitleId"+i;
|
|
// 第i题的正确答案
|
|
var trueAnswer = $(nowId).find("#titleId").find("#answerId").val();
|
|
//trueAnswer = trueAnswer.replace(/;/g, ',');
|
|
tempT = trueAnswer;
|
|
//flage = $(nowId).find("#shortAnswer").find("#content").val();
|
|
var flages = $(nowId).find("#shortAnswer").find("#content").val();
|
|
var flagess = flages.split("-");
|
|
if(flagess.length>1){
|
|
for(var i of flagess){
|
|
flage += i + " ";
|
|
}
|
|
}else{
|
|
flage = flages;
|
|
}
|
|
var questionId = $(nowId).find('#titleId').find('#questionId').val();
|
|
if(flage!=""){
|
|
var contentList = trueAnswer.split(";");
|
|
var contentnum = contentList.length;
|
|
for(var contentone of contentList){
|
|
var contentl = contentone.split("|");
|
|
for(var contentll of contentl){
|
|
if(flage.indexOf(contentll)>-1 && contentll!=""){
|
|
num++;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if(num >= contentnum-1){
|
|
add += 5;
|
|
trueGrade = 5;
|
|
}else{
|
|
if(num>=5){
|
|
add += 5;
|
|
trueGrade = 5;
|
|
}else{
|
|
add += num;
|
|
trueGrade = num;
|
|
}
|
|
}
|
|
selectAllContent = questionId + "-" + flage+"-"+trueGrade;
|
|
temp += selectAllContent + "]";
|
|
} else {
|
|
selectAllContent = "null";
|
|
temp += selectAllContent + "]";
|
|
}
|
|
}
|
|
//console.log("正确多少题:",add);
|
|
$("#add").attr("value",add);
|
|
shorttrue = tempT;
|
|
shorteselect = temp;
|
|
}
|
|
|
|
</script>
|
|
</body>
|
|
</html> |