-
+
考生试卷
+
+
题库类型:
+
科目总分:100 通过分数:60
+
北京时间:
+
考试开始时间:
+
考试结束时间:
+
+
@@ -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);
}
}
diff --git a/ruoyi-admin/src/main/resources/templates/system/exam/index.html b/ruoyi-admin/src/main/resources/templates/system/exam/index.html
index 1dae158..da2054c 100644
--- a/ruoyi-admin/src/main/resources/templates/system/exam/index.html
+++ b/ruoyi-admin/src/main/resources/templates/system/exam/index.html
@@ -25,6 +25,9 @@
.table{
width:43% ;
}
+ .unnamed1{
+ color: red;
+ }
@@ -41,7 +44,7 @@
您的相关信息:
|
- 人员编号:admin
|
+ 人员编号: [[${user.loginName}]]
|
@@ -53,12 +56,12 @@
- 性别:nan
|
+ 性别:
|
选择相关考题
|
- 人员姓名: admin
|
- 单位:admin
|
+ 人员姓名: [[${user.userName}]]
|
+ 单位: [[${user.dept.deptName}]]
|
|