Examination_system/Examination_system-1/.svn/pristine/a0/a0f3b9427b3b43c4b94e86efb0f...

346 lines
10 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" %>
<title></title>
<style type="text/css">
</style>
</head>
<body>
<div class="">
<input id="add" value="" type="hidden"/>
<input id="sub" value="" type="hidden"/>
<input id="didQuestion" value="" type="hidden"/>
<div style="font-size: 20px;width: 80%; display: inline-block;">
<c:choose>
<c:when test="${not empty single}">
<c:forEach items="${single}" 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>
<c:choose>
<c:when test="${not empty sin.operationContent}">
<c:forEach items="${sin.operationContent}" var="operation" varStatus="item">
<div class="selectContent" onclick="dblSelectContent(${index.count},${item.count})" id="selectContent${index.count}-${item.count }">
<input type="checkbox" value="${operation.id}" ondblclick="dblSelectContent(${index.count},${item.count})"/>
<c:if test="${item.count ==1}">
A:
</c:if>
<c:if test="${item.count ==2}">
B:
</c:if>
<c:if test="${item.count ==3}">
C:
</c:if>
<c:if test="${item.count ==4}">
D:
</c:if>
<span> ${operation.content}</span>
</div>
</c:forEach>
</c:when>
<c:otherwise>
没有相关选项
</c:otherwise>
</c:choose>
<div style="position: fixed; bottom: 4%; margin-left: 60%;display: inline-flex;">
<button class="btns" onclick="prevQuestion(${index.count})">上一题</button>&nbsp;&nbsp;&nbsp;&nbsp;
<button class="btns" onclick="nextQuestion(${index.count})">下一题</button>&nbsp;&nbsp;&nbsp;&nbsp;
<button class="btns" onclick="submit(${singleNum})">提交</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 singleselect = "";
var singletrue = "";
$(function() {
showSelectContent();
$("#questiontitleId1").css("display","");
$("#questiontitleId1").nextAll().css("display","none");
showQuestionSelectId();
qsiNum(1);
var singleNum ='${singleNum}';
if(singleNum == 0){
jumpExam();
}
});
function showSelectContent() {
for(var i=1;i<=singleNum;i++) {
var nowId = "";
var every = "";
nowId = "#questiontitleId" + i;
var selectAnswer = $(nowId).find("#titleId").find("#selectAnswerId").val();
if(selectAnswer!=null) {
for (var j = 1; j <= 4; j++) {
var selectNowId = "#selectContent" + i + "-" + j;
every = $(nowId).find(selectNowId).find('input[type="checkbox"]').val();
if(selectAnswer == every){
$(nowId).find(selectNowId).find('input[type="checkbox"]').prop("checked","checked");
}
}
}
}
}
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 singleNum = '${singleNum}';
//上一题
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();
}
}
//setTimeout(jumpExam,1000);
function jumpExam(){
if(singleNum == 0){
var add=0;
var examId = localStorage.getItem("examId");
var typeId = localStorage.getItem("typeId");
var data = {
singleAnswer:"无",
singleTrue:"无",
singleGrade:add,
examId:examId,
typeId:typeId
};
//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(2);
},
error:function(data){
alert("ajax请求错误!");
}
})
}
}
//提交
function submit(index){
nextQuestion(index) ;
}
//下一题型
function nextQuestion(index) {
judgeDid(index);
var didQuestion = $("#didQuestion").val();
var nodoQuestion = singleNum-didQuestion;
if(index==singleNum){
var indexMsg = layer.confirm("<h4 style='color:red'>已做"+didQuestion+"题,还有"+nodoQuestion+"题未做</h4>", {btn: ['提交','取消']},function(){
var add=$("#add").val();
var examId = localStorage.getItem("examId");
var typeId = localStorage.getItem("typeId");
if("2" == typeId||2 ==typeId){
add = add*2;
}
var typeNum = 1;
var data = {
singleAnswer:singleselect,
singleTrue:singletrue,
singleGrade:add,
examId:examId,
typeNum: typeNum,
typeId:typeId
};
//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){
layer.close(indexMsg);
menuClick(2);
},
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<=singleNum;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<=singleNum;i++){
var nowId = "";
var flage = false;
var num = 0;
nowId = "#questiontitleId"+i;
for(var j=1;j<=4;j++){
var selectNowId = "#selectContent"+i+"-"+j;
flage = $(nowId).find(selectNowId).find('input[type="checkbox"]').prop("checked");
if(flage){
num++;
didQuestion++;
}
}
var indexI = "#qsiNumId"+i;
if(num!=0){
$(indexI).css("background-color",'#c6febf');
}else if(index==i){
$(indexI).css("background-color",'#c9e1fe');
}else{
$(indexI).css("background-color",'#eee');
}
}
$("#didQuestion").attr("value",didQuestion);
console.log("didQuestion=",didQuestion);
}
//判断题目是否正确,统计分数
function judgeTrue() {
// 正确数
var add = 0;
// 错误数
var sub = 0;
var temp = "";
var tempT = "";
for(var i=1;i<=singleNum;i++){
var trueGrade = 0;
var nowId = "";
var flage = false;
var num = 0;
var selectAnswer = 0;
var selectAllContent = "";
nowId = "#questiontitleId"+i;
// 第i题的正确答案
var trueAnswer = $(nowId).find("#titleId").find("#answerId").val();
var trueAnswerNum = "";
temp += trueAnswer + ";";
var flag = false;
for(var j=1;j<=4;j++){
var selectNowId = "#selectContent"+i+"-"+j;
flage = $(nowId).find(selectNowId).find('input[type="checkbox"]').prop("checked");
if(flage){
// 第i题的选择答案
selectAnswer = $(nowId).find(selectNowId).find('input[type="checkbox"]').val();
var questionId = $(nowId).find('#titleId').find('#questionId').val();
//console.log("selectAnswer=",selectAnswer);
if(trueAnswer=="A"){
trueAnswerNum = "1";
}else if(trueAnswer=="B"){
trueAnswerNum = "2";
}else if(trueAnswer=="C"){
trueAnswerNum = "3";
}else{
trueAnswerNum = "4";
}
if(selectAnswer==trueAnswerNum){
trueGrade = 1 ;
add = add+1;
}else{
trueGrade = 0;
sub = sub+1;
}
selectAllContent = questionId + "-" + selectAnswer+"-"+trueGrade;
tempT += selectAllContent + ";";
flag = true;
}
}
if(flag == false) {
tempT += "null;";
}
}
//console.log("正确多少题:",add);
//console.log("错误多少题:",sub);
$("#add").attr("value",add);
$("#sub").attr("value",sub);
singletrue = temp;
singleselect = tempT;
}
</script>
</body>
</html>