前端考试答题,下一题,上一题

64 篇文章 1 订阅
<template>
  <div class="box">
    <div class="wrap">
      <p class="title">教育培训</p>
      <el-row class="top">
        <el-col :span="3" :offset="1">
          <img
            src="@/assets/img/fh.png"
            alt=""
            class="fh"
            @click="$router.go(-1)"
          />
        </el-col>
        <el-col :span="16">
          <el-row style="width: 35%; margin: 0 auto">
            <el-col :span="5">
              <img
                src="../../../assets/img/timryes.png"
                alt=""
                class="timrIoc"
              />
            </el-col>
            <el-col :span="15">
              <span :class="[timeState ? 'redcolor' : '']"
                ><van-count-down
                  :time="time"
                  ref="countDown"
                  format="mm:ss"
                  @finish="finish"
                  @change="timeChange(time)"
              /></span>
            </el-col>
          </el-row>
        </el-col>
        <el-col :span="3">
          <!-- <span class="submitCss" @click="submitFn()">交卷</span> -->
        </el-col>
      </el-row>
      <div class="tabContentPage">
        <div class="topicList">
          <p>
            <em>{{ numValue + 1 }}/20</em><span>{{ stem }}</span>
          </p>
          <ul>
            <li>
              <el-radio
                v-model="answerValue[numValue]"
                label="A"
                class="radioCss"
                :disabled="radioShow.radioShow"
                @change="radioChange"
                >{{ optionA }}</el-radio
              >
            </li>
            <li>
              <el-radio
                v-model="answerValue[numValue]"
                label="B"
                class="radioCss"
                :disabled="radioShow.radioShow"
                >{{ optionB }}</el-radio
              >
            </li>
            <li>
              <el-radio
                v-model="answerValue[numValue]"
                label="C"
                class="radioCss"
                :disabled="radioShow.radioShow"
                >{{ optionC }}</el-radio
              >
            </li>
            <li>
              <el-radio
                v-model="answerValue[numValue]"
                label="D"
                class="radioCss"
                :disabled="radioShow.radioShow"
                >{{ optionD }}</el-radio
              >
            </li>
          </ul>
        </div>
        <el-row>
          <el-col :span="12" style="text-align: center">
            <span class="submitCss" @click="prev">上一题</span>
          </el-col>
          <el-col :span="12" style="text-align: center">
            <span class="submitCss" @click="next">下一题</span>
          </el-col>
          <el-col :span="24" style="text-align: center" v-if="numValue == 19">
            <span class="submitCss" @click="submitFn()"
              >交卷</span
            >
          </el-col>
        </el-row>

        <div class="topicAnswer">
          <el-row type="flex" justify="space-between" class="topicSort">
            <el-col :span="12">
              <h5>试题讲解</h5>
            </el-col>
            <el-col :span="12">
              <el-row>
                <el-col :span="8">
                  <img src="../../../assets/img/yes.png" alt="" /><span>{{
                    45
                  }}</span>
                </el-col>
                <el-col :span="8">
                  <img src="../../../assets/img/no.png" alt="" /><span>{{
                    45
                  }}</span>
                </el-col>
                <el-col :span="8">
                  <img src="../../../assets/img/fail.png" alt="" /><span>{{
                    45
                  }}</span>
                </el-col>
              </el-row>
            </el-col>
            <!-- <el-col :span="8">4545644646466</el-col> -->
          </el-row>
          <p>
            {{ notes }}
          </p>
        </div>
        <el-dialog
          :visible.sync="dialogVisible"
          width="80%"
          :show-close="false"
          :close-on-click-modal="false"
        >
          <div class="upTitle">
            <h5>当前成绩不合格</h5>
            <img src="../../../assets/img/grade.png" alt="" />
            <el-row style="margin-top: 1rem">
              <el-col :span="8">
                <div class="borderCss">
                  <p style="color: #fe6c6c">12</p>
                  <p>错题数</p>
                </div>
              </el-col>
              <el-col :span="8">
                <div class="borderCss">
                  <p>8</p>
                  <p>未做题数</p>
                </div>
              </el-col>
              <el-col :span="8">
                <div>
                  <p>40</p>
                  <p>考试得分</p>
                </div>
              </el-col>
            </el-row>
            <el-row class="bottomCss" type="flex" justify="space-between">
              <el-col :span="12">
                <el-button size="small" @click="open">继续答题</el-button>
              </el-col>
              <el-col :span="12">
                <el-button size="small" type="primary" @click="submitPaperFn"
                  >现在交卷</el-button
                >
              </el-col>
            </el-row>
          </div>
        </el-dialog>
      </div>
    </div>
  </div>
