306 lines
9.1 KiB
Plaintext
306 lines
9.1 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 completion}">
|
|
<c:forEach items="${completion}" 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>
|
|
<input id="myAnswerId${index.count}" placeholder="请在此输入答案"></input>
|
|
</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(${completionNum})">提交</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 compleselect=new Array();
|
|
var completrue="";
|
|
$(function() {
|
|
showSelectContent();
|
|
$("#questiontitleId1").css("display","");
|
|
$("#questiontitleId1").nextAll().css("display","none");
|
|
showQuestionSelectId();
|
|
qsiNum(1);
|
|
var completionNum ='${completionNum}';
|
|
if(completionNum == 0){
|
|
jumpExam();
|
|
}
|
|
})
|
|
|
|
function showSelectContent() {
|
|
for(var i=1;i<=completionNum;i++) {
|
|
var nowId = "";
|
|
nowId = "#questiontitleId" + i;
|
|
var contentId = "#myAnswerId" + i;
|
|
var selectAnswer = $(nowId).find("#titleId").find("#selectAnswerId").val();
|
|
if(selectAnswer!=null) {
|
|
$(nowId).find("#titleId").find(contentId).val(selectAnswer);
|
|
}
|
|
}
|
|
}
|
|
|
|
//setTimeout(jumpExam,1000);
|
|
function jumpExam(){
|
|
if(completionNum == 0){
|
|
var add=0;
|
|
var examId = localStorage.getItem("examId");
|
|
var data = {
|
|
fillAnswer:"无",
|
|
fillTrue:"无",
|
|
fillGrade:add,
|
|
examId:examId
|
|
};
|
|
//alert("自己所选的"+singleselect+"正确"+singletrue+"分数"+add+"试卷id"+examId)
|
|
$.ajax({
|
|
type:"POST",
|
|
url:bonuspath +'/backstage/score/temporarySelfUpdate',
|
|
data: JSON.stringify(data),
|
|
dataType:"json",
|
|
contentType:"application/json",
|
|
success:function(data){
|
|
menuClick(5);
|
|
},
|
|
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 completionNum ='${completionNum}';
|
|
|
|
//上一题
|
|
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 = completionNum-didQuestion;
|
|
if(index==completionNum){
|
|
var indexMsg = layer.confirm("<h4 style='color:red'>已做"+didQuestion+"题,还有"+nodoQuestion+"题未做</h4>", {btn: ['提交','取消']},function(){
|
|
var add=$("#add").val();
|
|
var count = parseInt(add)*2;
|
|
var examId = localStorage.getItem("examId");
|
|
var select = "";
|
|
//alert("自己所选的"+compleselect+"正确"+completrue+"分数"+add+"试卷id"+examId)
|
|
console.log(compleselect.length);
|
|
for(var i = 0; i < compleselect.length; i++) {
|
|
if(compleselect[i] == null || compleselect[i] == "") {
|
|
select += "null]";
|
|
} else {
|
|
select += compleselect[i] + "]";
|
|
}
|
|
}
|
|
var typeNum = 4;
|
|
var data = {
|
|
fillAnswer:select,
|
|
fillTrue:completrue,
|
|
fillGrade:count,
|
|
examId:examId,
|
|
typeNum:typeNum
|
|
};
|
|
$.ajax({
|
|
type:"POST",
|
|
url:bonuspath +'/backstage/score/temporarySelfUpdate',
|
|
data: JSON.stringify(data),
|
|
dataType:"json",
|
|
contentType:"application/json",
|
|
success:function(data){
|
|
layer.close(indexMsg);
|
|
menuClick(5);
|
|
},
|
|
error:function(data){
|
|
alert("ajax请求错误!");
|
|
}
|
|
})
|
|
});
|
|
qsiNum(index);
|
|
}else{
|
|
var nowindex = index+1;
|
|
goIndexQuestion(nowindex);
|
|
qsiNum(nowindex);
|
|
judgeDid(nowindex);
|
|
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<=completionNum;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<=completionNum;i++){
|
|
//var nowId = "";
|
|
var flage = false;
|
|
var myAnswerId = "#myAnswerId" + i;
|
|
var myAnswer = $(myAnswerId).val();
|
|
if(myAnswer != null && myAnswer != "") {
|
|
flage = true;
|
|
didQuestion++;
|
|
}
|
|
/* var num = 0;
|
|
nowId = "#questiontitleId"+i;
|
|
for(var j=1;j<=5;j++){
|
|
var selectNowId = "#selectContent"+i+"-"+j;
|
|
flage = $(nowId).find(selectNowId).find('input[type="checkbox"]').prop("checked");
|
|
if(flage){
|
|
num++;
|
|
}
|
|
} */
|
|
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 multtrue="";
|
|
// 错误数
|
|
var sub = 0;
|
|
for(var i=1;i<=completionNum;i++){
|
|
var nowId = "";
|
|
var flage = false;
|
|
var num = 0;
|
|
var selectAnswer = 0;
|
|
var trueGrade = 0;
|
|
nowId = "#questiontitleId"+i;
|
|
var trueAnswer = $(nowId).find("#titleId").find("#answerId").val(); // 第i题的正确答案
|
|
var questionId = $(nowId).find('#titleId').find('#questionId').val();
|
|
//trueAnswer = trueAnswer.replace(/;/g, ',');
|
|
multtrue = trueAnswer;
|
|
completrue = multtrue;
|
|
var data = trueAnswer.split(";");
|
|
var contentnum = data.length;
|
|
var myAnswerId = "#myAnswerId" + i;
|
|
var myAnswer = $(myAnswerId).val(); //第i题的所做答案
|
|
compleselect[i-1]=questionId+"-"+myAnswer;
|
|
var flag = false;
|
|
for(var d of data) {
|
|
var contentl = d.split("|");
|
|
for(var contentll of contentl){
|
|
if(myAnswer.indexOf(contentll)>-1 && contentll!=""){
|
|
num++;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if(num==contentnum) {
|
|
add++;
|
|
trueGrade = 2;
|
|
compleselect[i-1] = questionId+"-"+myAnswer+"-"+trueGrade;
|
|
} else {
|
|
sub++;
|
|
trueGrade = 0;
|
|
compleselect[i-1] = questionId+"-"+myAnswer+"-"+trueGrade;
|
|
}
|
|
}
|
|
//console.log("正确多少题:",add);
|
|
//console.log("错误多少题:",sub);
|
|
$("#add").attr("value",add);
|
|
$("#sub").attr("value",sub);
|
|
}
|
|
|
|
</script>
|
|
</body>
|
|
</html> |