diff --git a/package-lock.json b/package-lock.json
index e8056be..575dea3 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -3885,6 +3885,11 @@
"randomfill": "^1.0.3"
}
},
+ "crypto-js": {
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz",
+ "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q=="
+ },
"css": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/css/-/css-2.2.4.tgz",
@@ -9561,6 +9566,11 @@
"resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
"integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM="
},
+ "jsencrypt": {
+ "version": "3.3.2",
+ "resolved": "https://registry.npmjs.org/jsencrypt/-/jsencrypt-3.3.2.tgz",
+ "integrity": "sha512-arQR1R1ESGdAxY7ZheWr12wCaF2yF47v5qpB76TtV64H1pyGudk9Hvw8Y9tb/FiTIaaTRUyaSnm5T/Y53Ghm/A=="
+ },
"jsesc": {
"version": "2.5.2",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz",
diff --git a/package.json b/package.json
index 7ba9c5b..9c38cce 100644
--- a/package.json
+++ b/package.json
@@ -12,6 +12,7 @@
"ali-oss": "^6.20.0",
"axios": "^0.18.0",
"babel-polyfill": "^6.26.0",
+ "crypto-js": "^4.2.0",
"dayjs": "^1.11.12",
"decimal.js": "^10.4.3",
"echarts": "^4.8.0",
@@ -19,6 +20,7 @@
"element-ui": "^2.13.0",
"image-conversion": "^2.1.1",
"js-cookie": "^2.2.1",
+ "jsencrypt": "^3.3.2",
"lodash": "^4.17.21",
"mavon-editor": "^2.6.17",
"postcss-px2rem": "^0.3.0",
diff --git a/public/index.html b/public/index.html
index 33f4e2a..3b643d2 100644
--- a/public/index.html
+++ b/public/index.html
@@ -13,9 +13,13 @@
-
+
+
+
+
+
diff --git a/src/api/index.js b/src/api/index.js
index 419284d..27aff70 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -2,6 +2,7 @@ import Setting from '@/setting'
const { apiBaseURL: host } = Setting
export default {
+ encrypt: `/nakadai/data/encrypt`,
queryProfessional: `/exam/exam/professional/queryProfessional`,
categoriesDel: `/exam/question/bank/categories/batchDeletion`,
diff --git a/src/components/upload/config.js b/src/components/upload/config.js
index 503fd7c..04818ef 100644
--- a/src/components/upload/config.js
+++ b/src/components/upload/config.js
@@ -1,15 +1,41 @@
/**
* 阿里云oss配置
* */
+import { get } from '@/plugins/requests/index.js'
+import api from '@/api'
+import CryptoJS from 'crypto-js'
+import JSEncrypt from 'jsencrypt'
-export default {
- // oss账号信息
- config: {
- region: 'oss-cn-shenzhen',
- accessKeyId: 'LTAI4FzqQHnk4rozqLZ8jCNj',
- accessKeySecret: 'mveW7B1OyFoKUkHm8WsxmrjHmkJWHq',
- bucket: 'huoran'
- },
- // 上传成功url前置部分(成功回调没有返回url)
- preUrl: 'https://huoran.oss-cn-shenzhen.aliyuncs.com/'
+const A = (key, encryptedData) => {
+ const keyHex = CryptoJS.enc.Base64.parse(key)
+ const decrypted = CryptoJS.AES.decrypt(encryptedData, keyHex, {
+ mode: CryptoJS.mode.ECB,
+ padding: CryptoJS.pad.Pkcs7
+ })
+ return decrypted.toString(CryptoJS.enc.Utf8)
+}
+
+const R = (encryptedKey, privateKey) => {
+ const decrypt = new JSEncrypt()
+ decrypt.setPrivateKey(privateKey)
+ const decryptedKey = decrypt.decrypt(encryptedKey)
+ return decryptedKey
+}
+
+export default async function () {
+ try {
+ const res = await get(api.encrypt)
+ const RE = A(R(res.encryptedKey, res.privateKey), res.encryptedData).split('/')
+ return {
+ // oss账号信息
+ config: {
+ region: 'oss-cn-shenzhen',
+ accessKeyId: RE[0],
+ accessKeySecret: RE[1],
+ bucket: 'huoran'
+ },
+ // 上传成功url前置部分(成功回调没有返回url)
+ preUrl: 'https://huoran.oss-cn-shenzhen.aliyuncs.com/'
+ }
+ } catch (e) { }
}
\ No newline at end of file
diff --git a/src/components/upload/index.vue b/src/components/upload/index.vue
index 6308e1f..dd7087d 100644
--- a/src/components/upload/index.vue
+++ b/src/components/upload/index.vue
@@ -1,5 +1,5 @@
-
@@ -62,7 +62,8 @@ export default {
client: null,
uploading: false,
uploadProgress: 0,
- showFiles: this.showFileList
+ showFiles: this.showFileList,
+ Oss: {},
};
},
mounted () {
@@ -70,8 +71,9 @@ export default {
},
methods: {
// 初始化oss
- initOss () {
- this.client = new OSS(OssConfig.config)
+ async initOss () {
+ this.Oss = await OssConfig()
+ this.client = new OSS(this.Oss.config)
},
// 附件上传前
beforeUpload (file) {
@@ -94,14 +96,13 @@ export default {
this.uploadProgress = 0
this.uploading = true
this.showFiles = false
-
// 上传到阿里云oss
const { name } = await this.client.multipartUpload(Date.now() + '.' + Util.getFileExt(file.name), file, {
progress: this.handleProgress
});
this.uploading = false
- const url = OssConfig.preUrl + name
+ const url = this.Oss.preUrl + name
this.changeFileList && this.$emit('update:fileList', [
...this.fileList,
{
@@ -109,6 +110,7 @@ export default {
url
}
])
+
this.showFiles = true
this.$emit('onSuccess', {
format: Util.getFileExt(file.name),
diff --git a/src/components/upload/upload.js b/src/components/upload/upload.js
index 47f5916..59368bd 100644
--- a/src/components/upload/upload.js
+++ b/src/components/upload/upload.js
@@ -5,10 +5,13 @@ import OssConfig from './config'
import Util from '@/libs/util'
let client = null
+let Oss
// 初始化oss
-const initOss = () => {
- if (!client) client = new OSS(OssConfig.config)
+const initOss = async () => {
+ Oss = await OssConfig()
+ if (!client) client = new OSS(Oss.config)
}
+initOss()
export default {
// 上传文件
@@ -21,7 +24,7 @@ export default {
resolve({
format: Util.getFileExt(file.name),
name: file.name,
- url: OssConfig.preUrl + res.name,
+ url: Oss.preUrl + res.name,
size: file.size,
})
} catch (error) {
@@ -32,6 +35,6 @@ export default {
// 删除文件(传完整url,不是没有https的name,因为很多接口没有存name,只存url,所以统一使用url)
async del (url) {
initOss()
- await client.delete(url.replace(OssConfig.preUrl, ''));
+ await client.delete(url.replace(Oss.preUrl, ''));
}
}
diff --git a/src/pages/testPaper/detail/auto.vue b/src/pages/testPaper/detail/auto.vue
index a42d8de..6d8ff78 100644
--- a/src/pages/testPaper/detail/auto.vue
+++ b/src/pages/testPaper/detail/auto.vue
@@ -186,6 +186,7 @@ export default {
const { list } = await this.$post(this.api.questionBankStructureLevel, {
keyword: this.quesBankKeyword,
createSource: 1,
+ status: 1,
})
this.quesBanks = list
} catch (e) { }
@@ -291,20 +292,33 @@ export default {
list.forEach(e => {
const total = e.questionNum
- // 初始分配题目数量
- let totalWeight = Decimal(total).mul(Decimal(target)).toNumber()
- const maxCount = Math.ceil(total / 4)
- for (let i = 0; i < 4; i++) {
- if (totalWeight > 0) {
- const random = Math.floor(Math.random() * maxCount) + 1
- const weight = difficultyWeights[i]
- totalWeight = Decimal(totalWeight).sub(Decimal(weight * random)).toNumber()
- this.$set(e, names[i], totalWeight > 0 ? random : 0)
- // e[names[i]] = totalWeight > 0 ? random : 0
+ if (target === 1) {
+ let already = 0
+ this.$set(e, 'basicDifficulty', Math.floor(total * 0.6))
+ this.$set(e, 'normalDifficulty', Math.floor(total * 0.3))
+ this.$set(e, 'hardDifficulty', Math.floor(total * 0.1))
+ this.$set(e, 'veryHardDifficulty', 0)
+ already = Decimal(already).add(e.basicDifficulty).add(e.normalDifficulty).add(e.hardDifficulty).add(e.veryHardDifficulty).toNumber()
+
+ while (total > already) {
+ e.basicDifficulty++
+ already++
}
+ console.log(33, already)
}
- console.log("🚀 ~ calculateQuestionNumbers ~ totalWeight:", totalWeight)
+ // 初始分配题目数量
+ // let totalWeight = Decimal(total).mul(Decimal(target)).toNumber()
+ // const maxCount = Math.ceil(total / 4)
+ // for (let i = 0; i < 4; i++) {
+ // if (totalWeight > 0) {
+ // const random = Math.floor(Math.random() * maxCount) + 1
+ // const weight = difficultyWeights[i]
+ // totalWeight = Decimal(totalWeight).sub(Decimal(weight * random)).toNumber()
+ // this.$set(e, names[i], totalWeight > 0 ? random : 0)
+ // // e[names[i]] = totalWeight > 0 ? random : 0
+ // }
+ // }
})
@@ -313,7 +327,7 @@ export default {
// 试卷难度选择回调
difficultData (val) {
// debugger
- console.log(111, this.calculateQuestionNumbers(this.list, 0.3))
+ console.log(111, this.calculateQuestionNumbers(this.list, val))
},
// 年份全选回调
yearAllChange (val) {
@@ -365,6 +379,7 @@ export default {
list.map((e, i) => {
if (e.questionNum !== res.list[i].questions.length) invalid = 1
if (e.examQuestions.length) hasQues = 1
+ e.score = 0
})
// 3种情况提示不一样
diff --git a/src/pages/testPaper/detail/index.vue b/src/pages/testPaper/detail/index.vue
index 13574e1..12900e1 100644
--- a/src/pages/testPaper/detail/index.vue
+++ b/src/pages/testPaper/detail/index.vue
@@ -131,7 +131,10 @@
-
【正确答案】:A
+
+ 【{{ ques.questionType === 'essay' ? '参考答案' : '正确答案' }}】:
+
+
排序
@@ -312,6 +315,12 @@ export default {
})
const r = res.examPaper
const paper = r.paperOutline
+ paper.map(e => {
+ e.examQuestions.map(n => {
+ Object.assign(n, n.question)
+ })
+
+ })
if (r.particularYear) r.particularYear = r.particularYear + ''
this.form = r
// this.answerAnalysis = opts[0].answerAnalysis
@@ -395,7 +404,7 @@ export default {
data.avgValueList.map((e, i) => {
// scores里有-1则不用循环
e.scores.includes(-1) || e.scores.map((n, j) => {
- paper[i].examQuestions[j].score = n
+ this.$set(paper[i].examQuestions[j], 'score', n)
})
})
@@ -405,6 +414,17 @@ export default {
showAuto () {
this.autoVisible = true
},
+ // 处理正确答案的显示
+ getCorrectAnswer (e) {
+ if (e.questionType === 'fill_blank') { // 填空题
+ // return e.questionAnswerVersionsList.filter(e => e.answerIsCorrect)
+ } else if (e.questionType === 'essay') { // 问答题取参考答案
+ return e.questionAnswerVersionsList[0].referenceAnswer
+ } else {
+ const correct = e.questionAnswerVersionsList.filter(e => e.answerIsCorrect)
+ return correct ? (e.questionType === 'judgement' ? correct[0].optionText : correct.map(e => Util.numToLetter(e.optionNumber - 1)).join('')) : ''
+ }
+ },
// 添加题目
showManualDia (item, i, ques) {
this.curType = item
@@ -497,6 +517,7 @@ export default {
break
}
}
+ debugger
if (invalid) return false
this.submiting = true
@@ -516,7 +537,6 @@ export default {
}
})
})
- debugger
if (typeof form.classificationId === 'object') form.classificationId = form.classificationId[form.classificationId.length - 1]
form.questionType = [...new Set(paper.map(e => e.questionType))].join('、')
form.createSource = 1
@@ -638,6 +658,7 @@ export default {
}
.correct {
+ display: flex;
font-size: 13px;
color: #333;
}
diff --git a/src/pages/testPaper/detail/manual.vue b/src/pages/testPaper/detail/manual.vue
index 83d6963..f3c0f39 100644
--- a/src/pages/testPaper/detail/manual.vue
+++ b/src/pages/testPaper/detail/manual.vue
@@ -159,6 +159,7 @@ export default {
const { list } = await this.$post(this.api.questionBankStructureLevel, {
keyword: this.quesBankKeyword,
createSource: 1,
+ status: 1,
})
this.quesBanks = list
} catch (e) { }
@@ -309,7 +310,6 @@ export default {
this.$set(e, 'score', '')
this.$set(e, 'questionVersionId', e.questionId)
})
- // debugger
if (curQues) {
// curQues即是小题,有则说明是更换试题,需要把该小题去掉,再添加进选中的试题
diff --git a/src/pages/testPaperLibrary/index.vue b/src/pages/testPaperLibrary/index.vue
index bf5e46d..d909efd 100644
--- a/src/pages/testPaperLibrary/index.vue
+++ b/src/pages/testPaperLibrary/index.vue
@@ -26,7 +26,7 @@