</template>
<script>
import { FlashPayment } from "@icon-park/vue";
export default {
  data() {
    return {
      radioShow:{radioShow:false},
      answerValue: [],
      stem: "",
      optionA: "",
      optionB: "",
      optionC: "",
      optionD: "",
      correctAnswer: "",
      numValue: 0,
      notes: "",
      topicId: "",
      dialogVisible: false,
      timeState: false,
      time: 20 * 60 * 1000,
      topicName: "",
      listData: [],
      listData2: [],
    };
  },
  //  请求违法代码接口
  created() {
    this.topicName = this.$route.query.item.selectedQuestionBank;
    this.topicId = this.$route.query.item.id;
    this.getData();
   
  },
  methods: {
    // 考试倒计时
    finish() {
      this.$message({
        message: "考试时间结束",
        type: "error",
      });
      this.submitFn();
    },
    // 倒计时提示
    timeChange() {
      let that = this;
      if (that.$refs.countDown.formattedTime < "01:00") {
        that.timeState = true;
      }
    },
    选择题目方法
    radioChange(val) {  
      console.log(32232321,this.answerValue)
      console.log(321,this.numValue)
      选过的题禁止重选
		if(this.numValue < this.answerValue.length){
		     this.radioShow.radioShow = true
		}
    },
    上一题
    prev() {
      if (this.numValue >= 1) {
        var num = this.numValue;
        this.numValue = --num;
       **numValue  是题目下标  this.answerValu 是答案长度   题目下标小于答案长度 证明题目已经解答 打过的题 禁止选**  
        if(this.numValue < this.answerValue.length){
            this.radioShow.radioShow = true
        }
        ***调用题目方法***
        this.topicList()
      } else {
        return;
      }
    },
    // 下一步
    next(item) {
      if (this.numValue <= 18) {
       
        var num = this.numValue;
        this.numValue = ++num;
  **numValue  是题目下标   this.answerValu 是答案长度   题目下标小于答案长度 证明题目已经解答 打过的题 禁止重新答题
**
        if(this.numValue >= this.answerValue.length){
            this.$set(this.radioShow,"radioShow",false)
          }
        this.topicList()
      }
    },
    // 操作题目列表
    topicList(){
      this.$nextTick(()=>{
           var arrData = this.listData
           var numValue = this.numValue
            this.stem = arrData[numValue].stem;
            this.optionA = arrData[numValue].optionA;
            this.optionB = arrData[numValue].optionB;
            this.optionC = arrData[numValue].optionC;
            this.optionD = arrData[numValue].optionD;
            this.notes = arrData[numValue].notes;
            // this.radioShow = arrData[numValue].radioShow;
            this.correctAnswer = arrData[numValue].correctAnswer;
            this.topicId = arrData[numValue].id; 
      })
     
    },
    // 获取答题列表
    getData(num) {
      var then = this;
      this.$axios
        .get(
          this.GLOBAL.myhf +
            `/selectQuestionBan?selectedQuestionBankType=${then.topicName}&id=${then.topicId}`,
          { withCredentials: true }
        )
        .then((res) => {
        
          if (res.data.info == "success") {
            then.listData = res.data.data.questionBankNewList;
              then.topicList();
          } else {
            // this.$message({
            //   message: res.data.msg,
            //   type: "warning",
            // });
          }
        });
    },
    // 答题未通过
    open() {
      let that = this;
      that
        .$confirm("此次答题不会记录", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
        .then(() => {
          this.dialogVisible = false;
        })
        .catch(() => {});
    },
    // 现在交卷
    submitPaperFn() {
      this.$router.push("/submitPaper");
      //  this.$router.push({path:'/home',query: {id:'1'}})
    },
    // 提交
    submitFn() {
      this.$router.push({
        path: "/submitPaper",
        query: { dtTime: this.$refs.countDown.formattedTime },
      });
    },
  },
};

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
以下是一个包含六道选择题的答题界面样例代码: ```html <!DOCTYPE html> <html> <head> <title>在线考试系统</title> </head> <body> <h1>选择题</h1> <form> <p>1. 以下哪个不是一种编程语言?</p> <input type="radio" name="q1" value="A">A. HTML<br> <input type="radio" name="q1" value="B">B. Java<br> <input type="radio" name="q1" value="C">C. Python<br> <input type="radio" name="q1" value="D">D. Photoshop<br> <br> <p>2. 下列哪个不是Web前端开发中的一种常见框架?</p> <input type="radio" name="q2" value="A">A. React<br> <input type="radio" name="q2" value="B">B. Vue<br> <input type="radio" name="q2" value="C">C. Django<br> <input type="radio" name="q2" value="D">D. Angular<br> <br> <p>3. 下列哪个不是一种常见的数据库管理系统?</p> <input type="radio" name="q3" value="A">A. MySQL<br> <input type="radio" name="q3" value="B">B. Oracle<br> <input type="radio" name="q3" value="C">C. Photoshop<br> <input type="radio" name="q3" value="D">D. SQL Server<br> <br> <p>4. 以下哪个是一种网络安全攻击?</p> <input type="radio" name="q4" value="A">A. SQL注入<br> <input type="radio" name="q4" value="B">B. HTML注入<br> <input type="radio" name="q4" value="C">C. CSS注入<br> <input type="radio" name="q4" value="D">D. JavaScript注入<br> <br> <p>5. 下列哪个不是一种常见的操作系统?</p> <input type="radio" name="q5" value="A">A. Windows<br> <input type="radio" name="q5" value="B">B. Linux<br> <input type="radio" name="q5" value="C">C. macOS<br> <input type="radio" name="q5" value="D">D. Photoshop<br> <br> <p>6. 下列哪个不是一种常见的云计算平台?</p> <input type="radio" name="q6" value="A">A. AWS<br> <input type="radio" name="q6" value="B">B. Azure<br> <input type="radio" name="q6" value="C">C. GCP<br> <input type="radio" name="q6" value="D">D. Photoshop Cloud<br> <br> <input type="submit" value="提交"> </form> </body> </html> ``` 这段代码创建了一个包含六道选择题的答题界面,并在页面底部放置了一个提交按钮。当用户点击提交按钮时,表单数据将被提交到服务器端进行处理。注意,这只是一个简单的示例代码,实际的在线考试系统需要更加复杂的逻辑和功能。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小四是个处女座

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值