左右箭头改为上一题下一题

main^2
Ly 1 week ago
parent a6d4c99252
commit d8074e8231
  1. 38
      src/views/subjectTest/index.vue

@ -4,9 +4,9 @@
<div class="title">{{ setting.title }}</div> <div class="title">{{ setting.title }}</div>
</div> </div>
<!-- 右边箭头 --> <!-- 右边箭头 -->
<button class="submit-right" @click="SubRight"></button> <!-- <button class="submit-right" @click="SubRight"></button> -->
<!-- 左边按钮 --> <!-- 左边按钮 -->
<button class="submit-left" @click="SubLeft"></button> <!-- <button class="submit-left" @click="SubLeft"></button> -->
<div class="question-body"> <div class="question-body">
<div class="question"> <div class="question">
<span class="question-count">{{ currentSum }}</span> <span class="question-count">{{ currentSum }}</span>
@ -38,6 +38,8 @@
</div> </div>
<div class="submit-buttons"> <div class="submit-buttons">
<button class="submit-btn" @click="resetAnswers">退出答题</button> <button class="submit-btn" @click="resetAnswers">退出答题</button>
<button class="submit-btn" @click="SubLeft">上一题</button>
<button class="submit-btn" @click="SubRight">下一题</button>
<button class="submit-btn" @click="submitAnswers" v-if="complete === false">提交成绩</button> <button class="submit-btn" @click="submitAnswers" v-if="complete === false">提交成绩</button>
</div> </div>
<el-dialog v-model="isVisible" :close-on-click-modal="false" :show-close="false"> <el-dialog v-model="isVisible" :close-on-click-modal="false" :show-close="false">
@ -54,7 +56,7 @@ import { ref, computed, onMounted, onUnmounted } from "vue"
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
const setting = settingStore(); const setting = settingStore();
// //
const SubLeft = () => { const SubLeft = () => {
console.log(currentQuestionIndex.value) console.log(currentQuestionIndex.value)
if (currentQuestionIndex.value >= 1) { if (currentQuestionIndex.value >= 1) {
@ -63,12 +65,11 @@ const SubLeft = () => {
ElMessage.warning('无法上翻') ElMessage.warning('无法上翻')
} }
} }
// //
const SubRight = async () => { const SubRight = async () => {
console.log(complete.value,'11111111') console.log(selectedOption.value,'11111111')
if(complete.value == false){ if(complete.value == false){
const res: any = await checkapi(selectedOption.value[currentQuestionIndex.value]); const res: any = await checkapi(selectedOption.value[currentQuestionIndex.value]);
console.log(selectedOption.value);
console.log(res, 'res') console.log(res, 'res')
// //
if (res.result == "success") { if (res.result == "success") {
@ -80,11 +81,7 @@ const SubRight = async () => {
} }
} }
else { else {
if (selectedOption.value[currentQuestionIndex.value] == null) {
ElMessage.warning('请先答题')
} else {
ElMessage.error('回答错误') ElMessage.error('回答错误')
}
} }
}else{ }else{
if (currentSum.value < questions.value.length) { if (currentSum.value < questions.value.length) {
@ -97,10 +94,15 @@ const SubRight = async () => {
} }
const questions = ref<any[]>([]); const questions = ref<any[]>([]);
// questions.value null
const selectedOption = ref<{ oid: any; qid: any }[]>([]);
const currentList = async () => { const currentList = async () => {
const res: any = await subTestapi(); const res: any = await subTestapi();
questions.value = res.result questions.value = res.result
console.log(res.result) selectedOption.value = Array.from({ length: questions.value.length }, () => ({ oid: '', qid: '' }))
console.log(selectedOption.value,'selectedOption');
// console.log(questions.value[0].xnOptionsList[0].id) // console.log(questions.value[0].xnOptionsList[0].id)
// console.log(questions.value,'questions1.value') // console.log(questions.value,'questions1.value')
} }
@ -120,12 +122,8 @@ const xnOptionsList = computed(() => {
if (questions.value.length > 0) { if (questions.value.length > 0) {
return questions.value[currentQuestionIndex.value].xnOptionsList return questions.value[currentQuestionIndex.value].xnOptionsList
} }
console.log(selectedOption.value)
return []; return [];
}) })
//
// questions.value null
const selectedOption = ref<{ oid: any; qid: string }[]>(Array(questions.value.length).fill(null));
// //
const selectOption = async (option: any) => { const selectOption = async (option: any) => {
@ -240,7 +238,7 @@ const handleRecreate = () => {
border: none; border: none;
cursor: pointer; cursor: pointer;
position: absolute; position: absolute;
right: 0; right: 18%;
/* 紧靠右部 */ /* 紧靠右部 */
top: 40%; top: 40%;
/* 垂直居中*/ /* 垂直居中*/
@ -256,7 +254,7 @@ const handleRecreate = () => {
border: none; border: none;
cursor: pointer; cursor: pointer;
position: absolute; position: absolute;
left: 0; left: 18%;
/* 紧靠左部 */ /* 紧靠左部 */
top: 40%; top: 40%;
/* 垂直居中*/ /* 垂直居中*/
@ -416,7 +414,7 @@ const handleRecreate = () => {
/* 水平排列按钮 */ /* 水平排列按钮 */
justify-content: center; justify-content: center;
/* 水平居中 */ /* 水平居中 */
gap: 450px; gap: 20px;
/* 按钮之间的间距 */ /* 按钮之间的间距 */
margin-top: 50px; margin-top: 50px;
} }
@ -431,8 +429,8 @@ const handleRecreate = () => {
/* 移除边框 */ /* 移除边框 */
cursor: pointer; cursor: pointer;
/* 鼠标悬停时显示手型 */ /* 鼠标悬停时显示手型 */
width: 300px; width: 255px;
height: 41px; height: 35px;
font-size: 18px; font-size: 18px;
font-weight: bold; font-weight: bold;
/* 文字加粗 */ /* 文字加粗 */

Loading…
Cancel
Save