diff --git a/src/api/apis/apis.js b/src/api/apis/apis.js index fa38c2d..eb7b52a 100644 --- a/src/api/apis/apis.js +++ b/src/api/apis/apis.js @@ -767,4 +767,11 @@ export default { responseType: 'arraybuffer', }); }, + // 同步教师账号 + syncUser() { + return service({ + url: setUpUrls.syncUser, + method: "POST", + }); + }, }; diff --git a/src/api/urls/apis.js b/src/api/urls/apis.js index 86ff435..0834006 100644 --- a/src/api/urls/apis.js +++ b/src/api/urls/apis.js @@ -195,4 +195,6 @@ export default { exportSchoolContrast: "/api_html/tenant/exportSchoolContrast", // 导出年级使用对比 exportGradeContrast: "/api_html/tenant/exportGradeContrast", + // 同步教师账号 + syncUser: "/api_html/tenant/syncUser", } diff --git a/src/components/setAnswer.vue b/src/components/setAnswer.vue index a406423..c280672 100644 --- a/src/components/setAnswer.vue +++ b/src/components/setAnswer.vue @@ -90,6 +90,7 @@

{{ setSubPro(formAns.qusType) }}:

{ - answerList += this.setAnswer(item.questionType, item.correctAnswer); - if (subIdx != indexs) { - if (!!item.qusType) { - answerList = ""; - } - } else { - if (item.qusType == 3) { - answerList = answerList.slice(0, -1); + if (subIdx >= startIndex) { + answerList += this.setAnswer(item.questionType, item.correctAnswer); + if (subIdx != indexs) { + if (!!item.qusType) { + answerList = ""; + } + } else { + if (item.qusType == 3) { + answerList = answerList.slice(0, -1); + } + this.formAns.answerList = answerList; } - this.formAns.answerList = answerList; } }); this.diaSetAns = true; @@ -292,13 +296,16 @@ export default { for (let i = 0; i <= subNum; i++) { let correctAnswer = ""; if (this.formAns.qusType == 2) { - correctAnswer = this.formAns.answerList[subNum - i]; + correctAnswer = this.formAns.answerList[subNum - i] || ""; } else if (this.formAns.qusType == 3) { - correctAnswer = this.formAns.answerList.split(",")[subNum - i]; - - console.log(this.formAns.answerList.split(",")[subNum - i]); + correctAnswer = this.formAns.answerList.split(",")[subNum - i] || ""; } else if (this.formAns.qusType == 4) { - correctAnswer = this.formAns.answerList[subNum - i] == "✓" ? 1 : 2; + correctAnswer = + this.formAns.answerList[subNum - i] == "✓" + ? 1 + : this.formAns.answerList[subNum - i] == "✗" + ? 2 + : ""; } this.questionList[EndIndex - i].correctAnswer = correctAnswer; } @@ -392,9 +399,26 @@ export default { } return txt; }, + insertTxtAndSetcursor(answerList, str) { + let element = this.$refs.formAnsIpt.$el.children[0]; // 获取到指定标签 + let startPos = element.selectionStart; // 获取光标开始的位置 + if (startPos === undefined) { + // 如果没有光标位置 不操作 + return answerList; + } else { + return { + text: + answerList.substring(0, startPos) + + str + + answerList.substring(startPos), // 将文本插入 + startPos: startPos + str.length, + }; + } + }, setMultiple(obj, answer) { //多选答案设置 - obj.answerList += answer; + let resault = this.insertTxtAndSetcursor(obj.answerList || "", answer); + obj.answerList = resault.text; let str = obj.answerList; let str2 = checkAnswer( str, @@ -403,6 +427,8 @@ export default { obj.answerList.length ); obj.answerList = str2; + this.$refs.formAnsIpt.$el.children[0].focus(); + this.$refs.formAnsIpt.$el.children[0].selectionStart = resault.startPos; }, changAnswer(sub, option) { //设置多选答案 diff --git a/src/views/examinationPaper/add.vue b/src/views/examinationPaper/add.vue index a1f6a5f..cfdbc0c 100644 --- a/src/views/examinationPaper/add.vue +++ b/src/views/examinationPaper/add.vue @@ -191,7 +191,11 @@ :key="index" >

- +

--

-

+

-

+

{{ option }} +

+

+ {{ option }} +

+

共:{{ setNums(question.subQuestions) }}题 共:{{ setScore(question) }} 分

- +
+ {{ setSubPro(subQuestions.questionType) }} +
+
+ +
+
+

--

+ +
+
+

--

+

+ + +

+

+ {{ option }} +

+

+ {{ option }} +

+
+
+ + { - answerList += this.setAnswer(item.questionType, item.correctAnswer); - if (subIdx != indexs) { - if (!!item.qusType) { - answerList = ""; - } - } else { - if (item.qusType == 3) { - answerList = answerList.slice(0, -1); + if (subIdx >= startIndex) { + answerList += this.setAnswer(item.questionType, item.correctAnswer); + if (subIdx != indexs) { + if (!!item.qusType) { + answerList = ""; + } + } else { + if (item.qusType == 3) { + answerList = answerList.slice(0, -1); + } + this.formAns.answerList = answerList; } - this.formAns.answerList = answerList; } }); this.diaSetAns = true; }, + insertTxtAndSetcursor(answerList, str) { + let element = this.$refs.formAnsIpt.$el.children[0]; // 获取到指定标签 + let startPos = element.selectionStart; // 获取光标开始的位置 + if (startPos === undefined) { + // 如果没有光标位置 不操作 + return answerList; + } else { + return { + text: + answerList.substring(0, startPos) + + str + + answerList.substring(startPos), // 将文本插入 + startPos: startPos + str.length, + }; + } + }, setMultiple(obj, answer) { //多选答案设置 - obj.answerList += answer; + let resault = this.insertTxtAndSetcursor(obj.answerList || "", answer); + obj.answerList = resault.text; let str = obj.answerList; let str2; if (!!obj.answerOptions) { @@ -1081,6 +1120,8 @@ export default { str2 = checkAnswer(str, 3, obj.selectNum, obj.answerList.length); } obj.answerList = str2; + this.$refs.formAnsIpt.$el.children[0].focus(); + this.$refs.formAnsIpt.$el.children[0].selectionStart = resault.startPos; }, saveFormAns() { //批量修改答案 @@ -1098,10 +1139,9 @@ export default { for (let i = 0; i <= subNum; i++) { let correctAnswer = ""; if (this.formAns.qusType == 2) { - correctAnswer = this.formAns.answerList[subNum - i]; + correctAnswer = this.formAns.answerList[subNum - i] || ""; } else if (this.formAns.qusType == 3) { - correctAnswer = this.formAns.answerList.split(",")[subNum - i]; - console.log(this.formAns.answerList.split(",")[subNum - i]); + correctAnswer = this.formAns.answerList.split(",")[subNum - i] || ""; } else if (this.formAns.qusType == 4) { correctAnswer = this.formAns.answerList[subNum - i] == "✓" @@ -1548,9 +1588,9 @@ export default { if (this.saveLoading) return; this.saveLoading = true; this.formatQuestionList(); - let formDatas = deepClone(this.form) + let formDatas = deepClone(this.form); for (let i = 0; i < formDatas.questionList.length; i++) { - delete formDatas.questionList[i].show + delete formDatas.questionList[i].show; } const { data, status, info } = await this.$request.addPaper({ ...formDatas, diff --git a/src/views/examinationPaper/edit.vue b/src/views/examinationPaper/edit.vue index 369710a..bb0e88b 100644 --- a/src/views/examinationPaper/edit.vue +++ b/src/views/examinationPaper/edit.vue @@ -71,7 +71,17 @@

--

-

{{ subQuestions.partScore }}

+

--

@@ -160,7 +170,17 @@

--

-

{{ subQuestions.partScore }}

+

--

@@ -234,6 +254,7 @@

{{ setSubPro(formAns.qusType) }}:

{ - answerList += this.setAnswer(item.questionType, item.correctAnswer); - if (subIdx != indexs) { - if (!!item.qusType) { - answerList = ""; - } - } else { - if (item.qusType == 3) { - answerList = answerList.slice(0, -1); + if (subIdx >= startIndex) { + answerList += this.setAnswer(item.questionType, item.correctAnswer); + if (subIdx != indexs) { + if (!!item.qusType) { + answerList = ""; + } + } else { + if (item.qusType == 3) { + answerList = answerList.slice(0, -1); + } + this.formAns.answerList = answerList; } - this.formAns.answerList = answerList; } }); } else { this.formAns = { ...this.questionList[indexs] }; + let startIndex = this.formAns.endIndex - this.formAns.subNum; this.formAns.listIndex = indexs; let answerList = ""; this.questionList[index].map((item, subIdx) => { - answerList += this.setAnswer(item.questionType, item.correctAnswer); - if (subIdx != indexs) { - if (!!item.qusType) { - answerList = ""; - } - } else { - if (item.qusType == 3) { - answerList = answerList.slice(0, -1); + if (subIdx >= startIndex) { + answerList += this.setAnswer(item.questionType, item.correctAnswer); + if (subIdx != indexs) { + if (!!item.qusType) { + answerList = ""; + } + } else { + if (item.qusType == 3) { + answerList = answerList.slice(0, -1); + } + this.formAns.answerList = answerList; } - this.formAns.answerList = answerList; } }); } @@ -552,13 +598,16 @@ export default { for (let i = 0; i <= subNum; i++) { let correctAnswer = ""; if (this.formAns.qusType == 2) { - correctAnswer = this.formAns.answerList[subNum - i]; + correctAnswer = this.formAns.answerList[subNum - i] || ""; } else if (this.formAns.qusType == 3) { - correctAnswer = this.formAns.answerList.split(",")[subNum - i]; - - console.log(this.formAns.answerList.split(",")[subNum - i]); + correctAnswer = this.formAns.answerList.split(",")[subNum - i] || ""; } else if (this.formAns.qusType == 4) { - correctAnswer = this.formAns.answerList[subNum - i] == "✓" ? 1 : 2; + correctAnswer = + this.formAns.answerList[subNum - i] == "✓" + ? 1 + : this.formAns.answerList[subNum - i] == "✗" + ? 2 + : ""; } if (this.questionList[0].subQuestions) { this.questionList[this.formAns.listIndex].subQuestions[ @@ -732,6 +781,7 @@ export default { } } } + console.log(this.questionList); } else { this.$message.error(info); } diff --git a/src/views/setUp/account.vue b/src/views/setUp/account.vue index 1d5466a..1a9b848 100644 --- a/src/views/setUp/account.vue +++ b/src/views/setUp/account.vue @@ -16,7 +16,12 @@ @click="diaUp = true" > --> - + 学生管理 - @@ -202,6 +234,8 @@ export default { data() { return { code: "", + role: "", + diaUp: false, url: "", diaStu: false, diaClass: false, @@ -254,6 +288,13 @@ export default { }, async created() { this.code = localStorage.getItem("csCode") || ""; + let role = ""; + this.$store.getters.info.permissions.map((item) => { + if (item.roleName == this.$store.getters.info.showRoleName) { + role = item.role; + } + }); + this.role = role ? role : this.$store.getters.info.permissions[0].role; await this._QueryDataGrade(); await this._QueryClass(); this._QueryData(3); @@ -300,6 +341,26 @@ export default { } }); }, + upSuccess() { + //导入成功 + this.diaUp = false; + this._QueryData(3); + }, + async downExcel() { + this.loadingDown = true; + let data = await this.$request.subjectiveScoreTemplate({ + classId: this.query.classId, + }); + this.loadingDown = false; + if (data && !data.code) { + let blob = new Blob([data], { + type: "application/vnd.ms-excel;charset=utf-8", + }); + downloadFile(`主观题模版.xlsx`, blob); + } else { + this.$message.error(data.info); + } + }, async removeStu(obj, index) { const { data, status, info } = await this.$request.delStudent({ studentId: obj.id, @@ -410,19 +471,6 @@ export default { this.$message.error(info); } }, - async downExcel() { - let data = await this.$request.downDevice({ - id: this.id, - }); - if (data && !data.code) { - let blob = new Blob([data], { - type: "application/vnd.ms-excel;charset=utf-8", - }); - downloadFile(`设备信息.xlsx`, blob); - } else { - this.$message.error(data.info); - } - }, }, }; diff --git a/src/views/test/editAnswer.vue b/src/views/test/editAnswer.vue index 460892a..a3295fd 100644 --- a/src/views/test/editAnswer.vue +++ b/src/views/test/editAnswer.vue @@ -53,7 +53,17 @@

--

-

{{ subQuestions.partScore }}

+

--

@@ -142,7 +152,17 @@

--

-

{{ subQuestions.partScore }}

+

--

@@ -200,9 +220,7 @@
- 取消 + 取消 保存
@@ -220,6 +238,7 @@

{{ setSubPro(formAns.qusType) }}:

x - ac + ac