提交修改

master
dsh 1 year ago
parent 15090ad6c2
commit ac6c0de90c

@ -54,7 +54,7 @@ public class TdExamController extends BaseController{
/**
* 访exam
*/
@RequestMapping("/exam")
@GetMapping("/edit")
public String index(){
return prefix + "/exam";
}

@ -5,42 +5,67 @@
</head>
<style>
.table-striped {
min-height: 89%;
min-height: 84%;
overflow: auto;
}
.table-striped p{
font-size: 16px;
}
.headerBox{
display: flex;
justify-content: start;
align-items: center;
margin-bottom: 10px;
margin-top: 10px;
padding-left: 10px;
}
.contentBox{
padding-left: 15px;
}
#answer-form{
margin-left: 15px;
font-size: 14px;
}
#next-question{
margin-left: 15px;
}
.topBox{
display: flex;
justify-content: space-around;
align-items: center;
margin-top: 15px;
}
</style>
<body class="gray-bg">
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="formId">
<div class="select-list">
<ul>
<li>
<label>题库类型:</label>
<select name="TYPEID" th:with="type=${@dict.getType('td_question_type')}">
<option value="">所有</option>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</li>
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</form>
<h2 style="text-align: center">考生<span class="typeId"></span>试卷</h2>
<div class="topBox">
<p>题库类型:<span class="typeId2"></span></p>
<p>科目总分100 &nbsp;&nbsp;&nbsp;通过分数60</p>
<p>北京时间:<span style="color: red" class="beijintime"></span></p>
<p>考试开始时间:<span class="kaishi"></span></p>
<p>考试结束时间:<span class="jieshu"></span></p>
<button class="submit" type="submit">提交</button>
</div>
</div>
<div id="question-container" class="col-sm-12 select-table table-striped">
<h1 id="question-number"></h1>
<p id="question-content"></p>
<form id="answer-form">
<div id="options"></div>
<button type="submit">提交答案</button>
</form>
<p id="result"></p>
<button id="next-question">下一题</button>
<div class="headerBox">
<h3 id="question-number"></h3>&nbsp;&nbsp;&nbsp;
<h3 id="typeId-number"></h3>&nbsp;&nbsp;&nbsp;
<p style="padding-top: 5px;">单选题(请在以下几个选项中选择唯一正确答案) 本题分数:2分</p><br>
</div>
<div class="contentBox">
<p style="padding-top: 5px;" id="question-content"></p>
<form id="answer-form">
<div id="options"></div>
</form>
<p id="result"></p>
<button id="next-question">下一题</button>
</div>
</div>
<!-- <div class="col-sm-12 select-table table-striped">-->
<!-- <table id="bootstrap-table"></table>-->
@ -54,24 +79,87 @@
var removeFlag = [[${@permission.hasPermi('system:question:remove')}]];
var TYPEIDDatas = [[${@dict.getType('td_question_type')}]];
var prefix = ctx + "system/question";
// 获取当前页面的URL
var urlParams = new URLSearchParams(window.location.search);
// 获取名为 param1 的参数值
var param = urlParams.get('TYPEID');
var userName = urlParams.get('userName');
var deptName = urlParams.get('deptName');
if(param ==='1'){
document.querySelector('.typeId').innerHTML = '专业题库'
document.querySelector('.typeId2').innerHTML = '专业题库'
}else{
document.querySelector('.typeId').innerHTML = '基础题库'
document.querySelector('.typeId2').innerHTML = '基础题库'
}
// 获取当前北京时间
function getCurrentDateTime() {
var currentDate = new Date();
var year = currentDate.getFullYear(); // 年份
var month = currentDate.getMonth() + 1; // 月份
var day = currentDate.getDate(); // 当月的某一天
var hours = currentDate.getHours(); // 小时
var minutes = currentDate.getMinutes(); // 分钟
var seconds = currentDate.getSeconds(); // 秒钟
// 将时间部分补零,保证两位数显示
month = month < 10 ? '0' + month : month;
day = day < 10 ? '0' + day : day;
hours = hours < 10 ? '0' + hours : hours;
minutes = minutes < 10 ? '0' + minutes : minutes;
seconds = seconds < 10 ? '0' + seconds : seconds;
// 格式化输出日期时间
return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
}
// 更新显示时间的函数
function updateClock() {
// 假设你有一个 id 为 clock 的元素用来显示时间
document.querySelector('.beijintime').innerText = getCurrentDateTime();
}
updateClock();
// 每秒钟更新一次时间
setInterval(updateClock, 1000);
//获取考试开始时间和考试结束时间
// 获取当前时间
var currentTime = new Date();
// 获取考试开始时间
var examStartTime = new Date(currentTime);
// 加上45分钟得到考试结束时间
examStartTime.setMinutes(examStartTime.getMinutes() + 45);
function formatDateTime(date) {
var year = date.getFullYear();
var month = (date.getMonth() + 1).toString().padStart(2, '0');
var day = date.getDate().toString().padStart(2, '0');
var hours = date.getHours().toString().padStart(2, '0');
var minutes = date.getMinutes().toString().padStart(2, '0');
var seconds = date.getSeconds().toString().padStart(2, '0');
return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
}
// 输出考试开始时间和结束时间
document.querySelector('.kaishi').innerText = formatDateTime(currentTime)
document.querySelector('.jieshu').innerText = formatDateTime(examStartTime)
function checkExamTime (){
var currentTime1 = new Date();
if (currentTime1 > examStartTime) {
// 超时,进行强制提交操作
console.log("已超过考试开始时间,进行强制提交操作。");
clearInterval(intervalID);
} else {
// 未超时,正常进行考试
console.log("考试开始时间:" + formatDateTime(currentTime));
console.log("考试结束时间:" + formatDateTime(examStartTime));
}
}
var intervalID = setInterval(checkExamTime , 60000);
// $(function() {
// var options = {
// url: prefix + "/list",
// createUrl: prefix + "/add",
// updateUrl: prefix + "/edit/{id}",
// removeUrl: prefix + "/remove",
// exportUrl: prefix + "/export",
// modalName: "保密考试",
// };
// $.table.init(options);
// });
$(document).ready(function() {
const obj = {
pageSize: 10,
pageSize: 50,
pageNum: 1,
isAsc: 'asc',
TYPEID: ''
TYPEID: param
};
$.ajax({
url: prefix + "/list",
@ -92,17 +180,18 @@
function initQuestionSystem(questions) {
let currentQuestionIndex = 0;
// const result = [];
let result1 = []
let result2 = []
let result1 = [] //正确答案
let result2 = [] //错误答案
// 实现显示第一题的函数
function showQuestion(question) {
function showQuestion(question,currentQuestionIndex) {
// 显示题目和选项等信息
const questionNumberElement = document.getElementById('question-number');
const typeIdNumberElement = document.getElementById('typeId-number');
const questionContentElement = document.getElementById('question-content');
const optionsElement = document.getElementById('options');
questionNumberElement.textContent = `题目 ${question.id}`;
questionNumberElement.textContent = `题号:${currentQuestionIndex+1}/50`;
questionContentElement.textContent = question.qSubject;
typeIdNumberElement.textContent = `题型:${question.typeid}`;
question.options = [
'A、' + question.optiona,
'B、' + question.optionb,
@ -160,9 +249,9 @@
// 更新currentQuestionIndex显示下一题
currentQuestionIndex++;
if (currentQuestionIndex < questions.length) {
showQuestion(questions[currentQuestionIndex]);
showQuestion(questions[currentQuestionIndex],currentQuestionIndex);
} else {
alert('所有题目已答完!');
alert('所有题目已答完!请提交');
// 如果需要在所有题目答完后进行额外操作,可以在这里添加代码
}
} else {
@ -171,17 +260,33 @@
}
//提交
document.getElementById('answer-form').addEventListener('submit', function(event) {
document.querySelector('.topBox .submit').addEventListener('click', function(event) {
event.preventDefault();
if (result1.length){
let int = result1.length * 2
console.log(int)
let params = {
examResult:result1.length * 2,
userName:userName,
dept:deptName,
startTime:formatDateTime(currentTime),
endTime:formatDateTime(examStartTime),
type:param,
};
// 弹出确认提示框
let confirmation = confirm("提交后不可更改,是否确定提交?");
if (confirmation) {
// 如果用户确定提交,则执行提交操作
console.log(params);
// 执行提交的相关操作
this.disabled = true; // 禁用提交按钮
} else {
// 如果用户取消提交,则继续答题
console.log("取消提交,继续答题。");
}
});
document.getElementById('next-question').addEventListener('click', nextQuestion);
// 初始加载第一题
if (questions.length > 0) {
showQuestion(questions[currentQuestionIndex]);
showQuestion(questions[currentQuestionIndex],currentQuestionIndex);
}
}
</script>

@ -25,6 +25,9 @@
.table{
width:43% ;
}
.unnamed1{
color: red;
}
</style>
<body class="gray-bg">
<div class="container-div">
@ -41,7 +44,7 @@
<td colspan="3" ><br><h5>您的相关信息:</h5><hr /></td>
</tr>
<tr>
<td class="table" align="left"><b>人员编号:</b>admin<hr /></td>
<td class="table" align="left"><b>人员编号: </b>[[${user.loginName}]]<hr /></td>
<!-- <%-->
<!-- String disabled="";-->
<!-- String tmpsex=buf.fget("sex",0);-->
@ -53,12 +56,12 @@
<!-- disabled = "disabled";-->
<!-- }-->
<!-- %>-->
<td class="table" align="left"><b>性别:</b>nan<hr /></td>
<td class="table" align="left"><b>性别: </b><span th:text="${user.sex == 0 ? '女' : '男'}"></span><hr /></td>
<td class="table" align="left"><b>选择相关考题</b><hr /></td>
</tr>
<tr>
<td class="table" align="left"><b>人员姓名:</b> admin <hr/></td>
<td class="table" align="left"><b>单位:</b>admin<hr/></td>
<td class="table" align="left"><b>人员姓名: </b> <span class="user_name">[[${user.userName}]] </span><hr/></td>
<td class="table" align="left"><b>单位: </b><span class="dept_name">[[${user.dept.deptName}]]</span><hr/></td>
<td class="table" align="left">
<select name="TYPEID" th:with="type=${@dict.getType('td_question_type')}">
<option value="">-请选择-</option>
@ -85,9 +88,16 @@
</div>
<script th:inline="javascript">
function check() {
debugger
window.location.href = 'exam';
if (form1.TYPEID.value=='') {
alert("请选择相关考题!");
return false;
}
var userName = document.querySelector('.user_name').innerHTML
var deptName = document.querySelector('.dept_name').innerHTML
window.location.href = `/system/exam/edit?TYPEID=${form1.TYPEID.value}&userName=${userName}&deptName=${deptName}`;
// form1.action = "/zhyw/smsj/TryBook.jsp";
// form1.button1.disabled=true;
// form1.submit();
}
</script>
</body>

Loading…
Cancel
Save