|
@@ -1,10 +1,14 @@
|
|
|
<template>
|
|
|
<div class="create-evaluation-container">
|
|
|
<div class="create-header">
|
|
|
- <p class="create-header-title">{{ isEditPaper ? $t('evaluation.paperList.editPaper') : evaluationInfo.createType === 'auto' ? $t('evaluation.index.autoCreate') : evaluationInfo.createType === 'import' ? $t('evaluation.index.importCreate') : $t('evaluation.index.manualCreate') }}</p>
|
|
|
+ <p class="create-header-title">
|
|
|
+ {{ isEditPaper ? $t('evaluation.paperList.editPaper') : evaluationInfo.createType === 'auto' ? $t('evaluation.index.autoCreate') : evaluationInfo.createType === 'import' ? $t('evaluation.index.importCreate') : $t('evaluation.index.manualCreate') }}
|
|
|
+ </p>
|
|
|
<div style="float: right;" class="common-save-btn">
|
|
|
- <Button class="btn-save" type="text" icon="md-arrow-round-back" @click="goBack">{{$t('evaluation.paperList.backToBank')}}</Button>
|
|
|
- <Button class="btn-save" type="text" icon="md-folder" :loading="isLoading" @click="saveTestPaper">{{ isLoading ? $t('evaluation.paperList.isSaving') : $t('evaluation.paperList.savePaper')}}</Button>
|
|
|
+ <Button class="btn-save" type="text" icon="md-arrow-round-back"
|
|
|
+ @click="goBack">{{$t('evaluation.paperList.backToBank')}}</Button>
|
|
|
+ <Button class="btn-save" type="text" icon="md-folder" :loading="isLoading"
|
|
|
+ @click="saveTestPaper">{{ isLoading ? $t('evaluation.paperList.isSaving') : $t('evaluation.paperList.savePaper')}}</Button>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="create-body dark-iview-split">
|
|
@@ -13,7 +17,8 @@
|
|
|
<div class="evaluation-attr-wrap">
|
|
|
<p class="wrap-label">{{$t('evaluation.paperList.baseInfo')}}</p>
|
|
|
<div style="width:100%; height:calc(100% - 45px);padding-top:30px;">
|
|
|
- <Form ref="evaluationInfo" :model="evaluationInfo" label-position="top" class="evaluation-attr-form" label-colon>
|
|
|
+ <Form ref="evaluationInfo" :model="evaluationInfo" label-position="top"
|
|
|
+ class="evaluation-attr-form" label-colon>
|
|
|
<FormItem :label="$t('evaluation.paperList.paperType')" prop="type">
|
|
|
<Select v-model="evaluationInfo.type" disabled>
|
|
|
<Option value="private">{{$t('evaluation.paperList.praviteBank')}}</Option>
|
|
@@ -23,22 +28,30 @@
|
|
|
<FormItem :label="$t('evaluation.paperList.paperName')" prop="name">
|
|
|
<Input v-model="evaluationInfo.name"></Input>
|
|
|
</FormItem>
|
|
|
- <FormItem :label="$t('evaluation.newExercise.choosePeriod')" prop="paperPeriod" v-if="isSchool">
|
|
|
+ <FormItem :label="$t('evaluation.newExercise.choosePeriod')" prop="paperPeriod"
|
|
|
+ v-if="isSchool">
|
|
|
<Select v-model="evaluationInfo.paperPeriod" @on-change="onPeriodChange">
|
|
|
- <Option v-for="(period,index) in schoolInfo.period" :value="index" :key="index">{{ period.name }}</Option>
|
|
|
+ <Option v-for="(period,index) in schoolInfo.period" :value="index" :key="index">
|
|
|
+ {{ period.name }}</Option>
|
|
|
</Select>
|
|
|
</FormItem>
|
|
|
- <FormItem :label="$t('evaluation.newExercise.chooseGrade')" prop="publish" v-if="isSchool">
|
|
|
- <Select v-model="evaluationInfo.paperGrade" multiple :placeholder="$t('evaluation.newExercise.gradePlaceholder')">
|
|
|
- <Option v-for="(grade,index) in gradeList" :value="index" :key="index">{{ grade }}</Option>
|
|
|
+ <FormItem :label="$t('evaluation.newExercise.chooseGrade')" prop="publish"
|
|
|
+ v-if="isSchool">
|
|
|
+ <Select v-model="evaluationInfo.paperGrade" multiple
|
|
|
+ :placeholder="$t('evaluation.newExercise.gradePlaceholder')">
|
|
|
+ <Option v-for="(grade,index) in gradeList" :value="index" :key="index">
|
|
|
+ {{ grade }}</Option>
|
|
|
</Select>
|
|
|
</FormItem>
|
|
|
- <FormItem :label="$t('evaluation.newExercise.chooseSubject')" class="dark-iview-select" v-if="isSchool">
|
|
|
+ <FormItem :label="$t('evaluation.newExercise.chooseSubject')" class="dark-iview-select"
|
|
|
+ v-if="isSchool">
|
|
|
<Select v-model="evaluationInfo.paperSubject">
|
|
|
- <Option v-for="(subject,index) in subjectList" :value="index" :key="index">{{ subject.name }}</Option>
|
|
|
+ <Option v-for="(subject,index) in subjectList" :value="index" :key="index">
|
|
|
+ {{ subject.name }}</Option>
|
|
|
</Select>
|
|
|
</FormItem>
|
|
|
- <FormItem :label="$t('evaluation.paperList.paperScore')" prop="name" class="evaluation-attr-wrap-inputNumber">
|
|
|
+ <FormItem :label="$t('evaluation.paperList.paperScore')" prop="name"
|
|
|
+ class="evaluation-attr-wrap-inputNumber">
|
|
|
<InputNumber :max="200" :min="1" v-model="evaluationInfo.score"></InputNumber>
|
|
|
</FormItem>
|
|
|
</Form>
|
|
@@ -56,30 +69,39 @@
|
|
|
<Radio label="import" v-if="!isEditPaper">试题导入</Radio>
|
|
|
</RadioGroup>
|
|
|
</div> -->
|
|
|
- <p class="save-tips">* {{ viewModel === 'list' ? $t('evaluation.paperList.saveRule2') : $t('evaluation.paperList.saveRule2') }}
|
|
|
+ <p class="save-tips">*
|
|
|
+ {{ viewModel === 'list' ? $t('evaluation.paperList.saveRule2') : $t('evaluation.paperList.saveRule2') }}
|
|
|
</p>
|
|
|
<Tabs v-model="activeTab" type="card" class="question-main-tabs" name="createTest">
|
|
|
- <TabPane :label="$t('evaluation.paperList.tab1')" name="auto" v-if="evaluationInfo.createType == 'auto'" :index="1"
|
|
|
- tab="createTest">
|
|
|
- <AutoCreate :subject="propSubject" :period="propPeriod" @goToPreview="goToPreview" @autoQuestions="getAutoQuestions"></AutoCreate>
|
|
|
+ <TabPane :label="$t('evaluation.paperList.tab1')" name="auto"
|
|
|
+ v-if="evaluationInfo.createType == 'auto'" :index="1" tab="createTest">
|
|
|
+ <AutoCreate :subject="propSubject" :period="propPeriod" @goToPreview="goToPreview"
|
|
|
+ @autoQuestions="getAutoQuestions"></AutoCreate>
|
|
|
</TabPane>
|
|
|
- <TabPane :label="$t('evaluation.paperList.tab2')" name="manual" v-if="evaluationInfo.createType == 'manual'"
|
|
|
- :index="2" tab="createTest">
|
|
|
- <ManualCreate :questionList="questionList" :subjectCode="propSubject" :periodCode="propPeriod" :selQue="evaluationInfo.item"
|
|
|
- @goToPreview="goToPreview" @selectedQuestion="getSelectedQuestion"></ManualCreate>
|
|
|
+ <TabPane :label="$t('evaluation.paperList.tab2')" name="manual"
|
|
|
+ v-if="evaluationInfo.createType == 'manual'" :index="2" tab="createTest">
|
|
|
+ <ManualCreate :questionList="questionList" :subjectCode="propSubject"
|
|
|
+ :periodCode="propPeriod" :selQue="evaluationInfo.item"
|
|
|
+ @goToPreview="goToPreview" @selectedQuestion="getSelectedQuestion">
|
|
|
+ </ManualCreate>
|
|
|
</TabPane>
|
|
|
- <TabPane :label="evaluationInfo.item.length ? $t('evaluation.paperList.tab3') : $t('evaluation.paperList.tab4')"
|
|
|
- name="import" v-if="evaluationInfo.createType == 'import'" :index="3" tab="createTest">
|
|
|
+ <TabPane
|
|
|
+ :label="evaluationInfo.item.length ? $t('evaluation.paperList.tab3') : $t('evaluation.paperList.tab4')"
|
|
|
+ name="import" v-if="evaluationInfo.createType == 'import'" :index="3"
|
|
|
+ tab="createTest">
|
|
|
<BaseImport @importFinish="onImportFinish"></BaseImport>
|
|
|
</TabPane>
|
|
|
- <TabPane :label="$t('evaluation.paperList.tab5')" name="preview" :index="4" tab="createTest">
|
|
|
+ <TabPane :label="$t('evaluation.paperList.tab5')" name="preview" :index="4"
|
|
|
+ tab="createTest">
|
|
|
<!--<TeacherPreview :testPaper="evaluationInfo.testPaper[currentSubjectIndex]" :paperName="evaluationInfo.name"></TeacherPreview>-->
|
|
|
<vuescroll ref="paperRef" @handle-scroll="handleScroll">
|
|
|
- <TestPaper v-if="!examAnalysisStatus" :paper="evaluationInfo" :class="examAnalysisStatus ? '':'animated fadeIn'"
|
|
|
- ref="testPaper" @onViewModelChange="onViewModelChange"></TestPaper>
|
|
|
+ <TestPaper v-if="!examAnalysisStatus" :paper="evaluationInfo"
|
|
|
+ :class="examAnalysisStatus ? '':'animated fadeIn'" ref="testPaper"
|
|
|
+ @onViewModelChange="onViewModelChange"></TestPaper>
|
|
|
</vuescroll>
|
|
|
</TabPane>
|
|
|
- <TabPane :label="$t('evaluation.paperList.tab6')" name="student" :index="5" tab="createTest">
|
|
|
+ <TabPane :label="$t('evaluation.paperList.tab6')" name="student" :index="5"
|
|
|
+ tab="createTest">
|
|
|
<StudentPreview></StudentPreview>
|
|
|
</TabPane>
|
|
|
</Tabs>
|
|
@@ -153,6 +175,7 @@
|
|
|
}
|
|
|
},
|
|
|
async created() {
|
|
|
+ console.log('==========', this.$route)
|
|
|
/* 查询当前是否有保存的组卷方式,如果已经保存则直接读取,优先读取传过来的参数 */
|
|
|
let curCreateType = localStorage.getItem('curCreateType')
|
|
|
this.evaluationInfo.createType = this.$route.params.type || curCreateType || 'auto'
|
|
@@ -223,7 +246,7 @@
|
|
|
this.errorList = []
|
|
|
this.$refs.testPaper.$refs.exList.errorList = []
|
|
|
this.evaluationInfo.item = []
|
|
|
- try{
|
|
|
+ try {
|
|
|
let importList = await this.refreshImportItems(list)
|
|
|
this.evaluationInfo.item = importList
|
|
|
this.activeTab = 'preview'
|
|
@@ -232,21 +255,24 @@
|
|
|
if (this.errorList.length) {
|
|
|
this.$EventBus.$emit('importFinish', this.errorList)
|
|
|
}
|
|
|
- }catch(e){
|
|
|
+ } catch (e) {
|
|
|
this.$Message.error(this.$t('evaluation.importFile.warningTips5'))
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
},
|
|
|
|
|
|
/* 给导入的试题 补充最新的试卷学段年级以及科目信息 */
|
|
|
refreshImportItems(list) {
|
|
|
return new Promise((r, reject) => {
|
|
|
let objectiveTypes = ['single', 'multiple']
|
|
|
- let code = this.isSchool ? this.$store.state.userInfo.schoolCode : this.$store.state.userInfo.TEAMModelId
|
|
|
- let gradeIds = this.isSchool ? this.evaluationInfo.paperGrade.length ? this.evaluationInfo.paperGrade : this.gradeList
|
|
|
+ let code = this.isSchool ? this.$store.state.userInfo.schoolCode : this.$store.state.userInfo
|
|
|
+ .TEAMModelId
|
|
|
+ let gradeIds = this.isSchool ? this.evaluationInfo.paperGrade.length ? this.evaluationInfo
|
|
|
+ .paperGrade : this.gradeList
|
|
|
.map(i => i.id) : null
|
|
|
let subjectId = this.isSchool ? this.subjectList[this.evaluationInfo.paperSubject].id : null
|
|
|
- let periodId = this.isSchool ? this.schoolInfo.period[this.evaluationInfo.paperPeriod].id : null
|
|
|
+ let periodId = this.isSchool ? this.schoolInfo.period[this.evaluationInfo.paperPeriod].id :
|
|
|
+ null
|
|
|
for (let j = 0; j < list.length; j++) {
|
|
|
let i = list[j]
|
|
|
if (i.blob && i.id) {
|
|
@@ -276,7 +302,8 @@
|
|
|
})
|
|
|
}
|
|
|
// 如果导入的是客观题 则需要检测答案与选项是否为空
|
|
|
- if (objectiveTypes.includes(i.type) && (!i.question.replace(/\s*/g, "") || !i.option || !i.answer ||
|
|
|
+ if (objectiveTypes.includes(i.type) && (!i.question.replace(/\s*/g, "") || !i.option || !i
|
|
|
+ .answer ||
|
|
|
!i.option.length || !i.answer.length)) {
|
|
|
this.errorList.push(i)
|
|
|
reject(500)
|
|
@@ -305,6 +332,11 @@
|
|
|
getSelectedQuestion(data) {
|
|
|
console.log(data)
|
|
|
let arr = data.questions
|
|
|
+ let scoreArr = this.averageTotalScore(this.evaluationInfo.score, arr.length)
|
|
|
+ arr.forEach((i, index) => {
|
|
|
+ i.score = scoreArr[index] || 0
|
|
|
+ })
|
|
|
+ console.log()
|
|
|
// 如果是编辑试卷 则往原试卷添加不包含的新题目进入
|
|
|
if (this.isEditPaper) {
|
|
|
let list = this.evaluationInfo.item
|
|
@@ -320,6 +352,22 @@
|
|
|
console.log(arr)
|
|
|
},
|
|
|
|
|
|
+ averageTotalScore(total, length) {
|
|
|
+ let result = new Array(length).fill(0)
|
|
|
+ // 先判断是否总分除以题目数量能否除尽
|
|
|
+ let remainder = total % length
|
|
|
+ // 如果可以整除 则直接计算
|
|
|
+ if (remainder === 0) {
|
|
|
+ result = result.map(i => total % length)
|
|
|
+ } else {
|
|
|
+ // 如果不能整除 则前面所有取整 最后一题加上余数 即可完成配分
|
|
|
+ let integerScore = parseInt(total / length)
|
|
|
+ result = result.map(i => integerScore)
|
|
|
+ result[result.length - 1] = integerScore + remainder
|
|
|
+ }
|
|
|
+ return result
|
|
|
+ },
|
|
|
+
|
|
|
/** 预览试卷 */
|
|
|
goToPreview() {
|
|
|
this.activeTab = 'preview'
|
|
@@ -370,7 +418,8 @@
|
|
|
console.log('保存的试题列表')
|
|
|
console.log(list)
|
|
|
|
|
|
- let containerName = this.isSchool ? this.$store.state.userInfo.schoolCode : this.$store.state.userInfo.TEAMModelId
|
|
|
+ let containerName = this.isSchool ? this.$store.state.userInfo.schoolCode : this.$store.state.userInfo
|
|
|
+ .TEAMModelId
|
|
|
/* 上传前进行试卷blob查询size */
|
|
|
// let prefixArr = this.getListPrefixs(list)
|
|
|
// let beforeSize = await blobTool.checkPrefixSize(prefixArr, containerName)
|
|
@@ -394,12 +443,17 @@
|
|
|
let composeArr = [exerciseItem, ...exerciseItem.children]
|
|
|
composeArr.forEach(composeItem => {
|
|
|
promiseArr.push(new Promise(async (r, j) => {
|
|
|
- if (composeItem.children.length && composeItem.children[0].id) {
|
|
|
- composeItem.children = composeItem.children.map(i => i.id)
|
|
|
+ if (composeItem.children.length &&
|
|
|
+ composeItem.children[0].id) {
|
|
|
+ composeItem.children = composeItem
|
|
|
+ .children.map(i => i.id)
|
|
|
}
|
|
|
// 保存试题的blob链接
|
|
|
- const itemJsonFile = await this.$evTools.createBlobItem(composeItem)
|
|
|
- let file = new File([JSON.stringify(itemJsonFile)], composeItem.id + ".json");
|
|
|
+ const itemJsonFile = await this.$evTools
|
|
|
+ .createBlobItem(composeItem)
|
|
|
+ let file = new File([JSON.stringify(
|
|
|
+ itemJsonFile)], composeItem
|
|
|
+ .id + ".json");
|
|
|
blobFiles.push(file)
|
|
|
itemJsonFiles.push(composeItem)
|
|
|
r({
|
|
@@ -413,8 +467,10 @@
|
|
|
// 如果已有blob字段 说明是已经保存到blob的试题 只需要将最新试题更新到paper目录下(自动手动挑题情况)
|
|
|
promiseArr.push(new Promise(async (r, j) => {
|
|
|
// 保存试题的blob链接
|
|
|
- const itemJsonFile = await this.$evTools.createBlobItem(exerciseItem)
|
|
|
- let file = new File([JSON.stringify(itemJsonFile)], exerciseItem.id + ".json");
|
|
|
+ const itemJsonFile = await this.$evTools
|
|
|
+ .createBlobItem(exerciseItem)
|
|
|
+ let file = new File([JSON.stringify(itemJsonFile)],
|
|
|
+ exerciseItem.id + ".json");
|
|
|
blobFiles.push(file)
|
|
|
itemJsonFiles.push(exerciseItem)
|
|
|
r({
|
|
@@ -428,31 +484,41 @@
|
|
|
let composeArr = [exerciseItem, ...exerciseItem.children]
|
|
|
composeArr.forEach(composeItem => {
|
|
|
promiseArr.push(new Promise(async (r, j) => {
|
|
|
- if (composeItem.children.length && composeItem.children[0].id) {
|
|
|
- composeItem.children = composeItem.children.map(i => i.id)
|
|
|
+ if (composeItem.children.length && composeItem
|
|
|
+ .children[0].id) {
|
|
|
+ composeItem.children = composeItem.children
|
|
|
+ .map(i => i.id)
|
|
|
}
|
|
|
// 将当前的试题数据转化为BLOB内部的试题JSON格式
|
|
|
- let removeItem = await this.$editorTools.doRemoveMideaHost(composeItem)
|
|
|
- const itemJsonFile = await this.$evTools.createBlobItem(removeItem)
|
|
|
- const cosmosItem = await this.$evTools.createCosmosItem(composeItem)
|
|
|
+ let removeItem = await this.$editorTools
|
|
|
+ .doRemoveMideaHost(composeItem)
|
|
|
+ const itemJsonFile = await this.$evTools
|
|
|
+ .createBlobItem(removeItem)
|
|
|
+ const cosmosItem = await this.$evTools
|
|
|
+ .createCosmosItem(composeItem)
|
|
|
// 首先保存新题目的JSON文件到Blob 然后返回URL链接
|
|
|
- let file = new File([JSON.stringify(itemJsonFile)], composeItem.id + ".json");
|
|
|
+ let file = new File([JSON.stringify(
|
|
|
+ itemJsonFile)], composeItem.id +
|
|
|
+ ".json");
|
|
|
blobFiles.push(file)
|
|
|
try {
|
|
|
// 等待上传blob的返回结果
|
|
|
- let blobFile = await containerClient.upload(file, 'item/' + composeItem.id, undefined, false, false)
|
|
|
+ let blobFile = await containerClient
|
|
|
+ .upload(file, 'item/' + composeItem.id,
|
|
|
+ undefined, false, false)
|
|
|
if (blobFile.blob) {
|
|
|
// 保存试题JSON文件到试卷文件夹需要
|
|
|
itemJsonFiles.push(composeItem)
|
|
|
// 保存到COSMOS是不含base64图片编码的数据 避免数据量过大
|
|
|
cosmosItem.blob = blobFile.blob
|
|
|
// 保存当前试题到数据库
|
|
|
- that.saveExercise(cosmosItem).then(res => {
|
|
|
- r({
|
|
|
- cosmosItem: cosmosItem,
|
|
|
- blobItem: blobFile
|
|
|
+ that.saveExercise(cosmosItem).then(
|
|
|
+ res => {
|
|
|
+ r({
|
|
|
+ cosmosItem: cosmosItem,
|
|
|
+ blobItem: blobFile
|
|
|
+ })
|
|
|
})
|
|
|
- })
|
|
|
} else {
|
|
|
j(500)
|
|
|
}
|
|
@@ -466,15 +532,21 @@
|
|
|
// 如果没有blob字段 说明试题还没有保存到item目录下 则需要进行保存item文件夹后再保存到paper文件夹(导入试题情况)
|
|
|
promiseArr.push(new Promise(async (r, j) => {
|
|
|
// 将当前的试题数据转化为BLOB内部的试题JSON格式
|
|
|
- let removeItem = await this.$editorTools.doRemoveMideaHost(exerciseItem)
|
|
|
- const itemJsonFile = await this.$evTools.createBlobItem(removeItem)
|
|
|
- const cosmosItem = await this.$evTools.createCosmosItem(exerciseItem)
|
|
|
+ let removeItem = await this.$editorTools.doRemoveMideaHost(
|
|
|
+ exerciseItem)
|
|
|
+ const itemJsonFile = await this.$evTools.createBlobItem(
|
|
|
+ removeItem)
|
|
|
+ const cosmosItem = await this.$evTools.createCosmosItem(
|
|
|
+ exerciseItem)
|
|
|
// 首先保存新题目的JSON文件到Blob 然后返回URL链接
|
|
|
- let file = new File([JSON.stringify(itemJsonFile)], exerciseItem.id + ".json");
|
|
|
+ let file = new File([JSON.stringify(itemJsonFile)],
|
|
|
+ exerciseItem.id + ".json");
|
|
|
blobFiles.push(file)
|
|
|
try {
|
|
|
// 等待上传blob的返回结果
|
|
|
- let blobFile = await containerClient.upload(file, 'item/' + exerciseItem.id, undefined, false, false)
|
|
|
+ let blobFile = await containerClient.upload(file,
|
|
|
+ 'item/' + exerciseItem.id, undefined, false,
|
|
|
+ false)
|
|
|
if (blobFile.blob) {
|
|
|
// 保存试题JSON文件到试卷文件夹需要
|
|
|
itemJsonFiles.push(exerciseItem)
|
|
@@ -507,7 +579,9 @@
|
|
|
}], containerName).then(res => {
|
|
|
let slides = []
|
|
|
// 主观题的answer为空数组
|
|
|
- let nullType = ['complete', 'subjective', 'compose', 'correct', 'connector']
|
|
|
+ let nullType = ['complete', 'subjective', 'compose', 'correct',
|
|
|
+ 'connector'
|
|
|
+ ]
|
|
|
result.map(i => i.cosmosItem).forEach(item => {
|
|
|
console.log(item)
|
|
|
let o = {
|
|
@@ -517,7 +591,8 @@
|
|
|
score: item.score || 0,
|
|
|
knowledge: item.knowledge || [],
|
|
|
field: item.field || 1,
|
|
|
- ans: nullType.includes(item.type) ? [] : (item.answer || [])
|
|
|
+ ans: nullType.includes(item.type) ?
|
|
|
+ [] : (item.answer || [])
|
|
|
}
|
|
|
}
|
|
|
item.type === 'compose' && delete o.scoring
|
|
@@ -528,7 +603,8 @@
|
|
|
files: itemJsonFiles
|
|
|
})
|
|
|
}).catch(err => {
|
|
|
- this.$Message.error(this.$t('evaluation.newExercise.uploadErrorTip'));
|
|
|
+ this.$Message.error(this.$t(
|
|
|
+ 'evaluation.newExercise.uploadErrorTip'));
|
|
|
})
|
|
|
}).catch(err => {
|
|
|
console.log(err)
|
|
@@ -560,7 +636,8 @@
|
|
|
|
|
|
/* 保存单个试题 */
|
|
|
saveExercise(item) {
|
|
|
- item.code = item.scope === 'school' ? this.$store.state.userInfo.schoolCode : this.$store.state.userInfo.TEAMModelId
|
|
|
+ item.code = item.scope === 'school' ? this.$store.state.userInfo.schoolCode : this.$store.state.userInfo
|
|
|
+ .TEAMModelId
|
|
|
return new Promise((r, j) => {
|
|
|
this.$api.newEvaluation.SaveSingleExercise({
|
|
|
itemInfo: item,
|
|
@@ -581,9 +658,11 @@
|
|
|
isPaperExist(paperName) {
|
|
|
return new Promise(async (r, j) => {
|
|
|
// 获取初始化Blob需要的数据
|
|
|
- let sasData = this.isSchool ? await this.$tools.getSchoolSas() : await this.$tools.getPrivateSas()
|
|
|
+ let sasData = this.isSchool ? await this.$tools.getSchoolSas() : await this.$tools
|
|
|
+ .getPrivateSas()
|
|
|
//初始化Blob
|
|
|
- let containerClient = new blobTool(sasData.url, sasData.name, sasData.sas, this.isSchool ? 'school' : 'private')
|
|
|
+ let containerClient = new blobTool(sasData.url, sasData.name, sasData.sas, this.isSchool ?
|
|
|
+ 'school' : 'private')
|
|
|
containerClient.exists('paper/' + paperName + '/index.json').then(
|
|
|
(res) => {
|
|
|
r(res)
|
|
@@ -601,7 +680,8 @@
|
|
|
return new Promise(async (r, j) => {
|
|
|
let scope = this.isSchool ? 'school' : 'private'
|
|
|
// 获取初始化Blob需要的数据
|
|
|
- let sasData = this.isSchool ? await this.$tools.getSchoolSas() : await this.$tools.getPrivateSas()
|
|
|
+ let sasData = this.isSchool ? await this.$tools.getSchoolSas() : await this.$tools
|
|
|
+ .getPrivateSas()
|
|
|
//初始化Blob
|
|
|
let containerClient = new blobTool(sasData.url, sasData.name, sasData.sas, scope)
|
|
|
containerClient.isContainerFull(scope).then(
|
|
@@ -665,11 +745,13 @@
|
|
|
})
|
|
|
this.isLoading = true
|
|
|
if (!this.checkComposeScore(arr)) return
|
|
|
- let blobList = await this.getPaperFiles('paper/' + this.evaluationInfo.name)
|
|
|
+ let blobList = await this.getPaperFiles('paper/' + this
|
|
|
+ .evaluationInfo.name)
|
|
|
let files = blobList.blobList.map(i => i.blob)
|
|
|
this.onDeleteBlobPaper(files).then(r => {
|
|
|
if (isContainerFull) {
|
|
|
- this.$Message.warning(this.$t('evaluation.paperList.noSpaceTip'))
|
|
|
+ this.$Message.warning(this.$t(
|
|
|
+ 'evaluation.paperList.noSpaceTip'))
|
|
|
} else {
|
|
|
// 只按照默认顺序保存
|
|
|
// let saveArr = this.viewModel === 'type' ? arr : list
|
|
@@ -679,7 +761,8 @@
|
|
|
},
|
|
|
onCancel: () => {
|
|
|
this.isLoading = false
|
|
|
- this.$Message.warning(this.$t('evaluation.paperList.cancelSaveTip'))
|
|
|
+ this.$Message.warning(this.$t(
|
|
|
+ 'evaluation.paperList.cancelSaveTip'))
|
|
|
}
|
|
|
})
|
|
|
}
|
|
@@ -710,7 +793,8 @@
|
|
|
console.log(childTotalScore)
|
|
|
console.log(index)
|
|
|
let exList = this.$refs.testPaper.$refs.exList
|
|
|
- let exerciseDom = Array.from(exList.$el.getElementsByClassName('exercise-item')).filter(item => item.dataset.id ===
|
|
|
+ let exerciseDom = Array.from(exList.$el.getElementsByClassName('exercise-item')).filter(item =>
|
|
|
+ item.dataset.id ===
|
|
|
i.id)[0]
|
|
|
exerciseDom.style.backgroundColor = '#ffa7a7'
|
|
|
this.$nextTick(() => {
|
|
@@ -725,7 +809,9 @@
|
|
|
setTimeout(() => {
|
|
|
exerciseDom.style.backgroundColor = '#fff'
|
|
|
}, 2000)
|
|
|
- this.$Message.warning(`${ this.$t('evaluation.createPaper.tip1') } ${ index + 1 } ${ this.$t('evaluation.createPaper.tip2') }${ i.score > childTotalScore ? this.$t('evaluation.createPaper.tip3') : this.$t('evaluation.createPaper.tip4') },${ this.$t('evaluation.createPaper.tip5') }`)
|
|
|
+ this.$Message.warning(
|
|
|
+ `${ this.$t('evaluation.createPaper.tip1') } ${ index + 1 } ${ this.$t('evaluation.createPaper.tip2') }${ i.score > childTotalScore ? this.$t('evaluation.createPaper.tip3') : this.$t('evaluation.createPaper.tip4') },${ this.$t('evaluation.createPaper.tip5') }`
|
|
|
+ )
|
|
|
flag = false
|
|
|
this.isLoading = false
|
|
|
break
|
|
@@ -741,9 +827,11 @@
|
|
|
getPaperFiles(path) {
|
|
|
return new Promise(async (r, j) => {
|
|
|
// 获取初始化Blob需要的数据
|
|
|
- let sasData = this.isSchool ? await this.$tools.getSchoolSas() : await this.$tools.getPrivateSas()
|
|
|
+ let sasData = this.isSchool ? await this.$tools.getSchoolSas() : await this.$tools
|
|
|
+ .getPrivateSas()
|
|
|
//初始化Blob
|
|
|
- let containerClient = new blobTool(sasData.url, sasData.name, sasData.sas, this.isSchool ? 'school' : 'private')
|
|
|
+ let containerClient = new blobTool(sasData.url, sasData.name, sasData.sas, this.isSchool ?
|
|
|
+ 'school' : 'private')
|
|
|
// 等待blob的返回结果
|
|
|
containerClient.listBlob({
|
|
|
prefix: path
|
|
@@ -762,9 +850,11 @@
|
|
|
onDeleteBlobPaper(files) {
|
|
|
return new Promise(async (r, j) => {
|
|
|
// 获取初始化Blob需要的数据
|
|
|
- let sasData = this.isSchool ? await this.$tools.getSchoolSas() : await this.$tools.getPrivateSas()
|
|
|
+ let sasData = this.isSchool ? await this.$tools.getSchoolSas() : await this.$tools
|
|
|
+ .getPrivateSas()
|
|
|
//初始化Blob
|
|
|
- let containerClient = new blobTool(sasData.url, sasData.name, sasData.sas, this.isSchool ? 'school' : 'private')
|
|
|
+ let containerClient = new blobTool(sasData.url, sasData.name, sasData.sas, this.isSchool ?
|
|
|
+ 'school' : 'private')
|
|
|
// 等待blob的返回结果
|
|
|
containerClient.deleteBlobBatch(files).then(
|
|
|
(res) => {
|
|
@@ -790,14 +880,19 @@
|
|
|
let guid = this.$tools.guid()
|
|
|
let paperItem = {
|
|
|
id: this.evaluationInfo.id || guid,
|
|
|
- code: this.editPaper ? this.editPaper.code.replace('Paper-','') : (this.isSchool ? this.$store.state.userInfo.schoolCode : this.$store
|
|
|
+ code: this.editPaper ? this.editPaper.code.replace('Paper-', '') : (this
|
|
|
+ .isSchool ? this.$store.state.userInfo.schoolCode : this.$store
|
|
|
.state.userInfo.TEAMModelId),
|
|
|
scope: this.isSchool ? 'school' : 'private',
|
|
|
- gradeIds: this.isSchool ? (this.evaluationInfo.paperGrade.length ? this.evaluationInfo.paperGrade.map(i => i + '') : this.gradeList
|
|
|
- .map((i,index) => index + '')) : [],
|
|
|
- subjectId: this.isSchool ? this.subjectList[this.evaluationInfo.paperSubject].id : null,
|
|
|
- subjectName: this.isSchool ? this.subjectList[this.evaluationInfo.paperSubject].name : '',
|
|
|
- periodId: this.isSchool ? this.schoolInfo.period[this.evaluationInfo.paperPeriod].id : null,
|
|
|
+ gradeIds: this.isSchool ? (this.evaluationInfo.paperGrade.length ? this
|
|
|
+ .evaluationInfo.paperGrade.map(i => i + '') : this.gradeList
|
|
|
+ .map((i, index) => index + '')) : [],
|
|
|
+ subjectId: this.isSchool ? this.subjectList[this.evaluationInfo.paperSubject]
|
|
|
+ .id : null,
|
|
|
+ subjectName: this.isSchool ? this.subjectList[this.evaluationInfo.paperSubject]
|
|
|
+ .name : '',
|
|
|
+ periodId: this.isSchool ? this.schoolInfo.period[this.evaluationInfo
|
|
|
+ .paperPeriod].id : null,
|
|
|
name: this.evaluationInfo.name,
|
|
|
points: this.getPaperPoints(this.evaluationInfo.item),
|
|
|
scoring: this.getAnswers(list),
|
|
@@ -808,16 +903,20 @@
|
|
|
// 首先保存新题目的JSON文件到Blob 然后返回URL链接
|
|
|
let paperFile = new File([JSON.stringify(blobPaper)], "index.json");
|
|
|
// 获取初始化Blob需要的数据
|
|
|
- let sasData = this.evaluationInfo.type === 'private' ? await this.$tools.getPrivateSas() : await this.$tools.getSchoolSas()
|
|
|
+ let sasData = this.evaluationInfo.type === 'private' ? await this.$tools
|
|
|
+ .getPrivateSas() : await this.$tools.getSchoolSas()
|
|
|
//初始化Blob
|
|
|
- let containerClient = new blobTool(sasData.url, sasData.name, sasData.sas, this.evaluationInfo.type)
|
|
|
+ let containerClient = new blobTool(sasData.url, sasData.name, sasData.sas, this
|
|
|
+ .evaluationInfo.type)
|
|
|
|
|
|
- let containerName = paperItem.scope === 'private' ? this.$store.state.userInfo.TEAMModelId : this.$store.state
|
|
|
+ let containerName = paperItem.scope === 'private' ? this.$store.state.userInfo
|
|
|
+ .TEAMModelId : this.$store.state
|
|
|
.userInfo.schoolCode
|
|
|
/* 上传前进行试卷blob查询size */
|
|
|
- let beforeSizeArr = await blobTool.checkPrefixSize(['paper/' + paperItem.name], containerName)
|
|
|
+ let beforeSizeArr = await blobTool.checkPrefixSize(['paper/' + paperItem.name],
|
|
|
+ containerName)
|
|
|
let beforeSize = this._.sum(beforeSizeArr.map(i => i.size))
|
|
|
- console.log('试卷上传前的size',beforeSize)
|
|
|
+ console.log('试卷上传前的size', beforeSize)
|
|
|
|
|
|
try {
|
|
|
let promiseArr = []
|
|
@@ -827,9 +926,11 @@
|
|
|
console.log('试卷ITEM', paperItem)
|
|
|
// return
|
|
|
let privateSas = await this.$tools.getPrivateSas()
|
|
|
- let privateBlob = new blobTool(privateSas.url, privateSas.name, privateSas.sas, 'private')
|
|
|
+ let privateBlob = new blobTool(privateSas.url, privateSas.name, privateSas.sas,
|
|
|
+ 'private')
|
|
|
let schoolSas = await this.$tools.getSchoolSas()
|
|
|
- let schoolBlob = new blobTool(schoolSas.url, schoolSas.name, schoolSas.sas, 'school')
|
|
|
+ let schoolBlob = new blobTool(schoolSas.url, schoolSas.name, schoolSas.sas,
|
|
|
+ 'school')
|
|
|
|
|
|
// 放入试题json文件以及index.json文件
|
|
|
for (let i = 0; i < res.files.length; i++) {
|
|
@@ -839,12 +940,15 @@
|
|
|
|
|
|
let item = res.files[i]
|
|
|
if (item.scope == 'school') {
|
|
|
- containerClient.copyFolder('paper/' + paperItem.name + '/', 'item/' + item.id, schoolBlob, null, false)
|
|
|
+ containerClient.copyFolder('paper/' + paperItem.name +
|
|
|
+ '/', 'item/' + item.id, schoolBlob, null, false
|
|
|
+ )
|
|
|
.then(res => {
|
|
|
r(200)
|
|
|
})
|
|
|
} else {
|
|
|
- containerClient.copyFolder('paper/' + paperItem.name + '/', 'item/' + item.id, privateBlob, null,
|
|
|
+ containerClient.copyFolder('paper/' + paperItem.name +
|
|
|
+ '/', 'item/' + item.id, privateBlob, null,
|
|
|
false).then(res => {
|
|
|
r(200)
|
|
|
})
|
|
@@ -853,7 +957,8 @@
|
|
|
}
|
|
|
promiseArr.push(new Promise(async (r, j) => {
|
|
|
try {
|
|
|
- blobFile = await containerClient.upload(paperFile, 'paper/' + paperItem.name, undefined, false)
|
|
|
+ blobFile = await containerClient.upload(paperFile,
|
|
|
+ 'paper/' + paperItem.name, undefined, false)
|
|
|
console.log('上传到试卷目录下', blobFile)
|
|
|
r(blobFile)
|
|
|
} catch (e) {
|
|
@@ -865,22 +970,27 @@
|
|
|
// 进行试卷文件上传Blob
|
|
|
Promise.all(promiseArr).then(async result => {
|
|
|
/* 上传前进行试卷blob查询size */
|
|
|
- let afterSizeArr = await blobTool.checkPrefixSize(['paper/' + paperItem.name], containerName)
|
|
|
+ let afterSizeArr = await blobTool.checkPrefixSize(['paper/' +
|
|
|
+ paperItem.name
|
|
|
+ ], containerName)
|
|
|
let afterSize = this._.sum(afterSizeArr.map(i => i.size))
|
|
|
console.log('试卷上传后的size', afterSize)
|
|
|
if (blobFile.blob) {
|
|
|
// 保存到COSMOS是不含base64图片编码的数据 避免数据量过大
|
|
|
paperItem.blob = blobFile.blob.split('/index.json')[0]
|
|
|
let params = {
|
|
|
- paper: await this.$evTools.createCosmosPaper(paperItem),
|
|
|
+ paper: await this.$evTools.createCosmosPaper(
|
|
|
+ paperItem),
|
|
|
option: this.isEditPaper ? 'update' : 'insert'
|
|
|
}
|
|
|
// 保存试卷到cosmos
|
|
|
this.$api.learnActivity.SaveExamPaper(params).then(
|
|
|
res => {
|
|
|
if (res.error == null) {
|
|
|
- this.$Message.success(this.isEditPaper ? this.$t('evaluation.paperList.editSuc') : this.$t(
|
|
|
- 'evaluation.paperList.saveSuc'))
|
|
|
+ this.$Message.success(this.isEditPaper ? this
|
|
|
+ .$t('evaluation.paperList.editSuc') :
|
|
|
+ this.$t(
|
|
|
+ 'evaluation.paperList.saveSuc'))
|
|
|
this.isLoading = false
|
|
|
|
|
|
// 子题保存之后 统一更新blobSize
|
|
@@ -889,21 +999,30 @@
|
|
|
size: afterSize - beforeSize
|
|
|
}], containerName).then(res => {
|
|
|
this.$router.push({
|
|
|
- name: this.evaluationInfo.type === 'private' ? 'personalBank' : 'schoolBank',
|
|
|
+ name: this
|
|
|
+ .evaluationInfo
|
|
|
+ .type ===
|
|
|
+ 'private' ?
|
|
|
+ 'personalBank' :
|
|
|
+ 'schoolBank',
|
|
|
params: {
|
|
|
tabName: 'paper'
|
|
|
}
|
|
|
})
|
|
|
}).catch(err => {
|
|
|
- this.$Message.error(this.$t('evaluation.newExercise.uploadErrorTip'));
|
|
|
+ this.$Message.error(this.$t(
|
|
|
+ 'evaluation.newExercise.uploadErrorTip'
|
|
|
+ ));
|
|
|
})
|
|
|
} else {
|
|
|
- this.$Message.error(this.$t('evaluation.paperList.saveFail'))
|
|
|
+ this.$Message.error(this.$t(
|
|
|
+ 'evaluation.paperList.saveFail'))
|
|
|
this.isLoading = false
|
|
|
}
|
|
|
},
|
|
|
err => {
|
|
|
- this.$Message.error(this.$t('evaluation.paperList.saveFail'))
|
|
|
+ this.$Message.error(this.$t(
|
|
|
+ 'evaluation.paperList.saveFail'))
|
|
|
this.isLoading = false
|
|
|
}
|
|
|
)
|
|
@@ -960,21 +1079,23 @@
|
|
|
async doRender(paper) {
|
|
|
console.log('传进来的paper')
|
|
|
console.log(paper)
|
|
|
+ localStorage.setItem('c_edit_paper',JSON.stringify(paper))
|
|
|
let schoolInfo = null
|
|
|
if (paper.scope === 'school') {
|
|
|
schoolInfo = await this.getSchoolBaseInfo()
|
|
|
- this.subjectList = schoolInfo ? this.schoolInfo.period.filter(i => i.id === paper.periodId)[0].subjects : []
|
|
|
+ this.subjectList = schoolInfo ? this.schoolInfo.period.filter(i => i.id === paper.periodId)[0]
|
|
|
+ .subjects : []
|
|
|
}
|
|
|
this.evaluationInfo = {
|
|
|
id: paper.id,
|
|
|
name: paper.name,
|
|
|
code: paper.code,
|
|
|
type: paper.scope,
|
|
|
- paperPeriod: schoolInfo && paper.scope === 'school' ? this.schoolInfo.period.map(i => i.id).indexOf(paper.periodId) :
|
|
|
- null,
|
|
|
+ paperPeriod: schoolInfo && paper.scope === 'school' ? this.schoolInfo.period.map(i => i.id)
|
|
|
+ .indexOf(paper.periodId) : null,
|
|
|
paperGrade: schoolInfo && paper.scope === 'school' ? paper.gradeIds.map(i => +i) : [],
|
|
|
- paperSubject: schoolInfo && paper.scope === 'school' ? this.subjectList.map(i => i.id).indexOf(paper.subjectId) :
|
|
|
- [],
|
|
|
+ paperSubject: schoolInfo && paper.scope === 'school' ? this.subjectList.map(i => i.id).indexOf(
|
|
|
+ paper.subjectId) : [],
|
|
|
score: paper.score,
|
|
|
item: paper.item,
|
|
|
multipleRule: paper.multipleRule || 1,
|
|
@@ -989,6 +1110,7 @@
|
|
|
mounted() {
|
|
|
let routerData = this.$route.params.paper
|
|
|
if (routerData) {
|
|
|
+ console.log(routerData)
|
|
|
this.doRender(routerData)
|
|
|
this.editPaper = routerData
|
|
|
this.isEditPaper = true
|
|
@@ -1010,21 +1132,41 @@
|
|
|
return this.$route.name === 'newSchoolPaper'
|
|
|
},
|
|
|
propPeriod() {
|
|
|
- return this.$route.name === 'newSchoolPaper' && this.subjectList.length ? this.schoolInfo.period[this.evaluationInfo
|
|
|
+ console.log(this.evaluationInfo.paperPeriod)
|
|
|
+ console.log(this.schoolInfo)
|
|
|
+ return this.$route.name === 'newSchoolPaper' && this.subjectList.length && (this.evaluationInfo.paperPeriod || this.evaluationInfo.paperPeriod === 0 ) ? this.schoolInfo.period[this
|
|
|
+ .evaluationInfo
|
|
|
.paperPeriod].id : null
|
|
|
},
|
|
|
propSubject() {
|
|
|
- return this.$route.name === 'newSchoolPaper' && this.subjectList.length ? this.subjectList[this.evaluationInfo.paperSubject]
|
|
|
+ return this.$route.name === 'newSchoolPaper' && this.subjectList.length ? this.subjectList[this
|
|
|
+ .evaluationInfo.paperSubject]
|
|
|
.id : null
|
|
|
}
|
|
|
},
|
|
|
|
|
|
+ beforeRouteEnter(to, from, next) {
|
|
|
+ if (from.name === 'answerSheet' && (to.name === 'newSchoolPaper' || to.name === 'newPrivatePaper')) {
|
|
|
+ console.log('xxxxxxxxxxxx',to)
|
|
|
+ to.meta.isKeep = true
|
|
|
+ }
|
|
|
+ next()
|
|
|
+ },
|
|
|
+ beforeRouteLeave(to, from, next) {
|
|
|
+ if(to.name === 'answerSheet'){
|
|
|
+ console.error(to)
|
|
|
+ console.error(from)
|
|
|
+ // 设置下一个路由的 meta
|
|
|
+ from.meta.isKeep = true; // 让 A 缓存,即不刷新
|
|
|
+ }
|
|
|
+ next();
|
|
|
+ },
|
|
|
watch: {
|
|
|
paperScrollTop: {
|
|
|
handler(n) {
|
|
|
this.$refs.testPaper.isShowBackToTop = n > 200
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
}
|
|
|
}
|
|
|
</script>
|