Commit f57293969c334a8248512006f69d437a0d42aba0
1 parent
87abc4f3
批量设置答案
Showing
8 changed files
with
455 additions
and
226 deletions
src/api/apis/apis.js
| @@ -767,4 +767,11 @@ export default { | @@ -767,4 +767,11 @@ export default { | ||
| 767 | responseType: 'arraybuffer', | 767 | responseType: 'arraybuffer', |
| 768 | }); | 768 | }); |
| 769 | }, | 769 | }, |
| 770 | + // 同步教师账号 | ||
| 771 | + syncUser() { | ||
| 772 | + return service({ | ||
| 773 | + url: setUpUrls.syncUser, | ||
| 774 | + method: "POST", | ||
| 775 | + }); | ||
| 776 | + }, | ||
| 770 | }; | 777 | }; |
src/api/urls/apis.js
| @@ -195,4 +195,6 @@ export default { | @@ -195,4 +195,6 @@ export default { | ||
| 195 | exportSchoolContrast: "/api_html/tenant/exportSchoolContrast", | 195 | exportSchoolContrast: "/api_html/tenant/exportSchoolContrast", |
| 196 | // 导出年级使用对比 | 196 | // 导出年级使用对比 |
| 197 | exportGradeContrast: "/api_html/tenant/exportGradeContrast", | 197 | exportGradeContrast: "/api_html/tenant/exportGradeContrast", |
| 198 | + // 同步教师账号 | ||
| 199 | + syncUser: "/api_html/tenant/syncUser", | ||
| 198 | } | 200 | } |
src/components/setAnswer.vue
| @@ -90,6 +90,7 @@ | @@ -90,6 +90,7 @@ | ||
| 90 | <p>{{ setSubPro(formAns.qusType) }}:</p> | 90 | <p>{{ setSubPro(formAns.qusType) }}:</p> |
| 91 | <p class="ipt"> | 91 | <p class="ipt"> |
| 92 | <el-input | 92 | <el-input |
| 93 | + ref="formAnsIpt" | ||
| 93 | v-if="formAns.qusType == 2 || formAns.qusType == 3" | 94 | v-if="formAns.qusType == 2 || formAns.qusType == 3" |
| 94 | v-model="formAns.answerList" | 95 | v-model="formAns.answerList" |
| 95 | @keydown.native="keydownAnswer($event, formAns.qusType)" | 96 | @keydown.native="keydownAnswer($event, formAns.qusType)" |
| @@ -263,18 +264,21 @@ export default { | @@ -263,18 +264,21 @@ export default { | ||
| 263 | setFormAns(indexs) { | 264 | setFormAns(indexs) { |
| 264 | //初始化要修改的答案 | 265 | //初始化要修改的答案 |
| 265 | this.formAns = { ...this.FormQuestionList[indexs] }; | 266 | this.formAns = { ...this.FormQuestionList[indexs] }; |
| 267 | + let startIndex = this.formAns.endIndex - this.formAns.subNum; | ||
| 266 | let answerList = ""; | 268 | let answerList = ""; |
| 267 | this.FormQuestionList[index].map((item, subIdx) => { | 269 | this.FormQuestionList[index].map((item, subIdx) => { |
| 268 | - answerList += this.setAnswer(item.questionType, item.correctAnswer); | ||
| 269 | - if (subIdx != indexs) { | ||
| 270 | - if (!!item.qusType) { | ||
| 271 | - answerList = ""; | ||
| 272 | - } | ||
| 273 | - } else { | ||
| 274 | - if (item.qusType == 3) { | ||
| 275 | - answerList = answerList.slice(0, -1); | 270 | + if (subIdx >= startIndex) { |
| 271 | + answerList += this.setAnswer(item.questionType, item.correctAnswer); | ||
| 272 | + if (subIdx != indexs) { | ||
| 273 | + if (!!item.qusType) { | ||
| 274 | + answerList = ""; | ||
| 275 | + } | ||
| 276 | + } else { | ||
| 277 | + if (item.qusType == 3) { | ||
| 278 | + answerList = answerList.slice(0, -1); | ||
| 279 | + } | ||
| 280 | + this.formAns.answerList = answerList; | ||
| 276 | } | 281 | } |
| 277 | - this.formAns.answerList = answerList; | ||
| 278 | } | 282 | } |
| 279 | }); | 283 | }); |
| 280 | this.diaSetAns = true; | 284 | this.diaSetAns = true; |
| @@ -292,13 +296,16 @@ export default { | @@ -292,13 +296,16 @@ export default { | ||
| 292 | for (let i = 0; i <= subNum; i++) { | 296 | for (let i = 0; i <= subNum; i++) { |
| 293 | let correctAnswer = ""; | 297 | let correctAnswer = ""; |
| 294 | if (this.formAns.qusType == 2) { | 298 | if (this.formAns.qusType == 2) { |
| 295 | - correctAnswer = this.formAns.answerList[subNum - i]; | 299 | + correctAnswer = this.formAns.answerList[subNum - i] || ""; |
| 296 | } else if (this.formAns.qusType == 3) { | 300 | } else if (this.formAns.qusType == 3) { |
| 297 | - correctAnswer = this.formAns.answerList.split(",")[subNum - i]; | ||
| 298 | - | ||
| 299 | - console.log(this.formAns.answerList.split(",")[subNum - i]); | 301 | + correctAnswer = this.formAns.answerList.split(",")[subNum - i] || ""; |
| 300 | } else if (this.formAns.qusType == 4) { | 302 | } else if (this.formAns.qusType == 4) { |
| 301 | - correctAnswer = this.formAns.answerList[subNum - i] == "✓" ? 1 : 2; | 303 | + correctAnswer = |
| 304 | + this.formAns.answerList[subNum - i] == "✓" | ||
| 305 | + ? 1 | ||
| 306 | + : this.formAns.answerList[subNum - i] == "✗" | ||
| 307 | + ? 2 | ||
| 308 | + : ""; | ||
| 302 | } | 309 | } |
| 303 | this.questionList[EndIndex - i].correctAnswer = correctAnswer; | 310 | this.questionList[EndIndex - i].correctAnswer = correctAnswer; |
| 304 | } | 311 | } |
| @@ -392,9 +399,26 @@ export default { | @@ -392,9 +399,26 @@ export default { | ||
| 392 | } | 399 | } |
| 393 | return txt; | 400 | return txt; |
| 394 | }, | 401 | }, |
| 402 | + insertTxtAndSetcursor(answerList, str) { | ||
| 403 | + let element = this.$refs.formAnsIpt.$el.children[0]; // 获取到指定标签 | ||
| 404 | + let startPos = element.selectionStart; // 获取光标开始的位置 | ||
| 405 | + if (startPos === undefined) { | ||
| 406 | + // 如果没有光标位置 不操作 | ||
| 407 | + return answerList; | ||
| 408 | + } else { | ||
| 409 | + return { | ||
| 410 | + text: | ||
| 411 | + answerList.substring(0, startPos) + | ||
| 412 | + str + | ||
| 413 | + answerList.substring(startPos), // 将文本插入 | ||
| 414 | + startPos: startPos + str.length, | ||
| 415 | + }; | ||
| 416 | + } | ||
| 417 | + }, | ||
| 395 | setMultiple(obj, answer) { | 418 | setMultiple(obj, answer) { |
| 396 | //多选答案设置 | 419 | //多选答案设置 |
| 397 | - obj.answerList += answer; | 420 | + let resault = this.insertTxtAndSetcursor(obj.answerList || "", answer); |
| 421 | + obj.answerList = resault.text; | ||
| 398 | let str = obj.answerList; | 422 | let str = obj.answerList; |
| 399 | let str2 = checkAnswer( | 423 | let str2 = checkAnswer( |
| 400 | str, | 424 | str, |
| @@ -403,6 +427,8 @@ export default { | @@ -403,6 +427,8 @@ export default { | ||
| 403 | obj.answerList.length | 427 | obj.answerList.length |
| 404 | ); | 428 | ); |
| 405 | obj.answerList = str2; | 429 | obj.answerList = str2; |
| 430 | + this.$refs.formAnsIpt.$el.children[0].focus(); | ||
| 431 | + this.$refs.formAnsIpt.$el.children[0].selectionStart = resault.startPos; | ||
| 406 | }, | 432 | }, |
| 407 | changAnswer(sub, option) { | 433 | changAnswer(sub, option) { |
| 408 | //设置多选答案 | 434 | //设置多选答案 |
src/views/examinationPaper/add.vue
| @@ -191,7 +191,11 @@ | @@ -191,7 +191,11 @@ | ||
| 191 | :key="index" | 191 | :key="index" |
| 192 | > | 192 | > |
| 193 | <p class="question-title"> | 193 | <p class="question-title"> |
| 194 | - <el-tooltip effect="dark" :content="question.show?'收起':'展开'" placement="left"> | 194 | + <el-tooltip |
| 195 | + effect="dark" | ||
| 196 | + :content="question.show ? '收起' : '展开'" | ||
| 197 | + placement="left" | ||
| 198 | + > | ||
| 195 | <i | 199 | <i |
| 196 | class="el-icon-caret-right" | 200 | class="el-icon-caret-right" |
| 197 | :class="question.show ? 'active' : ''" | 201 | :class="question.show ? 'active' : ''" |
| @@ -277,33 +281,47 @@ | @@ -277,33 +281,47 @@ | ||
| 277 | </div> | 281 | </div> |
| 278 | <div class="qs-options"> | 282 | <div class="qs-options"> |
| 279 | <p v-if="subQuestions.questionType == 5">--</p> | 283 | <p v-if="subQuestions.questionType == 5">--</p> |
| 280 | - <p | ||
| 281 | - v-else-if="subQuestions.questionType == 4" | ||
| 282 | - class="answer-box" | ||
| 283 | - > | 284 | + <p v-if="subQuestions.questionType == 4" class="answer-box"> |
| 284 | <span | 285 | <span |
| 285 | class="answer-s" | 286 | class="answer-s" |
| 286 | :class="subQuestions.correctAnswer == 1 ? 'active' : ''" | 287 | :class="subQuestions.correctAnswer == 1 ? 'active' : ''" |
| 288 | + @click="subQuestions.correctAnswer = 1" | ||
| 287 | >✓</span | 289 | >✓</span |
| 288 | > | 290 | > |
| 289 | <span | 291 | <span |
| 290 | class="answer-s" | 292 | class="answer-s" |
| 291 | :class="subQuestions.correctAnswer == 2 ? 'active' : ''" | 293 | :class="subQuestions.correctAnswer == 2 ? 'active' : ''" |
| 294 | + @click="subQuestions.correctAnswer = 2" | ||
| 292 | >✗</span | 295 | >✗</span |
| 293 | > | 296 | > |
| 294 | </p> | 297 | </p> |
| 295 | - <p v-else class="answer-box"> | 298 | + <p v-if="subQuestions.questionType == 3" class="answer-box"> |
| 296 | <span | 299 | <span |
| 297 | class="answer-s" | 300 | class="answer-s" |
| 298 | v-for="option in subQuestions.answerOptions.split(',')" | 301 | v-for="option in subQuestions.answerOptions.split(',')" |
| 299 | - :key="option" | ||
| 300 | :class=" | 302 | :class=" |
| 301 | subQuestions.correctAnswer?.includes(option) | 303 | subQuestions.correctAnswer?.includes(option) |
| 302 | ? 'active' | 304 | ? 'active' |
| 303 | : '' | 305 | : '' |
| 304 | " | 306 | " |
| 307 | + :key="option" | ||
| 308 | + @click="changAnswer(subQuestions, option)" | ||
| 309 | + >{{ option }}</span | ||
| 310 | + > | ||
| 311 | + </p> | ||
| 312 | + <p v-if="subQuestions.questionType == 2" class="answer-box"> | ||
| 313 | + <span | ||
| 314 | + class="answer-s" | ||
| 315 | + v-for="option in subQuestions.answerOptions.split(',')" | ||
| 316 | + :class=" | ||
| 317 | + subQuestions.correctAnswer == option ? 'active' : '' | ||
| 318 | + " | ||
| 319 | + :key="option" | ||
| 320 | + @click="subQuestions.correctAnswer = option" | ||
| 305 | >{{ option }}</span | 321 | >{{ option }}</span |
| 306 | > | 322 | > |
| 323 | + </p> | ||
| 324 | + <p class="answer-box"> | ||
| 307 | <el-button | 325 | <el-button |
| 308 | size="mini" | 326 | size="mini" |
| 309 | type="primary" | 327 | type="primary" |
| @@ -601,108 +619,108 @@ | @@ -601,108 +619,108 @@ | ||
| 601 | <span class="m20">共:{{ setNums(question.subQuestions) }}题</span> | 619 | <span class="m20">共:{{ setNums(question.subQuestions) }}题</span> |
| 602 | <span>共:{{ setScore(question) }} 分</span> | 620 | <span>共:{{ setScore(question) }} 分</span> |
| 603 | </p> | 621 | </p> |
| 604 | - <ul class="questions-ul"> | ||
| 605 | - <li class="sub-questions"> | ||
| 606 | - <div class="qs-num">题号</div> | ||
| 607 | - <div class="qs-type">题型</div> | ||
| 608 | - <div class="qs-score">分数</div> | ||
| 609 | - <div class="qs-partScore">漏选得分</div> | ||
| 610 | - <div class="qs-options qs-options2">选项设置</div> | ||
| 611 | - </li> | ||
| 612 | - <li | ||
| 613 | - v-for="(subQuestions, indexs) in question.subQuestions" | ||
| 614 | - :key="indexs" | 622 | + <ul class="questions-ul"> |
| 623 | + <li class="sub-questions"> | ||
| 624 | + <div class="qs-num">题号</div> | ||
| 625 | + <div class="qs-type">题型</div> | ||
| 626 | + <div class="qs-score">分数</div> | ||
| 627 | + <div class="qs-partScore">漏选得分</div> | ||
| 628 | + <div class="qs-options qs-options2">选项设置</div> | ||
| 629 | + </li> | ||
| 630 | + <li | ||
| 631 | + v-for="(subQuestions, indexs) in question.subQuestions" | ||
| 632 | + :key="indexs" | ||
| 633 | + > | ||
| 634 | + <p | ||
| 635 | + class="set-ans-btn" | ||
| 636 | + v-if=" | ||
| 637 | + subQuestions.qusType && | ||
| 638 | + subQuestions.subNum && | ||
| 639 | + subQuestions.subNum > 4 | ||
| 640 | + " | ||
| 615 | > | 641 | > |
| 616 | - <p | ||
| 617 | - class="set-ans-btn" | ||
| 618 | - v-if=" | ||
| 619 | - subQuestions.qusType && | ||
| 620 | - subQuestions.subNum && | ||
| 621 | - subQuestions.subNum > 4 | ||
| 622 | - " | 642 | + <el-button type="primary" @click="setFormAns(indexs, index)" |
| 643 | + >批量设置答案</el-button | ||
| 623 | > | 644 | > |
| 624 | - <el-button type="primary" @click="setFormAns(indexs, index)" | ||
| 625 | - >批量设置答案</el-button | ||
| 626 | - > | ||
| 627 | - </p> | ||
| 628 | - <div v-else class="sub-questions"> | ||
| 629 | - <div class="qs-num"> | ||
| 630 | - {{ setNum(index, indexs, subQuestions) }} | ||
| 631 | - </div> | ||
| 632 | - <div class="qs-type"> | ||
| 633 | - {{ setSubPro(subQuestions.questionType) }} | ||
| 634 | - </div> | ||
| 635 | - <div class="qs-score"> | ||
| 636 | - <el-input-number | ||
| 637 | - class="number-ipt" | ||
| 638 | - size="medium" | ||
| 639 | - :min="1" | ||
| 640 | - :max="200" | ||
| 641 | - :precision="2" | ||
| 642 | - v-model="subQuestions.score" | ||
| 643 | - label="单题分值" | ||
| 644 | - ></el-input-number> | ||
| 645 | - </div> | ||
| 646 | - <div class="qs-partScore"> | ||
| 647 | - <p v-if="subQuestions.questionType != 3">--</p> | ||
| 648 | - <el-input-number | ||
| 649 | - class="number-ipt" | ||
| 650 | - v-else | ||
| 651 | - size="medium" | ||
| 652 | - :min="0" | ||
| 653 | - :precision="2" | ||
| 654 | - :max="subQuestions.score" | ||
| 655 | - :step="0.5" | ||
| 656 | - v-model="subQuestions.partScore" | ||
| 657 | - label="漏选得分" | ||
| 658 | - ></el-input-number> | ||
| 659 | - </div> | ||
| 660 | - <div class="qs-options qs-options2"> | ||
| 661 | - <p v-if="subQuestions.questionType == 5">--</p> | ||
| 662 | - <p v-if="subQuestions.questionType == 4" class="answer-box"> | ||
| 663 | - <span | ||
| 664 | - class="answer-s" | ||
| 665 | - :class="subQuestions.correctAnswer == 1 ? 'active' : ''" | ||
| 666 | - @click="subQuestions.correctAnswer = 1" | ||
| 667 | - >✓</span | ||
| 668 | - > | ||
| 669 | - <span | ||
| 670 | - class="answer-s" | ||
| 671 | - :class="subQuestions.correctAnswer == 2 ? 'active' : ''" | ||
| 672 | - @click="subQuestions.correctAnswer = 2" | ||
| 673 | - >✗</span | ||
| 674 | - > | ||
| 675 | - </p> | ||
| 676 | - <p v-if="subQuestions.questionType == 3" class="answer-box"> | ||
| 677 | - <span | ||
| 678 | - class="answer-s" | ||
| 679 | - v-for="option in subQuestions.answerOptions.split(',')" | ||
| 680 | - :class=" | ||
| 681 | - subQuestions.correctAnswer?.includes(option) | ||
| 682 | - ? 'active' | ||
| 683 | - : '' | ||
| 684 | - " | ||
| 685 | - :key="option" | ||
| 686 | - @click="changAnswer(subQuestions, option)" | ||
| 687 | - >{{ option }}</span | ||
| 688 | - > | ||
| 689 | - </p> | ||
| 690 | - <p v-if="subQuestions.questionType == 2" class="answer-box"> | ||
| 691 | - <span | ||
| 692 | - class="answer-s" | ||
| 693 | - v-for="option in subQuestions.answerOptions.split(',')" | ||
| 694 | - :class=" | ||
| 695 | - subQuestions.correctAnswer == option ? 'active' : '' | ||
| 696 | - " | ||
| 697 | - :key="option" | ||
| 698 | - @click="subQuestions.correctAnswer = option" | ||
| 699 | - >{{ option }}</span | ||
| 700 | - > | ||
| 701 | - </p> | ||
| 702 | - </div> | 645 | + </p> |
| 646 | + <div v-else class="sub-questions"> | ||
| 647 | + <div class="qs-num"> | ||
| 648 | + {{ setNum(index, indexs, subQuestions) }} | ||
| 703 | </div> | 649 | </div> |
| 704 | - </li> | ||
| 705 | - </ul> | 650 | + <div class="qs-type"> |
| 651 | + {{ setSubPro(subQuestions.questionType) }} | ||
| 652 | + </div> | ||
| 653 | + <div class="qs-score"> | ||
| 654 | + <el-input-number | ||
| 655 | + class="number-ipt" | ||
| 656 | + size="medium" | ||
| 657 | + :min="1" | ||
| 658 | + :max="200" | ||
| 659 | + :precision="2" | ||
| 660 | + v-model="subQuestions.score" | ||
| 661 | + label="单题分值" | ||
| 662 | + ></el-input-number> | ||
| 663 | + </div> | ||
| 664 | + <div class="qs-partScore"> | ||
| 665 | + <p v-if="subQuestions.questionType != 3">--</p> | ||
| 666 | + <el-input-number | ||
| 667 | + class="number-ipt" | ||
| 668 | + v-else | ||
| 669 | + size="medium" | ||
| 670 | + :min="0" | ||
| 671 | + :precision="2" | ||
| 672 | + :max="subQuestions.score" | ||
| 673 | + :step="0.5" | ||
| 674 | + v-model="subQuestions.partScore" | ||
| 675 | + label="漏选得分" | ||
| 676 | + ></el-input-number> | ||
| 677 | + </div> | ||
| 678 | + <div class="qs-options qs-options2"> | ||
| 679 | + <p v-if="subQuestions.questionType == 5">--</p> | ||
| 680 | + <p v-if="subQuestions.questionType == 4" class="answer-box"> | ||
| 681 | + <span | ||
| 682 | + class="answer-s" | ||
| 683 | + :class="subQuestions.correctAnswer == 1 ? 'active' : ''" | ||
| 684 | + @click="subQuestions.correctAnswer = 1" | ||
| 685 | + >✓</span | ||
| 686 | + > | ||
| 687 | + <span | ||
| 688 | + class="answer-s" | ||
| 689 | + :class="subQuestions.correctAnswer == 2 ? 'active' : ''" | ||
| 690 | + @click="subQuestions.correctAnswer = 2" | ||
| 691 | + >✗</span | ||
| 692 | + > | ||
| 693 | + </p> | ||
| 694 | + <p v-if="subQuestions.questionType == 3" class="answer-box"> | ||
| 695 | + <span | ||
| 696 | + class="answer-s" | ||
| 697 | + v-for="option in subQuestions.answerOptions.split(',')" | ||
| 698 | + :class=" | ||
| 699 | + subQuestions.correctAnswer?.includes(option) | ||
| 700 | + ? 'active' | ||
| 701 | + : '' | ||
| 702 | + " | ||
| 703 | + :key="option" | ||
| 704 | + @click="changAnswer(subQuestions, option)" | ||
| 705 | + >{{ option }}</span | ||
| 706 | + > | ||
| 707 | + </p> | ||
| 708 | + <p v-if="subQuestions.questionType == 2" class="answer-box"> | ||
| 709 | + <span | ||
| 710 | + class="answer-s" | ||
| 711 | + v-for="option in subQuestions.answerOptions.split(',')" | ||
| 712 | + :class=" | ||
| 713 | + subQuestions.correctAnswer == option ? 'active' : '' | ||
| 714 | + " | ||
| 715 | + :key="option" | ||
| 716 | + @click="subQuestions.correctAnswer = option" | ||
| 717 | + >{{ option }}</span | ||
| 718 | + > | ||
| 719 | + </p> | ||
| 720 | + </div> | ||
| 721 | + </div> | ||
| 722 | + </li> | ||
| 723 | + </ul> | ||
| 706 | </div> | 724 | </div> |
| 707 | <el-dialog | 725 | <el-dialog |
| 708 | title="批量设置答案" | 726 | title="批量设置答案" |
| @@ -719,6 +737,7 @@ | @@ -719,6 +737,7 @@ | ||
| 719 | <p class="ipt"> | 737 | <p class="ipt"> |
| 720 | <el-input | 738 | <el-input |
| 721 | v-if="formAns.qusType == 2 || formAns.qusType == 3" | 739 | v-if="formAns.qusType == 2 || formAns.qusType == 3" |
| 740 | + ref="formAnsIpt" | ||
| 722 | v-model="formAns.answerList" | 741 | v-model="formAns.answerList" |
| 723 | @keydown.native="keydownAnswer($event, formAns.qusType)" | 742 | @keydown.native="keydownAnswer($event, formAns.qusType)" |
| 724 | @input="setAllAnswer($event, formAns.qusType)" | 743 | @input="setAllAnswer($event, formAns.qusType)" |
| @@ -1047,27 +1066,47 @@ export default { | @@ -1047,27 +1066,47 @@ export default { | ||
| 1047 | //初始化要修改的答案 | 1066 | //初始化要修改的答案 |
| 1048 | this.formAns = { ...this.form.questionList[index].subQuestions[indexs] }; | 1067 | this.formAns = { ...this.form.questionList[index].subQuestions[indexs] }; |
| 1049 | this.formAns.listIndex = index; | 1068 | this.formAns.listIndex = index; |
| 1069 | + let startIndex = this.formAns.endIndex - this.formAns.subNum; | ||
| 1050 | this.formAns.answerList = []; | 1070 | this.formAns.answerList = []; |
| 1051 | let answerList = ""; | 1071 | let answerList = ""; |
| 1052 | this.form.questionList[index].subQuestions.map((item, subIdx) => { | 1072 | this.form.questionList[index].subQuestions.map((item, subIdx) => { |
| 1053 | - answerList += this.setAnswer(item.questionType, item.correctAnswer); | ||
| 1054 | - if (subIdx != indexs) { | ||
| 1055 | - if (!!item.qusType) { | ||
| 1056 | - answerList = ""; | ||
| 1057 | - } | ||
| 1058 | - } else { | ||
| 1059 | - if (item.qusType == 3) { | ||
| 1060 | - answerList = answerList.slice(0, -1); | 1073 | + if (subIdx >= startIndex) { |
| 1074 | + answerList += this.setAnswer(item.questionType, item.correctAnswer); | ||
| 1075 | + if (subIdx != indexs) { | ||
| 1076 | + if (!!item.qusType) { | ||
| 1077 | + answerList = ""; | ||
| 1078 | + } | ||
| 1079 | + } else { | ||
| 1080 | + if (item.qusType == 3) { | ||
| 1081 | + answerList = answerList.slice(0, -1); | ||
| 1082 | + } | ||
| 1083 | + this.formAns.answerList = answerList; | ||
| 1061 | } | 1084 | } |
| 1062 | - this.formAns.answerList = answerList; | ||
| 1063 | } | 1085 | } |
| 1064 | }); | 1086 | }); |
| 1065 | 1087 | ||
| 1066 | this.diaSetAns = true; | 1088 | this.diaSetAns = true; |
| 1067 | }, | 1089 | }, |
| 1090 | + insertTxtAndSetcursor(answerList, str) { | ||
| 1091 | + let element = this.$refs.formAnsIpt.$el.children[0]; // 获取到指定标签 | ||
| 1092 | + let startPos = element.selectionStart; // 获取光标开始的位置 | ||
| 1093 | + if (startPos === undefined) { | ||
| 1094 | + // 如果没有光标位置 不操作 | ||
| 1095 | + return answerList; | ||
| 1096 | + } else { | ||
| 1097 | + return { | ||
| 1098 | + text: | ||
| 1099 | + answerList.substring(0, startPos) + | ||
| 1100 | + str + | ||
| 1101 | + answerList.substring(startPos), // 将文本插入 | ||
| 1102 | + startPos: startPos + str.length, | ||
| 1103 | + }; | ||
| 1104 | + } | ||
| 1105 | + }, | ||
| 1068 | setMultiple(obj, answer) { | 1106 | setMultiple(obj, answer) { |
| 1069 | //多选答案设置 | 1107 | //多选答案设置 |
| 1070 | - obj.answerList += answer; | 1108 | + let resault = this.insertTxtAndSetcursor(obj.answerList || "", answer); |
| 1109 | + obj.answerList = resault.text; | ||
| 1071 | let str = obj.answerList; | 1110 | let str = obj.answerList; |
| 1072 | let str2; | 1111 | let str2; |
| 1073 | if (!!obj.answerOptions) { | 1112 | if (!!obj.answerOptions) { |
| @@ -1081,6 +1120,8 @@ export default { | @@ -1081,6 +1120,8 @@ export default { | ||
| 1081 | str2 = checkAnswer(str, 3, obj.selectNum, obj.answerList.length); | 1120 | str2 = checkAnswer(str, 3, obj.selectNum, obj.answerList.length); |
| 1082 | } | 1121 | } |
| 1083 | obj.answerList = str2; | 1122 | obj.answerList = str2; |
| 1123 | + this.$refs.formAnsIpt.$el.children[0].focus(); | ||
| 1124 | + this.$refs.formAnsIpt.$el.children[0].selectionStart = resault.startPos; | ||
| 1084 | }, | 1125 | }, |
| 1085 | saveFormAns() { | 1126 | saveFormAns() { |
| 1086 | //批量修改答案 | 1127 | //批量修改答案 |
| @@ -1098,10 +1139,9 @@ export default { | @@ -1098,10 +1139,9 @@ export default { | ||
| 1098 | for (let i = 0; i <= subNum; i++) { | 1139 | for (let i = 0; i <= subNum; i++) { |
| 1099 | let correctAnswer = ""; | 1140 | let correctAnswer = ""; |
| 1100 | if (this.formAns.qusType == 2) { | 1141 | if (this.formAns.qusType == 2) { |
| 1101 | - correctAnswer = this.formAns.answerList[subNum - i]; | 1142 | + correctAnswer = this.formAns.answerList[subNum - i] || ""; |
| 1102 | } else if (this.formAns.qusType == 3) { | 1143 | } else if (this.formAns.qusType == 3) { |
| 1103 | - correctAnswer = this.formAns.answerList.split(",")[subNum - i]; | ||
| 1104 | - console.log(this.formAns.answerList.split(",")[subNum - i]); | 1144 | + correctAnswer = this.formAns.answerList.split(",")[subNum - i] || ""; |
| 1105 | } else if (this.formAns.qusType == 4) { | 1145 | } else if (this.formAns.qusType == 4) { |
| 1106 | correctAnswer = | 1146 | correctAnswer = |
| 1107 | this.formAns.answerList[subNum - i] == "✓" | 1147 | this.formAns.answerList[subNum - i] == "✓" |
| @@ -1548,9 +1588,9 @@ export default { | @@ -1548,9 +1588,9 @@ export default { | ||
| 1548 | if (this.saveLoading) return; | 1588 | if (this.saveLoading) return; |
| 1549 | this.saveLoading = true; | 1589 | this.saveLoading = true; |
| 1550 | this.formatQuestionList(); | 1590 | this.formatQuestionList(); |
| 1551 | - let formDatas = deepClone(this.form) | 1591 | + let formDatas = deepClone(this.form); |
| 1552 | for (let i = 0; i < formDatas.questionList.length; i++) { | 1592 | for (let i = 0; i < formDatas.questionList.length; i++) { |
| 1553 | - delete formDatas.questionList[i].show | 1593 | + delete formDatas.questionList[i].show; |
| 1554 | } | 1594 | } |
| 1555 | const { data, status, info } = await this.$request.addPaper({ | 1595 | const { data, status, info } = await this.$request.addPaper({ |
| 1556 | ...formDatas, | 1596 | ...formDatas, |
src/views/examinationPaper/edit.vue
| @@ -71,7 +71,17 @@ | @@ -71,7 +71,17 @@ | ||
| 71 | </div> | 71 | </div> |
| 72 | <div class="qs-partScore"> | 72 | <div class="qs-partScore"> |
| 73 | <p v-if="subQuestions.questionType != 3">--</p> | 73 | <p v-if="subQuestions.questionType != 3">--</p> |
| 74 | - <p v-else>{{ subQuestions.partScore }}</p> | 74 | + <el-input-number |
| 75 | + class="number-ipt" | ||
| 76 | + v-else | ||
| 77 | + size="medium" | ||
| 78 | + :min="0" | ||
| 79 | + :precision="2" | ||
| 80 | + :max="subQuestions.score" | ||
| 81 | + :step="0.5" | ||
| 82 | + v-model="subQuestions.partScore" | ||
| 83 | + label="漏选得分" | ||
| 84 | + ></el-input-number> | ||
| 75 | </div> | 85 | </div> |
| 76 | <div class="qs-options qs-options2"> | 86 | <div class="qs-options qs-options2"> |
| 77 | <p v-if="subQuestions.questionType == 5">--</p> | 87 | <p v-if="subQuestions.questionType == 5">--</p> |
| @@ -160,7 +170,17 @@ | @@ -160,7 +170,17 @@ | ||
| 160 | </div> | 170 | </div> |
| 161 | <div class="qs-partScore"> | 171 | <div class="qs-partScore"> |
| 162 | <p v-if="subQuestions.questionType != 3">--</p> | 172 | <p v-if="subQuestions.questionType != 3">--</p> |
| 163 | - <p v-else>{{ subQuestions.partScore }}</p> | 173 | + <el-input-number |
| 174 | + class="number-ipt" | ||
| 175 | + v-else | ||
| 176 | + size="medium" | ||
| 177 | + :min="0" | ||
| 178 | + :precision="2" | ||
| 179 | + :max="subQuestions.score" | ||
| 180 | + :step="0.5" | ||
| 181 | + v-model="subQuestions.partScore" | ||
| 182 | + label="漏选得分" | ||
| 183 | + ></el-input-number> | ||
| 164 | </div> | 184 | </div> |
| 165 | <div class="qs-options qs-options2"> | 185 | <div class="qs-options qs-options2"> |
| 166 | <p v-if="subQuestions.questionType == 5">--</p> | 186 | <p v-if="subQuestions.questionType == 5">--</p> |
| @@ -234,6 +254,7 @@ | @@ -234,6 +254,7 @@ | ||
| 234 | <p>{{ setSubPro(formAns.qusType) }}:</p> | 254 | <p>{{ setSubPro(formAns.qusType) }}:</p> |
| 235 | <p class="ipt"> | 255 | <p class="ipt"> |
| 236 | <el-input | 256 | <el-input |
| 257 | + ref="formAnsIpt" | ||
| 237 | v-if="formAns.qusType == 2 || formAns.qusType == 3" | 258 | v-if="formAns.qusType == 2 || formAns.qusType == 3" |
| 238 | v-model="formAns.answerList" | 259 | v-model="formAns.answerList" |
| 239 | @keydown.native="keydownAnswer($event, formAns.qusType)" | 260 | @keydown.native="keydownAnswer($event, formAns.qusType)" |
| @@ -476,9 +497,26 @@ export default { | @@ -476,9 +497,26 @@ export default { | ||
| 476 | } | 497 | } |
| 477 | return txt; | 498 | return txt; |
| 478 | }, | 499 | }, |
| 500 | + insertTxtAndSetcursor(answerList, str) { | ||
| 501 | + let element = this.$refs.formAnsIpt.$el.children[0]; // 获取到指定标签 | ||
| 502 | + let startPos = element.selectionStart; // 获取光标开始的位置 | ||
| 503 | + if (startPos === undefined) { | ||
| 504 | + // 如果没有光标位置 不操作 | ||
| 505 | + return answerList; | ||
| 506 | + } else { | ||
| 507 | + return { | ||
| 508 | + text: | ||
| 509 | + answerList.substring(0, startPos) + | ||
| 510 | + str + | ||
| 511 | + answerList.substring(startPos), // 将文本插入 | ||
| 512 | + startPos: startPos + str.length, | ||
| 513 | + }; | ||
| 514 | + } | ||
| 515 | + }, | ||
| 479 | setMultiple(obj, answer) { | 516 | setMultiple(obj, answer) { |
| 480 | //多选答案设置 | 517 | //多选答案设置 |
| 481 | - obj.answerList += answer; | 518 | + let resault = this.insertTxtAndSetcursor(obj.answerList || "", answer); |
| 519 | + obj.answerList = resault.text; | ||
| 482 | let str = obj.answerList; | 520 | let str = obj.answerList; |
| 483 | let str2 = checkAnswer( | 521 | let str2 = checkAnswer( |
| 484 | str, | 522 | str, |
| @@ -487,6 +525,8 @@ export default { | @@ -487,6 +525,8 @@ export default { | ||
| 487 | obj.answerList.length | 525 | obj.answerList.length |
| 488 | ); | 526 | ); |
| 489 | obj.answerList = str2; | 527 | obj.answerList = str2; |
| 528 | + this.$refs.formAnsIpt.$el.children[0].focus(); | ||
| 529 | + this.$refs.formAnsIpt.$el.children[0].selectionStart = resault.startPos; | ||
| 490 | }, | 530 | }, |
| 491 | setFormAns(indexs, index) { | 531 | setFormAns(indexs, index) { |
| 492 | //初始化要修改的答案 | 532 | //初始化要修改的答案 |
| @@ -494,34 +534,40 @@ export default { | @@ -494,34 +534,40 @@ export default { | ||
| 494 | this.formAns = { ...this.questionList[index].subQuestions[indexs] }; | 534 | this.formAns = { ...this.questionList[index].subQuestions[indexs] }; |
| 495 | this.formAns.listIndex = index; | 535 | this.formAns.listIndex = index; |
| 496 | let answerList = ""; | 536 | let answerList = ""; |
| 537 | + let startIndex = this.formAns.endIndex - this.formAns.subNum; | ||
| 497 | this.questionList[index].subQuestions.map((item, subIdx) => { | 538 | this.questionList[index].subQuestions.map((item, subIdx) => { |
| 498 | - answerList += this.setAnswer(item.questionType, item.correctAnswer); | ||
| 499 | - if (subIdx != indexs) { | ||
| 500 | - if (!!item.qusType) { | ||
| 501 | - answerList = ""; | ||
| 502 | - } | ||
| 503 | - } else { | ||
| 504 | - if (item.qusType == 3) { | ||
| 505 | - answerList = answerList.slice(0, -1); | 539 | + if (subIdx >= startIndex) { |
| 540 | + answerList += this.setAnswer(item.questionType, item.correctAnswer); | ||
| 541 | + if (subIdx != indexs) { | ||
| 542 | + if (!!item.qusType) { | ||
| 543 | + answerList = ""; | ||
| 544 | + } | ||
| 545 | + } else { | ||
| 546 | + if (item.qusType == 3) { | ||
| 547 | + answerList = answerList.slice(0, -1); | ||
| 548 | + } | ||
| 549 | + this.formAns.answerList = answerList; | ||
| 506 | } | 550 | } |
| 507 | - this.formAns.answerList = answerList; | ||
| 508 | } | 551 | } |
| 509 | }); | 552 | }); |
| 510 | } else { | 553 | } else { |
| 511 | this.formAns = { ...this.questionList[indexs] }; | 554 | this.formAns = { ...this.questionList[indexs] }; |
| 555 | + let startIndex = this.formAns.endIndex - this.formAns.subNum; | ||
| 512 | this.formAns.listIndex = indexs; | 556 | this.formAns.listIndex = indexs; |
| 513 | let answerList = ""; | 557 | let answerList = ""; |
| 514 | this.questionList[index].map((item, subIdx) => { | 558 | this.questionList[index].map((item, subIdx) => { |
| 515 | - answerList += this.setAnswer(item.questionType, item.correctAnswer); | ||
| 516 | - if (subIdx != indexs) { | ||
| 517 | - if (!!item.qusType) { | ||
| 518 | - answerList = ""; | ||
| 519 | - } | ||
| 520 | - } else { | ||
| 521 | - if (item.qusType == 3) { | ||
| 522 | - answerList = answerList.slice(0, -1); | 559 | + if (subIdx >= startIndex) { |
| 560 | + answerList += this.setAnswer(item.questionType, item.correctAnswer); | ||
| 561 | + if (subIdx != indexs) { | ||
| 562 | + if (!!item.qusType) { | ||
| 563 | + answerList = ""; | ||
| 564 | + } | ||
| 565 | + } else { | ||
| 566 | + if (item.qusType == 3) { | ||
| 567 | + answerList = answerList.slice(0, -1); | ||
| 568 | + } | ||
| 569 | + this.formAns.answerList = answerList; | ||
| 523 | } | 570 | } |
| 524 | - this.formAns.answerList = answerList; | ||
| 525 | } | 571 | } |
| 526 | }); | 572 | }); |
| 527 | } | 573 | } |
| @@ -552,13 +598,16 @@ export default { | @@ -552,13 +598,16 @@ export default { | ||
| 552 | for (let i = 0; i <= subNum; i++) { | 598 | for (let i = 0; i <= subNum; i++) { |
| 553 | let correctAnswer = ""; | 599 | let correctAnswer = ""; |
| 554 | if (this.formAns.qusType == 2) { | 600 | if (this.formAns.qusType == 2) { |
| 555 | - correctAnswer = this.formAns.answerList[subNum - i]; | 601 | + correctAnswer = this.formAns.answerList[subNum - i] || ""; |
| 556 | } else if (this.formAns.qusType == 3) { | 602 | } else if (this.formAns.qusType == 3) { |
| 557 | - correctAnswer = this.formAns.answerList.split(",")[subNum - i]; | ||
| 558 | - | ||
| 559 | - console.log(this.formAns.answerList.split(",")[subNum - i]); | 603 | + correctAnswer = this.formAns.answerList.split(",")[subNum - i] || ""; |
| 560 | } else if (this.formAns.qusType == 4) { | 604 | } else if (this.formAns.qusType == 4) { |
| 561 | - correctAnswer = this.formAns.answerList[subNum - i] == "✓" ? 1 : 2; | 605 | + correctAnswer = |
| 606 | + this.formAns.answerList[subNum - i] == "✓" | ||
| 607 | + ? 1 | ||
| 608 | + : this.formAns.answerList[subNum - i] == "✗" | ||
| 609 | + ? 2 | ||
| 610 | + : ""; | ||
| 562 | } | 611 | } |
| 563 | if (this.questionList[0].subQuestions) { | 612 | if (this.questionList[0].subQuestions) { |
| 564 | this.questionList[this.formAns.listIndex].subQuestions[ | 613 | this.questionList[this.formAns.listIndex].subQuestions[ |
| @@ -732,6 +781,7 @@ export default { | @@ -732,6 +781,7 @@ export default { | ||
| 732 | } | 781 | } |
| 733 | } | 782 | } |
| 734 | } | 783 | } |
| 784 | + console.log(this.questionList); | ||
| 735 | } else { | 785 | } else { |
| 736 | this.$message.error(info); | 786 | this.$message.error(info); |
| 737 | } | 787 | } |
src/views/setUp/account.vue
| @@ -16,7 +16,12 @@ | @@ -16,7 +16,12 @@ | ||
| 16 | @click="diaUp = true" | 16 | @click="diaUp = true" |
| 17 | ></el-button> | 17 | ></el-button> |
| 18 | </el-tooltip> --> | 18 | </el-tooltip> --> |
| 19 | - <el-tooltip effect="dark" content="添加账号" placement="bottom" v-if="!code"> | 19 | + <el-tooltip |
| 20 | + effect="dark" | ||
| 21 | + content="添加账号" | ||
| 22 | + placement="bottom" | ||
| 23 | + v-if="!code" | ||
| 24 | + > | ||
| 20 | <el-button | 25 | <el-button |
| 21 | type="primary" | 26 | type="primary" |
| 22 | icon="el-icon-plus" | 27 | icon="el-icon-plus" |
| @@ -28,6 +33,7 @@ | @@ -28,6 +33,7 @@ | ||
| 28 | </el-tooltip> | 33 | </el-tooltip> |
| 29 | <el-tooltip effect="dark" content="账号同步" placement="bottom" v-else> | 34 | <el-tooltip effect="dark" content="账号同步" placement="bottom" v-else> |
| 30 | <el-button | 35 | <el-button |
| 36 | + v-loading="syncLoading" | ||
| 31 | type="primary" | 37 | type="primary" |
| 32 | icon="el-icon-refresh" | 38 | icon="el-icon-refresh" |
| 33 | size="mini" | 39 | size="mini" |
| @@ -360,12 +366,13 @@ import { encryptLoginPassword } from "@/utils"; | @@ -360,12 +366,13 @@ import { encryptLoginPassword } from "@/utils"; | ||
| 360 | export default { | 366 | export default { |
| 361 | data() { | 367 | data() { |
| 362 | return { | 368 | return { |
| 363 | - code:"", | 369 | + code: "", |
| 364 | role: "", | 370 | role: "", |
| 365 | diaUp: false, | 371 | diaUp: false, |
| 366 | diaAdd: false, | 372 | diaAdd: false, |
| 367 | url: "", //上传地址 | 373 | url: "", //上传地址 |
| 368 | loading: false, | 374 | loading: false, |
| 375 | + syncLoading: false, | ||
| 369 | diaCount: false, | 376 | diaCount: false, |
| 370 | tenantRoleList: [], | 377 | tenantRoleList: [], |
| 371 | regionList: [], | 378 | regionList: [], |
| @@ -439,10 +446,16 @@ export default { | @@ -439,10 +446,16 @@ export default { | ||
| 439 | this._QueryData(4); | 446 | this._QueryData(4); |
| 440 | }, | 447 | }, |
| 441 | methods: { | 448 | methods: { |
| 442 | - async refreshAcc(){//长水账号同步 | ||
| 443 | - const { data, status, info } = await this.$request.roleList(); | 449 | + async refreshAcc() { |
| 450 | + //长水账号同步 | ||
| 451 | + if (this.syncLoading) return; | ||
| 452 | + this.syncLoading = true; | ||
| 453 | + const { data, status, info } = await this.$request.syncUser(); | ||
| 454 | + this.syncLoading = false; | ||
| 444 | if (status === 0) { | 455 | if (status === 0) { |
| 445 | - this._QueryData(4); | 456 | + this.$message.success("同步中,请稍后刷新重试~"); |
| 457 | + // this._QueryData(4); | ||
| 458 | + | ||
| 446 | } else { | 459 | } else { |
| 447 | this.$message.error(info); | 460 | this.$message.error(info); |
| 448 | } | 461 | } |
src/views/setUp/student.vue
| @@ -4,8 +4,23 @@ | @@ -4,8 +4,23 @@ | ||
| 4 | <template slot="title"> | 4 | <template slot="title"> |
| 5 | <span>学生管理</span> | 5 | <span>学生管理</span> |
| 6 | </template> | 6 | </template> |
| 7 | - <template slot="btns" v-if="!code"> | ||
| 8 | - <el-tooltip effect="dark" content="添加学生" placement="bottom"> | 7 | + <template slot="btns" v-if="role == 'ROLE_XUEXIAO'"> |
| 8 | + <el-tooltip effect="dark" content="设置答题器" placement="bottom"> | ||
| 9 | + <el-button | ||
| 10 | + type="primary" | ||
| 11 | + icon="el-icon-upload2" | ||
| 12 | + size="mini" | ||
| 13 | + plain | ||
| 14 | + circle | ||
| 15 | + @click="diaUp = true" | ||
| 16 | + ></el-button> | ||
| 17 | + </el-tooltip> | ||
| 18 | + <el-tooltip | ||
| 19 | + v-if="!code" | ||
| 20 | + effect="dark" | ||
| 21 | + content="添加学生" | ||
| 22 | + placement="bottom" | ||
| 23 | + > | ||
| 9 | <el-button | 24 | <el-button |
| 10 | type="primary" | 25 | type="primary" |
| 11 | icon="el-icon-plus" | 26 | icon="el-icon-plus" |
| @@ -17,6 +32,7 @@ | @@ -17,6 +32,7 @@ | ||
| 17 | </el-tooltip> | 32 | </el-tooltip> |
| 18 | </template> | 33 | </template> |
| 19 | </back-box> | 34 | </back-box> |
| 35 | + | ||
| 20 | <div class="page-content"> | 36 | <div class="page-content"> |
| 21 | <div class="stu-box"> | 37 | <div class="stu-box"> |
| 22 | <div class="stu-list"> | 38 | <div class="stu-list"> |
| @@ -193,6 +209,22 @@ | @@ -193,6 +209,22 @@ | ||
| 193 | <el-button @click="diaClass = false">取 消</el-button> | 209 | <el-button @click="diaClass = false">取 消</el-button> |
| 194 | </div> | 210 | </div> |
| 195 | </el-dialog> | 211 | </el-dialog> |
| 212 | + <el-dialog title="设置答题器" :visible.sync="diaUp" width="600"> | ||
| 213 | + <up-load | ||
| 214 | + id="downTeacher" | ||
| 215 | + :url="url" | ||
| 216 | + @upSuccess="upSuccess" | ||
| 217 | + fileName="学生信息与答题器名单" | ||
| 218 | + > | ||
| 219 | + <p class="down-txt" slot="down"> | ||
| 220 | + 通过Excel名单导入学生信息与答题器名单,点击 | ||
| 221 | + <el-link type="danger" @click="downExcel">模板下载</el-link> 。 | ||
| 222 | + </p> | ||
| 223 | + </up-load> | ||
| 224 | + <div class="dialog-footer" slot="footer"> | ||
| 225 | + <el-button @click="diaUp = false">取 消</el-button> | ||
| 226 | + </div> | ||
| 227 | + </el-dialog> | ||
| 196 | </div> | 228 | </div> |
| 197 | </template> | 229 | </template> |
| 198 | 230 | ||
| @@ -202,6 +234,8 @@ export default { | @@ -202,6 +234,8 @@ export default { | ||
| 202 | data() { | 234 | data() { |
| 203 | return { | 235 | return { |
| 204 | code: "", | 236 | code: "", |
| 237 | + role: "", | ||
| 238 | + diaUp: false, | ||
| 205 | url: "", | 239 | url: "", |
| 206 | diaStu: false, | 240 | diaStu: false, |
| 207 | diaClass: false, | 241 | diaClass: false, |
| @@ -254,6 +288,13 @@ export default { | @@ -254,6 +288,13 @@ export default { | ||
| 254 | }, | 288 | }, |
| 255 | async created() { | 289 | async created() { |
| 256 | this.code = localStorage.getItem("csCode") || ""; | 290 | this.code = localStorage.getItem("csCode") || ""; |
| 291 | + let role = ""; | ||
| 292 | + this.$store.getters.info.permissions.map((item) => { | ||
| 293 | + if (item.roleName == this.$store.getters.info.showRoleName) { | ||
| 294 | + role = item.role; | ||
| 295 | + } | ||
| 296 | + }); | ||
| 297 | + this.role = role ? role : this.$store.getters.info.permissions[0].role; | ||
| 257 | await this._QueryDataGrade(); | 298 | await this._QueryDataGrade(); |
| 258 | await this._QueryClass(); | 299 | await this._QueryClass(); |
| 259 | this._QueryData(3); | 300 | this._QueryData(3); |
| @@ -300,6 +341,26 @@ export default { | @@ -300,6 +341,26 @@ export default { | ||
| 300 | } | 341 | } |
| 301 | }); | 342 | }); |
| 302 | }, | 343 | }, |
| 344 | + upSuccess() { | ||
| 345 | + //导入成功 | ||
| 346 | + this.diaUp = false; | ||
| 347 | + this._QueryData(3); | ||
| 348 | + }, | ||
| 349 | + async downExcel() { | ||
| 350 | + this.loadingDown = true; | ||
| 351 | + let data = await this.$request.subjectiveScoreTemplate({ | ||
| 352 | + classId: this.query.classId, | ||
| 353 | + }); | ||
| 354 | + this.loadingDown = false; | ||
| 355 | + if (data && !data.code) { | ||
| 356 | + let blob = new Blob([data], { | ||
| 357 | + type: "application/vnd.ms-excel;charset=utf-8", | ||
| 358 | + }); | ||
| 359 | + downloadFile(`主观题模版.xlsx`, blob); | ||
| 360 | + } else { | ||
| 361 | + this.$message.error(data.info); | ||
| 362 | + } | ||
| 363 | + }, | ||
| 303 | async removeStu(obj, index) { | 364 | async removeStu(obj, index) { |
| 304 | const { data, status, info } = await this.$request.delStudent({ | 365 | const { data, status, info } = await this.$request.delStudent({ |
| 305 | studentId: obj.id, | 366 | studentId: obj.id, |
| @@ -410,19 +471,6 @@ export default { | @@ -410,19 +471,6 @@ export default { | ||
| 410 | this.$message.error(info); | 471 | this.$message.error(info); |
| 411 | } | 472 | } |
| 412 | }, | 473 | }, |
| 413 | - async downExcel() { | ||
| 414 | - let data = await this.$request.downDevice({ | ||
| 415 | - id: this.id, | ||
| 416 | - }); | ||
| 417 | - if (data && !data.code) { | ||
| 418 | - let blob = new Blob([data], { | ||
| 419 | - type: "application/vnd.ms-excel;charset=utf-8", | ||
| 420 | - }); | ||
| 421 | - downloadFile(`设备信息.xlsx`, blob); | ||
| 422 | - } else { | ||
| 423 | - this.$message.error(data.info); | ||
| 424 | - } | ||
| 425 | - }, | ||
| 426 | }, | 474 | }, |
| 427 | }; | 475 | }; |
| 428 | </script> | 476 | </script> |
src/views/test/editAnswer.vue
| @@ -53,7 +53,17 @@ | @@ -53,7 +53,17 @@ | ||
| 53 | </div> | 53 | </div> |
| 54 | <div class="qs-partScore"> | 54 | <div class="qs-partScore"> |
| 55 | <p v-if="subQuestions.questionType != 3">--</p> | 55 | <p v-if="subQuestions.questionType != 3">--</p> |
| 56 | - <p v-else>{{ subQuestions.partScore }}</p> | 56 | + <el-input-number |
| 57 | + class="number-ipt" | ||
| 58 | + v-else | ||
| 59 | + size="medium" | ||
| 60 | + :min="0" | ||
| 61 | + :precision="2" | ||
| 62 | + :max="subQuestions.score" | ||
| 63 | + :step="0.5" | ||
| 64 | + v-model="subQuestions.partScore" | ||
| 65 | + label="漏选得分" | ||
| 66 | + ></el-input-number> | ||
| 57 | </div> | 67 | </div> |
| 58 | <div class="qs-options qs-options2"> | 68 | <div class="qs-options qs-options2"> |
| 59 | <p v-if="subQuestions.questionType == 5">--</p> | 69 | <p v-if="subQuestions.questionType == 5">--</p> |
| @@ -142,7 +152,17 @@ | @@ -142,7 +152,17 @@ | ||
| 142 | </div> | 152 | </div> |
| 143 | <div class="qs-partScore"> | 153 | <div class="qs-partScore"> |
| 144 | <p v-if="subQuestions.questionType != 3">--</p> | 154 | <p v-if="subQuestions.questionType != 3">--</p> |
| 145 | - <p v-else>{{ subQuestions.partScore }}</p> | 155 | + <el-input-number |
| 156 | + class="number-ipt" | ||
| 157 | + v-else | ||
| 158 | + size="medium" | ||
| 159 | + :min="0" | ||
| 160 | + :precision="2" | ||
| 161 | + :max="subQuestions.score" | ||
| 162 | + :step="0.5" | ||
| 163 | + v-model="subQuestions.partScore" | ||
| 164 | + label="漏选得分" | ||
| 165 | + ></el-input-number> | ||
| 146 | </div> | 166 | </div> |
| 147 | <div class="qs-options qs-options2"> | 167 | <div class="qs-options qs-options2"> |
| 148 | <p v-if="subQuestions.questionType == 5">--</p> | 168 | <p v-if="subQuestions.questionType == 5">--</p> |
| @@ -200,9 +220,7 @@ | @@ -200,9 +220,7 @@ | ||
| 200 | </ul> | 220 | </ul> |
| 201 | </div> | 221 | </div> |
| 202 | <div class="btn-box"> | 222 | <div class="btn-box"> |
| 203 | - <el-button type="danger" plain round @click="cancel" | ||
| 204 | - >取消</el-button | ||
| 205 | - > | 223 | + <el-button type="danger" plain round @click="cancel">取消</el-button> |
| 206 | <el-button type="primary" round @click="saveAnswer">保存</el-button> | 224 | <el-button type="primary" round @click="saveAnswer">保存</el-button> |
| 207 | </div> | 225 | </div> |
| 208 | </div> | 226 | </div> |
| @@ -220,6 +238,7 @@ | @@ -220,6 +238,7 @@ | ||
| 220 | <p>{{ setSubPro(formAns.qusType) }}:</p> | 238 | <p>{{ setSubPro(formAns.qusType) }}:</p> |
| 221 | <p class="ipt"> | 239 | <p class="ipt"> |
| 222 | <el-input | 240 | <el-input |
| 241 | + ref="formAnsIpt" | ||
| 223 | v-if="formAns.qusType == 2 || formAns.qusType == 3" | 242 | v-if="formAns.qusType == 2 || formAns.qusType == 3" |
| 224 | v-model="formAns.answerList" | 243 | v-model="formAns.answerList" |
| 225 | @keydown.native="keydownAnswer($event, formAns.qusType)" | 244 | @keydown.native="keydownAnswer($event, formAns.qusType)" |
| @@ -288,11 +307,7 @@ | @@ -288,11 +307,7 @@ | ||
| 288 | @click="formAns.answerList = formAns.answerList.slice(0, -1)" | 307 | @click="formAns.answerList = formAns.answerList.slice(0, -1)" |
| 289 | >x</span | 308 | >x</span |
| 290 | > | 309 | > |
| 291 | - <span | ||
| 292 | - class="answer-s ac" | ||
| 293 | - @click="formAns.answerList = ''" | ||
| 294 | - >ac</span | ||
| 295 | - > | 310 | + <span class="answer-s ac" @click="formAns.answerList = ''">ac</span> |
| 296 | </p> | 311 | </p> |
| 297 | </div> | 312 | </div> |
| 298 | <div class="dialog-footer" slot="footer"> | 313 | <div class="dialog-footer" slot="footer"> |
| @@ -322,7 +337,7 @@ export default { | @@ -322,7 +337,7 @@ export default { | ||
| 322 | }, | 337 | }, |
| 323 | data() { | 338 | data() { |
| 324 | return { | 339 | return { |
| 325 | - id:"", | 340 | + id: "", |
| 326 | diaSetAns: false, | 341 | diaSetAns: false, |
| 327 | form: {}, | 342 | form: {}, |
| 328 | questionList: [], | 343 | questionList: [], |
| @@ -438,12 +453,12 @@ export default { | @@ -438,12 +453,12 @@ export default { | ||
| 438 | event.returnValue = ""; | 453 | event.returnValue = ""; |
| 439 | } | 454 | } |
| 440 | }, | 455 | }, |
| 441 | - setAllAnswer(event, type){ | 456 | + setAllAnswer(event, type) { |
| 442 | let str = this.formAns.answerList; | 457 | let str = this.formAns.answerList; |
| 443 | let str2 = checkAnswer( | 458 | let str2 = checkAnswer( |
| 444 | str, | 459 | str, |
| 445 | type, | 460 | type, |
| 446 | - this.formAns.answerOptions.split(',').length, | 461 | + this.formAns.answerOptions.split(",").length, |
| 447 | this.formAns.subNum | 462 | this.formAns.subNum |
| 448 | ); | 463 | ); |
| 449 | this.formAns.answerList = str2; | 464 | this.formAns.answerList = str2; |
| @@ -459,9 +474,26 @@ export default { | @@ -459,9 +474,26 @@ export default { | ||
| 459 | } | 474 | } |
| 460 | return txt; | 475 | return txt; |
| 461 | }, | 476 | }, |
| 477 | + insertTxtAndSetcursor(answerList, str) { | ||
| 478 | + let element = this.$refs.formAnsIpt.$el.children[0]; // 获取到指定标签 | ||
| 479 | + let startPos = element.selectionStart; // 获取光标开始的位置 | ||
| 480 | + if (startPos === undefined) { | ||
| 481 | + // 如果没有光标位置 不操作 | ||
| 482 | + return answerList; | ||
| 483 | + } else { | ||
| 484 | + return { | ||
| 485 | + text: | ||
| 486 | + answerList.substring(0, startPos) + | ||
| 487 | + str + | ||
| 488 | + answerList.substring(startPos), // 将文本插入 | ||
| 489 | + startPos: startPos + str.length, | ||
| 490 | + }; | ||
| 491 | + } | ||
| 492 | + }, | ||
| 462 | setMultiple(obj, answer) { | 493 | setMultiple(obj, answer) { |
| 463 | //多选答案设置 | 494 | //多选答案设置 |
| 464 | - obj.answerList += answer; | 495 | + let resault = this.insertTxtAndSetcursor(obj.answerList || "", answer); |
| 496 | + obj.answerList = resault.text; | ||
| 465 | let str = obj.answerList; | 497 | let str = obj.answerList; |
| 466 | let str2 = checkAnswer( | 498 | let str2 = checkAnswer( |
| 467 | str, | 499 | str, |
| @@ -470,6 +502,8 @@ export default { | @@ -470,6 +502,8 @@ export default { | ||
| 470 | obj.answerList.length | 502 | obj.answerList.length |
| 471 | ); | 503 | ); |
| 472 | obj.answerList = str2; | 504 | obj.answerList = str2; |
| 505 | + this.$refs.formAnsIpt.$el.children[0].focus(); | ||
| 506 | + this.$refs.formAnsIpt.$el.children[0].selectionStart = resault.startPos; | ||
| 473 | }, | 507 | }, |
| 474 | changAnswer(sub, option) { | 508 | changAnswer(sub, option) { |
| 475 | //设置多选答案 | 509 | //设置多选答案 |
| @@ -482,40 +516,46 @@ export default { | @@ -482,40 +516,46 @@ export default { | ||
| 482 | sub.correctAnswer = arrs.sort().join(""); | 516 | sub.correctAnswer = arrs.sort().join(""); |
| 483 | } | 517 | } |
| 484 | }, | 518 | }, |
| 485 | - setFormAns(indexs, index) { | 519 | + setFormAns(indexs, index) { |
| 486 | //初始化要修改的答案 | 520 | //初始化要修改的答案 |
| 487 | if (this.questionList[0].subQuestions) { | 521 | if (this.questionList[0].subQuestions) { |
| 488 | this.formAns = { ...this.questionList[index].subQuestions[indexs] }; | 522 | this.formAns = { ...this.questionList[index].subQuestions[indexs] }; |
| 489 | this.formAns.listIndex = index; | 523 | this.formAns.listIndex = index; |
| 524 | + let startIndex = this.formAns.endIndex - this.formAns.subNum; | ||
| 490 | let answerList = ""; | 525 | let answerList = ""; |
| 491 | this.questionList[index].subQuestions.map((item, subIdx) => { | 526 | this.questionList[index].subQuestions.map((item, subIdx) => { |
| 492 | - answerList += this.setAnswer(item.questionType, item.correctAnswer); | ||
| 493 | - if (subIdx != indexs) { | ||
| 494 | - if (!!item.qusType) { | ||
| 495 | - answerList = ""; | ||
| 496 | - } | ||
| 497 | - } else { | ||
| 498 | - if (item.qusType == 3) { | ||
| 499 | - answerList = answerList.slice(0, -1); | 527 | + if (subIdx >= startIndex) { |
| 528 | + answerList += this.setAnswer(item.questionType, item.correctAnswer); | ||
| 529 | + if (subIdx != indexs) { | ||
| 530 | + if (!!item.qusType) { | ||
| 531 | + answerList = ""; | ||
| 532 | + } | ||
| 533 | + } else { | ||
| 534 | + if (item.qusType == 3) { | ||
| 535 | + answerList = answerList.slice(0, -1); | ||
| 536 | + } | ||
| 537 | + this.formAns.answerList = answerList; | ||
| 500 | } | 538 | } |
| 501 | - this.formAns.answerList = answerList; | ||
| 502 | } | 539 | } |
| 503 | }); | 540 | }); |
| 504 | } else { | 541 | } else { |
| 505 | this.formAns = { ...this.questionList[indexs] }; | 542 | this.formAns = { ...this.questionList[indexs] }; |
| 506 | this.formAns.listIndex = indexs; | 543 | this.formAns.listIndex = indexs; |
| 544 | + let startIndex = this.formAns.endIndex - this.formAns.subNum; | ||
| 507 | let answerList = ""; | 545 | let answerList = ""; |
| 508 | this.questionList[index].map((item, subIdx) => { | 546 | this.questionList[index].map((item, subIdx) => { |
| 509 | - answerList += this.setAnswer(item.questionType, item.correctAnswer); | ||
| 510 | - if (subIdx != indexs) { | ||
| 511 | - if (!!item.qusType) { | ||
| 512 | - answerList = ""; | ||
| 513 | - } | ||
| 514 | - } else { | ||
| 515 | - if (item.qusType == 3) { | ||
| 516 | - answerList = answerList.slice(0, -1); | 547 | + if (subIdx >= startIndex) { |
| 548 | + answerList += this.setAnswer(item.questionType, item.correctAnswer); | ||
| 549 | + if (subIdx != indexs) { | ||
| 550 | + if (!!item.qusType) { | ||
| 551 | + answerList = ""; | ||
| 552 | + } | ||
| 553 | + } else { | ||
| 554 | + if (item.qusType == 3) { | ||
| 555 | + answerList = answerList.slice(0, -1); | ||
| 556 | + } | ||
| 557 | + this.formAns.answerList = answerList; | ||
| 517 | } | 558 | } |
| 518 | - this.formAns.answerList = answerList; | ||
| 519 | } | 559 | } |
| 520 | }); | 560 | }); |
| 521 | } | 561 | } |
| @@ -546,13 +586,16 @@ export default { | @@ -546,13 +586,16 @@ export default { | ||
| 546 | for (let i = 0; i <= subNum; i++) { | 586 | for (let i = 0; i <= subNum; i++) { |
| 547 | let correctAnswer = ""; | 587 | let correctAnswer = ""; |
| 548 | if (this.formAns.qusType == 2) { | 588 | if (this.formAns.qusType == 2) { |
| 549 | - correctAnswer = this.formAns.answerList[subNum - i]; | 589 | + correctAnswer = this.formAns.answerList[subNum - i] || ""; |
| 550 | } else if (this.formAns.qusType == 3) { | 590 | } else if (this.formAns.qusType == 3) { |
| 551 | - correctAnswer = this.formAns.answerList.split(",")[subNum - i]; | ||
| 552 | - | ||
| 553 | - console.log(this.formAns.answerList.split(",")[subNum - i]); | 591 | + correctAnswer = this.formAns.answerList.split(",")[subNum - i] || ""; |
| 554 | } else if (this.formAns.qusType == 4) { | 592 | } else if (this.formAns.qusType == 4) { |
| 555 | - correctAnswer = this.formAns.answerList[subNum - i] == "✓" ? 1 : 2; | 593 | + correctAnswer = |
| 594 | + this.formAns.answerList[subNum - i] == "✓" | ||
| 595 | + ? 1 | ||
| 596 | + : this.formAns.answerList[subNum - i] == "✗" | ||
| 597 | + ? 2 | ||
| 598 | + : ""; | ||
| 556 | } | 599 | } |
| 557 | if (this.questionList[0].subQuestions) { | 600 | if (this.questionList[0].subQuestions) { |
| 558 | this.questionList[this.formAns.listIndex].subQuestions[ | 601 | this.questionList[this.formAns.listIndex].subQuestions[ |
| @@ -566,7 +609,7 @@ export default { | @@ -566,7 +609,7 @@ export default { | ||
| 566 | }, | 609 | }, |
| 567 | async edit(id) { | 610 | async edit(id) { |
| 568 | //修改答案 | 611 | //修改答案 |
| 569 | - this.id = id | 612 | + this.id = id; |
| 570 | const { data, status, info } = await this.$request.examQuestionList({ | 613 | const { data, status, info } = await this.$request.examQuestionList({ |
| 571 | examId: id, | 614 | examId: id, |
| 572 | }); | 615 | }); |
| @@ -580,7 +623,7 @@ export default { | @@ -580,7 +623,7 @@ export default { | ||
| 580 | let types = [{}]; | 623 | let types = [{}]; |
| 581 | let addndex = 0; | 624 | let addndex = 0; |
| 582 | item.subQuestions.map((sub, index) => { | 625 | item.subQuestions.map((sub, index) => { |
| 583 | - if (!!sub.questionType && sub.questionType!=5) { | 626 | + if (!!sub.questionType && sub.questionType != 5) { |
| 584 | if (sub.questionType == types[addndex].qusType) { | 627 | if (sub.questionType == types[addndex].qusType) { |
| 585 | //同类型批量答案+1 | 628 | //同类型批量答案+1 |
| 586 | types[addndex].subNum += 1; | 629 | types[addndex].subNum += 1; |
| @@ -605,7 +648,7 @@ export default { | @@ -605,7 +648,7 @@ export default { | ||
| 605 | //不同类型时如果原有类型数量大于等于5,保存批量答案 | 648 | //不同类型时如果原有类型数量大于等于5,保存批量答案 |
| 606 | types[addndex].endIndex = | 649 | types[addndex].endIndex = |
| 607 | item.subQuestions[index - 1].questionIndex; | 650 | item.subQuestions[index - 1].questionIndex; |
| 608 | - types[addndex].index = index-1; | 651 | + types[addndex].index = index - 1; |
| 609 | addndex += 1; | 652 | addndex += 1; |
| 610 | types[addndex] = {}; | 653 | types[addndex] = {}; |
| 611 | } | 654 | } |
| @@ -637,7 +680,7 @@ export default { | @@ -637,7 +680,7 @@ export default { | ||
| 637 | let types = [{}]; | 680 | let types = [{}]; |
| 638 | let addndex = 0; | 681 | let addndex = 0; |
| 639 | this.questionList?.map((sub, index) => { | 682 | this.questionList?.map((sub, index) => { |
| 640 | - if (!!sub.questionType && sub.questionType!=5) { | 683 | + if (!!sub.questionType && sub.questionType != 5) { |
| 641 | if (sub.questionType == types[addndex].qusType) { | 684 | if (sub.questionType == types[addndex].qusType) { |
| 642 | //同类型批量答案+1 | 685 | //同类型批量答案+1 |
| 643 | types[addndex].subNum += 1; | 686 | types[addndex].subNum += 1; |
| @@ -662,7 +705,7 @@ export default { | @@ -662,7 +705,7 @@ export default { | ||
| 662 | //不同类型时如果原有类型数量大于等于5,保存批量答案 | 705 | //不同类型时如果原有类型数量大于等于5,保存批量答案 |
| 663 | types[addndex].endIndex = | 706 | types[addndex].endIndex = |
| 664 | this.questionList[index - 1].questionIndex; | 707 | this.questionList[index - 1].questionIndex; |
| 665 | - types[addndex].index = index-1; | 708 | + types[addndex].index = index - 1; |
| 666 | addndex += 1; | 709 | addndex += 1; |
| 667 | types[addndex] = {}; | 710 | types[addndex] = {}; |
| 668 | } | 711 | } |
| @@ -705,7 +748,7 @@ export default { | @@ -705,7 +748,7 @@ export default { | ||
| 705 | } else { | 748 | } else { |
| 706 | if (this.questionList[i].qusType) { | 749 | if (this.questionList[i].qusType) { |
| 707 | this.questionList.splice(i, 1); | 750 | this.questionList.splice(i, 1); |
| 708 | - i-- | 751 | + i--; |
| 709 | } | 752 | } |
| 710 | } | 753 | } |
| 711 | } | 754 | } |