Просмотр исходного кода

Merge branch 'develop5.0-tmd' of http://52.130.252.100:10000/TEAMMODEL/TEAMModelOS into develop5.0-tmd

Li 3 лет назад
Родитель
Сommit
49d6c0cab6

+ 3 - 2
TEAMModelOS/ClientApp/src/components/evaluation/ExerciseList.vue

@@ -218,7 +218,7 @@
 				return new Promise(async (r,j) => {
 					if(list.length){
 						/* 如果是评测里面的试题 则不需要从getFullItem取 */
-						let blobList = this.examPropScope ? list : await this.$evTools.getFullItem(list,undefined,this.inSyllabus)
+						let blobList = this.examPropScope && !this.inSyllabus ? list : await this.$evTools.getFullItem(list,undefined,this.inSyllabus)
 						r(blobList)
 					}else{
 						r([])
@@ -347,9 +347,10 @@
 				// 拿到当前页码需要展示的数据
 				this.$emit("pageScroll", 0);
 				let simpleList = this.originData.slice(start, end);
+				console.log('exercise-list > simpleList',simpleList,this.hasSas,this.examPropScope)
 				try {
 					// 执行试题换取完整JSON数据
-					this.exerciseList = this.hasSas ? simpleList : await this.getBlobList(simpleList);
+					this.exerciseList = this.hasSas && !this.inSyllabus ? simpleList : await this.getBlobList(simpleList);
 					this.currentPage = page;
 					setTimeout(() => {
 						this.dataLoading = false

+ 18 - 4
TEAMModelOS/ClientApp/src/utils/evTools.js

@@ -147,16 +147,24 @@ export default {
 		})
 	},
 	/* 根据醍摩豆ID获取对应用户Blob内部的完整试题 */
-	getFullItemByTmdId(tmdId,blob){
+	getFullItemByTmdId(tmdId,blob,inSyllabus){
 		return new Promise(async (r,j) => {
 			let privateSas = await this.getBlobPrivateSas(tmdId)
 			let fullPath = this.getBlobHost() +  '/' + tmdId + blob + privateSas
 			let jsonData = JSON.parse(await $tools.getFile(fullPath))
 			// 如果是综合题 那就拿到children里面的小题id集合 去换取小题的blobJSON文件 然后替换children的内容
 			if(jsonData.exercise.children.length && jsonData.exercise.type === 'compose'){
-				let childrenUrls = jsonData.exercise.children.map(i => this.getBlobHost() +  '/' + tmdId + '/item/' + i + '/' + i + '.json' + privateSas)
+				let childrenUrls;
+				if(inSyllabus){
+					let syllabusPrefix = '/syllabus/' + blob.split('/')[2] + '/' + jsonData.id
+					childrenUrls = jsonData.exercise.children.map(i => this.getBlobHost() +  '/' + tmdId + syllabusPrefix + '/' + i.id  + '.json' + privateSas)
+				}else{
+					childrenUrls = jsonData.exercise.children.map(i => this.getBlobHost() +  '/' + tmdId + '/item/' + i + '/' + i + '.json' + privateSas)
+				}
+				console.log(childrenUrls);
 				jsonData.exercise.children = await this.getFullChildren(childrenUrls,tmdId)
 			}
+			
 			// 调整渲染试题数据结构
 			jsonData.exercise.question = jsonData.item[0].question
 			jsonData.exercise.blob = fullPath
@@ -214,10 +222,15 @@ export default {
 						try{
 							let jsonInfo = list[i].blob.includes('https://') ? await $tools.getFile(list[i].blob + sasString.sas) : await $tools.getFile(blobHost + list[i].blob + sasString.sas)
 							let jsonData = JSON.parse(jsonInfo)
-							console.log(jsonData.exercise.children.length)
 							// 如果是综合题 那就拿到children里面的小题id集合 去换取小题的blobJSON文件 然后替换children的内容
 							if(jsonData.exercise.children.length && jsonData.exercise.type === 'compose'){
-								let childrenUrls = jsonData.exercise.children.map(i => blobHost + '/item/' + i + '/' + i + '.json' + sasString.sas)
+								let childrenUrls;
+								if(inSyllabus){
+									let syllabusPrefix = '/syllabus/' + list[i].blob.split('/')[2]  + '/' + list[i].id
+									childrenUrls = jsonData.exercise.children.map(i => blobHost + syllabusPrefix + '/' + i.id + '.json' + sasString.sas)
+								}else{
+									childrenUrls = jsonData.exercise.children.map(i => blobHost + '/item/' + i + '/' + i + '.json' + sasString.sas)
+								}
 								console.log(childrenUrls);
 								jsonData.exercise.children = await this.getFullChildren(childrenUrls,list[i].code,list[i].scope)
 							}
@@ -234,6 +247,7 @@ export default {
 							jsonData.exercise = await this.doAddHost(jsonData.exercise,null,null,inSyllabus)
 							r(jsonData.exercise)
 						}catch(e){
+							console.log(e)
 							j(e)
 							// this.$Message.error(e)
 						}

+ 87 - 43
TEAMModelOS/ClientApp/src/view/syllabus/Syllabus.vue

@@ -58,7 +58,7 @@
 								<div v-for="(volume,volumeIndex) in volumeList" :key="volume.id"
 									:class="['volume-item',activeVolumeIndex === volumeIndex ? 'volume-active' : '']"
 									@click="onVolumeClick(volume,volumeIndex)">
-									<p class="volume-item-name">{{ volume.name }} <span
+									<p class="volume-item-name">{{ volume.name }}<span
 											class="status-idDel status-coedit"
 											v-if="hasVolumeAuth(volume.auth) && isSchool">{{ $t('syllabus.canEdit') }}</span>
 									</p>
@@ -547,7 +547,7 @@
 					"data": this.volumeList.map((i, index) => {
 						return {
 							key: i.id,
-							value: index
+							value: this.volumeList.length - index
 						}
 					})
 				}).then(res => {
@@ -664,7 +664,7 @@
 				this.$api.syllabus.FindVolumes(findParams).then(res => {
 					if (!res.error) {
 						this.isLoading = false
-						this.volumeList = res.volumes
+						this.volumeList = this.sortByOrderAndTime(res.volumes)
 						this.originVolumeList = JSON.parse(JSON.stringify(this.volumeList))
 						this.myVolumeList = JSON.parse(JSON.stringify(this.volumeList))
 						let activeIndex = this.activeVolumeIndex || 0
@@ -677,6 +677,25 @@
 					this.$Message.error(err);
 				})
 			},
+			/* 先按照order排序再按照新建时间排序 */
+			sortByOrderAndTime(arr){
+				arr.sort((a,b) => {
+				    if(b.order > a.order){
+				        return 1
+				    }
+				    if(b.order < a.order){
+				        return -1
+				    }
+				    if(b.order === a.order){
+				        if(b.createTime > a.createTime){
+				            return 1
+				        }else{
+				            return -1
+				        }
+				    }
+				})
+				return arr
+			},
 			/* 获取分享来的册别列表 */
 			getShareVolumeList(needRefresh) {
 				this.$api.syllabus.FindShare({
@@ -1555,50 +1574,73 @@
 					console.log(isSaveToItem)
 					let targetPrefix = isSaveToItem ? 'item/' : `syllabus/${this.curNode.id}/`
 					let sourcePrefix = 'item/'
-					
-					let fn = async (pItem) => {
-						let targetPath = targetPrefix + pItem.id + '/'
-						let sourcePath = sourcePrefix + pItem.id
-						let privateSas = await this.$tools.getPrivateSas()
-						let privateBlobTool = new BlobTool(privateSas.url, privateSas.name, privateSas.sas,
-							'private')
-						let schoolSas = await this.$tools.getSchoolSas()
-						let schoolBlobTool = new BlobTool(schoolSas.url, schoolSas.name, schoolSas.sas,
-							'school')
-						let toClient = this.isSchool ? schoolBlobTool : privateBlobTool
-						let fromClient = pItem.scope === 'private' ? privateBlobTool : schoolBlobTool
-						const itemJsonFile = await this.$evTools.createBlobItem(pItem);
-						let file = new File([JSON.stringify(itemJsonFile)], pItem.id + ".json", {
-							type: "",
-						});
-						// 先把对应试题目录下的全部复制到校本BLOB 然后再更新添加学段科目等字段后的题目Json文件
-						toClient.copyFolder(targetPath, sourcePath, fromClient).then(async res => {
-							try {
-								let blobFile = await toClient.upload(file, targetPrefix + pItem.id);
-								if (blobFile.blob) {
-									if (isSaveToItem) {
-										this.saveExercise(pItem).then(result => {
-											console.log(result)
-											r(result)
-										})
-									} else {
-										r({
-											id: pItem.id,
-											question: pItem.question,
-											blob: '/' + targetPath + pItem.id + '.json'
-										})
+					// 可能是综合题 则需要对小题进行批量处理
+					let fn = async (pItem,pId) => {
+						return new Promise(async (r2,j2) => {
+							console.log(pItem)
+							// 判断是否是小题 如果是小题 则保存在大题的目录下
+							let targetPath = pId ? `syllabus/${this.curNode.id}/${pId}/` : targetPrefix + pItem.id + '/'
+							let sourcePath = sourcePrefix + pItem.id
+							let privateSas = await this.$tools.getPrivateSas()
+							let privateBlobTool = new BlobTool(privateSas.url, privateSas.name, privateSas.sas,
+								'private')
+							let schoolSas = await this.$tools.getSchoolSas()
+							let schoolBlobTool = new BlobTool(schoolSas.url, schoolSas.name, schoolSas.sas,
+								'school')
+							let toClient = this.isSchool ? schoolBlobTool : privateBlobTool
+							let fromClient = pItem.scope === 'private' ? privateBlobTool : schoolBlobTool
+							const itemJsonFile = await this.$evTools.createBlobItem(pItem);
+							let file = new File([JSON.stringify(itemJsonFile)], pItem.id + ".json", {
+								type: "",
+							});
+							// 先把对应试题目录下的全部复制到校本BLOB 然后再更新添加学段科目等字段后的题目Json文件
+							toClient.copyFolder(targetPath, sourcePath, fromClient).then(async res => {
+								try {
+									let blobFile = await toClient.upload(file, pId ? `syllabus/${this.curNode.id}/${pId}` : targetPrefix + pItem.id);
+									if (blobFile.blob) {
+										if (isSaveToItem) {
+											this.saveExercise(pItem).then(result => {
+												console.log(result)
+												r2(result)
+											})
+										} else {
+											r2({
+												id: pItem.id,
+												question: pItem.question,
+												blob: '/' + targetPath + pItem.id + '.json'
+											})
+										}
 									}
+								} catch (e) {
+									console.log(e)
+									j2(e)
 								}
-							} catch (e) {
-								console.log(e)
-								j(e)
-							}
-						}).catch(err => {
-							j(err)
+							}).catch(err => {
+								j2(err)
+							})
 						})
 					}
-					fn(exerciseItem)
 					
+					let promiseArr = []
+					if(exerciseItem.children.length){
+						console.log(exerciseItem.children.map(i => i.id))
+						exerciseItem.children.forEach(i => {
+							promiseArr.push(fn(i,exerciseItem.id))
+						})
+					}
+					promiseArr.push(fn(exerciseItem))
+					
+					Promise.all(promiseArr).then(result => {
+						console.log(result)
+						r({
+							id: exerciseItem.id,
+							question: exerciseItem.question,
+							blob: '/' + targetPrefix + exerciseItem.id + '/' + exerciseItem.id + '.json'
+						})
+					}).catch(e => {
+						console.log(e)
+						j(e)
+					})
 				})
 			},
 			/* 获取关联的试题数据 */
@@ -1998,7 +2040,7 @@
 						// 如果不是当前用户自己的试题 则需要去获取他人BLOB内部的试题JSON文件
 						if (tmdId !== this.curTeammodelId) {
 							this.isFullList = 'true'
-							let fullItemJson = await this.$evTools.getFullItemByTmdId(tmdId, item.link)
+							let fullItemJson = await this.$evTools.getFullItemByTmdId(tmdId, item.link, true)
 							console.log(fullItemJson);
 							this.questionList = [fullItemJson]
 						} else {
@@ -2204,6 +2246,8 @@
 						addVolumeParams.syllabusIds = this.allChapterIds || []
 						addVolumeParams.creatorId = this.curVolume.creatorId
 						addVolumeParams.creatorName = this.curVolume.creatorName
+					}else{
+						addVolumeParams.order = this.volumeList.length + 1
 					}
 					if (this.isSaveSyllabus) {
 						addVolumeParams = this.curVolume