| | |
| | | return this.userAnswer |
| | | }, |
| | | setAnswer (answer) { |
| | | this.userAnswer = '' |
| | | this.userAnswer = answer |
| | | }, |
| | | setSubjectInfo (subject, subjectCount, index) { |
| | | this.currentAnswer = false |
| | |
| | | <template> |
| | | <div> |
| | | <div class="subject-content"> |
| | | <div class="subject-title"> |
| | | {{ index }} |
| | | <span class="subject-title-content" v-html="subjectInfo.subjectName" /> |
| | | <span class="subject-title-content titlesss"> |
| | | ( 判断题 <span v-if="subjectInfo.score !== undefined && subjectInfo.score !== 0"> {{ |
| | | subjectInfo.score }}分 </span>) |
| | | </span> |
| | | </div> |
| | | <ul class="subject-options" v-for="option in options" :key="option.id"> |
| | | <li class="subject-option"> |
| | | <input class="toggle" type="checkbox" :checked="userAnswer === option.optionName" |
| | | :id="'option' + option.id" @change="toggleOption(option)" /> |
| | | <label :for="'option' + option.id"> |
| | | <span class="subject-option-prefix">{{ option.optionName }} </span> |
| | | </label> |
| | | </li> |
| | | </ul> |
| | | </div> |
| | | <div> |
| | | <div class="subject-content"> |
| | | <div class="subject-title"> |
| | | {{ index }} |
| | | <span class="subject-title-content" v-html="subjectInfo.subjectName" /> |
| | | <span class="subject-title-content titlesss"> |
| | | ( 判断题 <span |
| | | v-if="subjectInfo.score !== undefined && subjectInfo.score !== 0" |
| | | > {{ subjectInfo.score }}分 </span |
| | | >) |
| | | </span> |
| | | </div> |
| | | <ul class="subject-options" v-for="option in options" :key="option.id"> |
| | | <li class="subject-option"> |
| | | <input |
| | | class="toggle" |
| | | type="checkbox" |
| | | :checked="userAnswer === option.optionName" |
| | | :id="'option' + option.id" |
| | | @change="toggleOption(option)" |
| | | /> |
| | | <label :for="'option' + option.id"> |
| | | <span class="subject-option-prefix" |
| | | >{{ option.optionName }} </span |
| | | > |
| | | </label> |
| | | </li> |
| | | </ul> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | export default { |
| | | name: "Judgement", |
| | | data () { |
| | | return { |
| | | subjectCount: 0, |
| | | subjectInfo: { |
| | | subjectName: "", |
| | | score: 0, |
| | | }, |
| | | options: [ |
| | | { id: 1, optionName: "正确" }, |
| | | { id: 2, optionName: "错误" }, |
| | | ], |
| | | userAnswer: "", |
| | | index: "", |
| | | } |
| | | name: "Judgement", |
| | | data() { |
| | | return { |
| | | subjectCount: 0, |
| | | subjectInfo: { |
| | | subjectName: "", |
| | | score: 0, |
| | | }, |
| | | options: [ |
| | | { id: 1, optionName: "正确" }, |
| | | { id: 2, optionName: "错误" }, |
| | | ], |
| | | userAnswer: "", |
| | | index: "", |
| | | }; |
| | | }, |
| | | methods: { |
| | | getAnswer() { |
| | | return this.userAnswer; |
| | | }, |
| | | methods: { |
| | | getAnswer () { |
| | | return this.userAnswer |
| | | }, |
| | | setAnswer (answer) { |
| | | this.userAnswer = '' |
| | | }, |
| | | setSubjectInfo (subject, subjectCount, index) { |
| | | this.subjectCount = subjectCount |
| | | this.subjectInfo = subject |
| | | if (subject.hasOwnProperty("answer")) { |
| | | this.setAnswer(subject.answer) |
| | | } |
| | | this.index = index + "." |
| | | }, |
| | | getSubjectInfo () { |
| | | this.subjectInfo.options = this.options |
| | | return this.subjectInfo |
| | | }, |
| | | // 选中选项 |
| | | toggleOption (option) { |
| | | this.userAnswer = option.optionName |
| | | }, |
| | | setAnswer(answer) { |
| | | this.userAnswer = answer; |
| | | }, |
| | | } |
| | | setSubjectInfo(subject, subjectCount, index) { |
| | | this.subjectCount = subjectCount; |
| | | this.subjectInfo = subject; |
| | | if (subject.hasOwnProperty("answer")) { |
| | | this.setAnswer(subject.answer); |
| | | } |
| | | this.index = index + "."; |
| | | }, |
| | | getSubjectInfo() { |
| | | this.subjectInfo.options = this.options; |
| | | return this.subjectInfo; |
| | | }, |
| | | // 选中选项 |
| | | toggleOption(option) { |
| | | this.userAnswer = option.optionName; |
| | | }, |
| | | }, |
| | | }; |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | @import "../../../assets/css/subject.scss"; |
| | | |
| | | .subject-options>li label { |
| | | line-height: 36px !important; |
| | | .subject-options > li label { |
| | | line-height: 36px !important; |
| | | } |
| | | </style> |
| | |
| | | * @Author: shuishen 1109946754@qq.com |
| | | * @Date: 2023-11-06 10:15:36 |
| | | * @LastEditors: shuishen 1109946754@qq.com |
| | | * @LastEditTime: 2023-11-07 14:43:28 |
| | | * @LastEditTime: 2023-11-07 15:12:56 |
| | | * @FilePath: \zhba_exam\src\components\Subjects\MultipleChoices\index.vue |
| | | * @Description: |
| | | * |
| | | * Copyright (c) 2023 by shuishen, All Rights Reserved. |
| | | --> |
| | | <template> |
| | | <div> |
| | | <div class="subject-content"> |
| | | <div class="subject-title"> |
| | | {{ index }} |
| | | <span class="subject-title-content" v-html="subjectInfo.subjectName" /> |
| | | <span class="subject-title-content titlesss"> |
| | | ( 多选题 <span v-if="subjectInfo.score !== undefined && subjectInfo.score !== 0"> {{ |
| | | subjectInfo.score }}分 </span>) |
| | | </span> |
| | | </div> |
| | | <div> |
| | | <div class="subject-content"> |
| | | <div class="subject-title"> |
| | | {{ index }} |
| | | <span class="subject-title-content" v-html="subjectInfo.subjectName" /> |
| | | <span class="subject-title-content titlesss"> |
| | | ( 多选题 <span |
| | | v-if="subjectInfo.score !== undefined && subjectInfo.score !== 0" |
| | | > {{ subjectInfo.score }}分 </span |
| | | >) |
| | | </span> |
| | | </div> |
| | | |
| | | <ul class="subject-options" v-for="option in options" :key="option.id"> |
| | | <li class="subject-option"> |
| | | <input class="toggle" type="checkbox" :checked="isChecked(option.optionName)" :id="'option' + option.id" |
| | | @change="toggleOption($event, option)" /> |
| | | <label :for="'option' + option.id"> |
| | | <span class="subject-option-prefix">{{ option.optionName + "." }} </span> |
| | | <span v-html="option.optionContent" class="subject-option-prefix" /> |
| | | </label> |
| | | </li> |
| | | </ul> |
| | | </div> |
| | | <ul class="subject-options" v-for="option in options" :key="option.id"> |
| | | <li class="subject-option"> |
| | | <input |
| | | class="toggle" |
| | | type="checkbox" |
| | | :checked="isChecked(option.optionName)" |
| | | :id="'option' + option.id" |
| | | @change="toggleOption($event, option)" |
| | | /> |
| | | <label :for="'option' + option.id"> |
| | | <span class="subject-option-prefix" |
| | | >{{ option.optionName + "." }} </span |
| | | > |
| | | <span v-html="option.optionContent" class="subject-option-prefix" /> |
| | | </label> |
| | | </li> |
| | | </ul> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | export default { |
| | | name: "MultipleChoices", |
| | | data () { |
| | | return { |
| | | subjectCount: 0, |
| | | subjectInfo: { |
| | | subjectName: "", |
| | | score: 0, |
| | | }, |
| | | options: [], |
| | | userAnswer: [], |
| | | index: "", |
| | | name: "MultipleChoices", |
| | | data() { |
| | | return { |
| | | subjectCount: 0, |
| | | subjectInfo: { |
| | | subjectName: "", |
| | | score: 0, |
| | | }, |
| | | options: [], |
| | | userAnswer: [], |
| | | index: "", |
| | | }; |
| | | }, |
| | | watch: {}, |
| | | methods: { |
| | | getAnswer() { |
| | | return this.userAnswer.join(","); |
| | | }, |
| | | setAnswer(answer) { |
| | | // if (isNotEmpty(answer)) { |
| | | this.userAnswer = answer.split(","); |
| | | // } |
| | | }, |
| | | setSubjectInfo(subject, subjectCount, index) { |
| | | this.subjectCount = subjectCount; |
| | | this.subjectInfo = subject; |
| | | if (subject.hasOwnProperty("examSubjectOptions")) { |
| | | this.options = subject.examSubjectOptions; |
| | | } |
| | | if (subject.hasOwnProperty("answer")) { |
| | | this.setAnswer(subject.answer); |
| | | } |
| | | this.index = index + "."; |
| | | }, |
| | | getSubjectInfo() { |
| | | this.subjectInfo.options = this.options; |
| | | return this.subjectInfo; |
| | | }, |
| | | // 选中选项 |
| | | toggleOption($event, option) { |
| | | if ($event.target.checked) { |
| | | if (!this.userAnswer.includes(option.optionName)) { |
| | | this.userAnswer.push(option.optionName); |
| | | } |
| | | } else { |
| | | this.userAnswer.splice( |
| | | this.userAnswer.findIndex((item) => item === option.optionName), |
| | | 1 |
| | | ); |
| | | } |
| | | }, |
| | | watch: {}, |
| | | methods: { |
| | | getAnswer () { |
| | | return this.userAnswer.join(",") |
| | | }, |
| | | setAnswer (answer) { |
| | | this.userAnswer = [] |
| | | }, |
| | | setSubjectInfo (subject, subjectCount, index) { |
| | | this.subjectCount = subjectCount |
| | | this.subjectInfo = subject |
| | | if (subject.hasOwnProperty("examSubjectOptions")) { |
| | | this.options = subject.examSubjectOptions |
| | | } |
| | | if (subject.hasOwnProperty("answer")) { |
| | | this.setAnswer(subject.answer) |
| | | } |
| | | this.index = index + "." |
| | | }, |
| | | getSubjectInfo () { |
| | | this.subjectInfo.options = this.options |
| | | return this.subjectInfo |
| | | }, |
| | | // 选中选项 |
| | | toggleOption ($event, option) { |
| | | if ($event.target.checked) { |
| | | if (!this.userAnswer.includes(option.optionName)) { |
| | | this.userAnswer.push(option.optionName) |
| | | } |
| | | } else { |
| | | this.userAnswer.splice( |
| | | this.userAnswer.findIndex((item) => item === option.optionName), |
| | | 1 |
| | | ) |
| | | } |
| | | }, |
| | | isChecked (optionName) { |
| | | return this.userAnswer.includes(optionName) |
| | | }, |
| | | isChecked(optionName) { |
| | | return this.userAnswer.includes(optionName); |
| | | }, |
| | | } |
| | | }, |
| | | }; |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | @import "../../../assets/css/subject.scss"; |
| | | |
| | | .subject-options>li label { |
| | | line-height: 36px !important; |
| | | .subject-options > li label { |
| | | line-height: 36px !important; |
| | | } |
| | | </style> |
| | |
| | | last () { |
| | | for (let i = 0; i < this.subjectIds.length; i++) { |
| | | if (this.subjectIds[i].everyID == this.query.subjectId) { |
| | | this.subjectIds[i].answer = this.judgeAnswerIfNull(this.subjectIds[i].answer) |
| | | this.subjectIds[i].answer = this.getAnswer() |
| | | |
| | | this.markAnswered(this.subjectIds[i].answer, i) |
| | | |
| | |
| | | next () { |
| | | for (let i = 0; i < this.subjectIds.length; i++) { |
| | | if (this.subjectIds[i].everyID == this.query.subjectId) { |
| | | // if (this.getAnswer() == "") { |
| | | // this.$message({ |
| | | // message: "请选择答案", |
| | | // type: "warning", |
| | | // }); |
| | | // return; |
| | | // } |
| | | // console.log(this.getAnswer(), this.query.type); |
| | | if (this.query.type == 3) { |
| | | let goShiCao = true |
| | | const answer = this.getAnswer() |
| | | for (let k in answer) { |
| | | if (answer[k].value == "") { |
| | | goShiCao = false |
| | | } |
| | | } |
| | | if (!goShiCao) { |
| | | this.$message({ |
| | | message: "实操题目请选择完整顺序!", |
| | | type: "warning" |
| | | }) |
| | | return |
| | | } |
| | | } |
| | | |
| | | this.subjectIds[i].answer = this.judgeAnswerIfNull(this.subjectIds[i].answer) |
| | | this.subjectIds[i].answer = this.getAnswer() |
| | | |
| | | this.markAnswered(this.subjectIds[i].answer, i) |
| | | |
| | |
| | | }, |
| | | // 保存当前题目,同时根据序号加载下一题 |
| | | saveCurrentSubjectAndGetNextSubject (nextType, nextSubjectId, subjectIds) { |
| | | var answerData = this.judgeAnswerIfNull(subjectIds.answer) |
| | | // console.log(nextType, nextSubjectId, subjectIds, '2222222') |
| | | this.startLoading(nextType) |
| | | |
| | | var answerData = this.getAnswer() |
| | | |
| | | var str = "" |
| | | |
| | |
| | | ind = this.subjectIndex - 1 |
| | | } |
| | | |
| | | this.subjectIds[ind].answer = this.judgeAnswerIfNull(this.subjectIds[ind].answer) |
| | | this.subjectIds[ind].answer = this.getAnswer() |
| | | |
| | | this.markAnswered(this.subjectIds[ind].answer, ind) |
| | | |
| | |
| | | ind = this.subjectIndex - 1 |
| | | } |
| | | |
| | | this.subjectIds[ind].answer = this.judgeAnswerIfNull(this.subjectIds[ind].answer) |
| | | this.subjectIds[ind].answer = this.getAnswer() |
| | | |
| | | this.markAnswered(this.subjectIds[ind].answer, ind) |
| | | |
| | |
| | | toggleOption (answer) { |
| | | this.answer = answer |
| | | }, |
| | | |
| | | // 根据答案是否为空决定使用哪个答案 |
| | | judgeAnswerIfNull (val) { |
| | | if (this.getAnswer() == '') { |
| | | return val |
| | | } else { |
| | | return this.getAnswer() |
| | | } |
| | | }, |
| | | |
| | | // 根据题目类型返回填写的答案 |
| | | getAnswer () { |
| | | const ref = this.getSubjectRef() |