Explorar o código

feat:1、视频课程试卷提交试卷接口、新增错题接口和收藏功能 2、视频试卷报告页新增解析和重做按钮

xuqiaoying %!s(int64=3) %!d(string=hai) anos
pai
achega
85f05de36c

+ 6 - 1
common/httpList/goods.js

@@ -88,7 +88,12 @@ export default {
 		})
 	},
 	
-	
+	bankReportData(data) {
+		return myRequest({
+			url: '/bank/record/' + data,
+			method: 'get',
+		})
+	},
 	
 	deleteCollectQuestion(data) {
 		return myRequest({

+ 2 - 1
pages2/bank/questionBank.vue

@@ -1333,6 +1333,7 @@ export default {
           goodsId: this.goodsId,
           questionIds: doWrongQuestionIds,
           recordId: this.recordId,
+          type: 1, // 题库试卷传1
         })
         .then((res) => {});
     },
@@ -1931,7 +1932,6 @@ export default {
       this.show = true;
     },
     changeIndex(index) {
-      console.log('点击变化', index)
       this.current = index;
     },
 
@@ -2197,6 +2197,7 @@ export default {
           orderGoodsId: this.orderGoodsId,
           questionIds: doWrongQuestionIds,
           recordId: this.recordId,
+          type: 1, // 题库试卷传1
         })
         .then((res) => {});
     },

+ 12 - 4
pages2/bank/questionBankAllExplain.vue

@@ -654,6 +654,7 @@ export default {
       recordId: "",
       chapterId: "",
       moduleId: "",
+      courseType: 1, //1题库,2视频 商品类型
     };
   },
   onLoad(option) {
@@ -662,7 +663,7 @@ export default {
     this.chapterId = option.chapterId || "";
     this.moduleId = option.moduleId || "";
     this.recordId = option.recordId || "";
-
+    this.courseType = option.courseType
     let showDialog = uni.getStorageSync("showDialog");
 
     if (showDialog) {
@@ -683,9 +684,16 @@ export default {
     },
 
     goodsQuestionList() {
-      this.$api.examReport(this.recordId).then((res) => {
-        this.questionList = JSON.parse(res.data.data.historyExamJson);
-      });
+      if (this.courseType == 2) {
+        this.$api.bankReportData(this.recordId).then((res) => {
+          this.questionList = JSON.parse(res.data.data.historyExamJson)
+        })
+      } else {
+        this.$api.examReport(this.recordId).then((res) => {
+          this.questionList = JSON.parse(res.data.data.historyExamJson);
+        });
+      }
+      
     },
 
     openFooterTab() {

+ 4 - 0
pages2/bank/questionBankContinue.vue

@@ -1032,6 +1032,7 @@ export default {
         let json = JSON.parse(res.data.data.historyExamJson);
         this.examData = res.data.data;
         this.questionList = json;
+        this.getCollectInfo(this.current)
       });
     },
 
@@ -1348,6 +1349,7 @@ export default {
           questionIds: doWrongQuestionIds,
           recordId: this.recordId,
           orderGoodsId: this.orderGoodsId,
+          type: 1, // 题库试卷传1
         })
         .then((res) => {});
     },
@@ -1607,6 +1609,7 @@ export default {
           orderGoodsId: this.orderGoodsId,
           questionIds: doWrongQuestionIds,
           recordId: this.recordId,
+          type: 1, // 题库试卷传1
         })
         .then((res) => {});
     },
@@ -1623,6 +1626,7 @@ export default {
 
     swiperChange(e) {
       this.current = e.detail.current;
+      this.getCollectInfo(this.current)
     },
 
     deleteImg(imgIndex, bankIndex) {

+ 1 - 0
pages2/bank/questionBankExplainDetail.vue

@@ -1497,6 +1497,7 @@ export default {
 
     swiperChange(e) {
       this.current = e.detail.current;
+      this.getCollectInfo(this.current)
     },
 
     deleteImg(imgIndex, bankIndex) {

+ 18 - 6
pages2/bank/questionBankWrongExplain.vue

@@ -648,6 +648,7 @@ export default {
       recordId: "",
       chapterId: "",
       moduleId: "",
+      courseType: 1, //1题库,2视频 商品类型
     };
   },
   onLoad(option) {
@@ -656,7 +657,7 @@ export default {
     this.chapterId = option.chapterId || "";
     this.moduleId = option.moduleId || "";
     this.recordId = option.recordId || "";
-
+    this.courseType = option.courseType
     let showDialog = uni.getStorageSync("showDialog");
 
     if (showDialog) {
@@ -677,10 +678,21 @@ export default {
     },
 
     goodsQuestionList() {
-      this.$api.examReport(this.recordId).then((res) => {
-        let questionList = JSON.parse(res.data.data.historyExamJson);
+      if (this.courseType == 2) {
+        this.$api.bankReportData(this.recordId).then((res) => {
+          let questionList = JSON.parse(res.data.data.historyExamJson)
+          this.listForEach(questionList)
+        })
+      } else {
+        this.$api.examReport(this.recordId).then((res) => {
+          let questionList = JSON.parse(res.data.data.historyExamJson)
 
-        questionList.forEach((json) => {
+          this.listForEach(questionList)
+        });
+      }
+    },
+    listForEach(questionList) {
+      questionList.forEach((json) => {
           //只获取类型1,2,3 单选,多选,判断 ,主观题灭有对错
           if (json.type == 1 || json.type == 3) {
             //单选判断
@@ -702,9 +714,9 @@ export default {
             }
           }
         });
-      });
-    },
 
+        // console.log(this.questionList);
+    },
     openFooterTab() {
       this.show = true;
     },

+ 119 - 22
pages2/class/questionBank.vue

@@ -626,11 +626,24 @@
           </template>
 
           <view class="footer_btn">
-            <view class="collect">
+            <!-- <view class="collect">
               <view v-if="collectList[bankIndex]">
                 <image src="/static/icon/collected.png" mode=""></image>
                 <view>取消收藏</view>
               </view>
+            </view> -->
+            <view
+              class="collect show"
+              @click="collect(collectList[bankIndex], bankIndex)"
+            >
+              <view v-if="collectList[bankIndex]">
+                <image src="/static/icon/collected.png" mode=""></image>
+                <view>取消收藏</view>
+              </view>
+              <view v-if="!collectList[bankIndex]">
+                <image src="/static/icon/collect.png" mode=""></image>
+                <view>收藏</view>
+              </view>
             </view>
             <view class="flex_center" @click="openFooterTab">
               <view class="up-icon">
@@ -744,7 +757,7 @@
           }}
         </view>
         <view class="classFootsty" v-if="cgType === 6">
-          <view class="btnsty btns1" @click="submit">立即交卷</view>
+          <view class="btnsty btns1" @click="submit()">立即交卷</view>
           <view class="btnsty btns2" @click="showpopups = false">继续做题</view>
         </view>
         <view class="classFootsty" v-if="cgType === 7">
@@ -757,7 +770,7 @@
         </view>
         <view class="classFootsty" v-if="cgType === 9">
           <view class="btnsty btns1" @click="showpopups = false">暂不交卷</view>
-          <view class="btnsty btns2" @click="submit">立即交卷</view>
+          <view class="btnsty btns2" @click="submit()">立即交卷</view>
         </view>
       </view>
     </u-popup>
@@ -1367,6 +1380,8 @@ export default {
       if (this.needPhoto && !this.isTakePhoto) {
         return;
       }
+      this.submit('leaveNow')
+      return
       let score = 0; //计算总分
       let reportStatus = 0;
       let number = 0;
@@ -1473,20 +1488,20 @@ export default {
 
       this.$api
         .bankRecordEdit({
-          chapterId: this.chapterId || 0,
           moduleId: this.moduleId || 0,
+          chapterId: this.chapterId || 0,
           sectionId: this.sectionId || 0,
-          examId: this.id,
-          goodsId: this.goodsId,
+          gradeId: this.gradeId,
+          courseId: this.courseId,
           orderGoodsId: this.orderGoodsId,
+          goodsId: this.goodsId,
+          examId: this.id,
           recordId: this.recordId,
-          courseId: this.courseId,
           reportStatus: reportStatus,
           rightQuestionNum: number,
           doQuestionNum: doQuestionNum,
           status: 1,
           doQuestionIds: doQuestionIds.join(","),
-          gradeId: this.gradeId,
           performance: score,
           totalScore: allScore,
           type: this.examType,
@@ -1509,6 +1524,8 @@ export default {
      */
     examRecordEdit() {
       if (!this.isSubmit) {
+        this.submit('leave')
+        return
         let number = 0;
         let score = 0;
         let doQuestionNum = 0;
@@ -1603,14 +1620,14 @@ export default {
 
         this.$api
           .bankRecordEdit({
-            chapterId: this.chapterId || 0,
             moduleId: this.moduleId || 0,
+            chapterId: this.chapterId || 0,
             sectionId: this.sectionId || 0,
             gradeId: this.gradeId,
-            examId: this.id,
             courseId: this.courseId,
             orderGoodsId: this.orderGoodsId,
             goodsId: this.goodsId,
+            examId: this.id,
             recordId: this.recordId,
 						lessQuestionNum:lessQuestionNum,
             performance: score,
@@ -1789,7 +1806,7 @@ export default {
 
           this.questionList = res.data.data;
           this.lastCount = this.questionList.length;
-
+          this.getCollectInfo(this.current)
           await this.examRecord();
         });
     },
@@ -2026,15 +2043,73 @@ export default {
       this.showDialog = false;
     },
     changeIndex(index) {
-      console.log('点击变化', index)
       this.current = index;
     },
 
     swiperChange(e) {
-      console.log('切换', e.detail.current, this.questionList.length)
       this.current = e.detail.current;
+      this.getCollectInfo(this.current)
+    },
+    /**
+     * @param {Object} current
+     * 获取收藏信息
+     */
+    getCollectInfo(current) {
+      this.$api
+        .getCollectInfo({
+          examId: this.id,
+          questionId: this.questionList[current].questionId,
+          goodsId: this.goodsId,
+          orderGoodsId: this.orderGoodsId,
+        })
+        .then((res) => {
+          if (res.data.code == 500) {
+            this.$set(this.collectList, current, false);
+          } else if (res.data.code == 200) {
+            this.$set(this.collectList, current, res.data.data);
+          }
+        });
+    },
+    /**
+     * @param {Object} state
+     * @param {Object} index
+     * 收藏
+     */
+    collect(state, index) {
+      if (!state) {
+        this.$api.collectQuestion({
+            examId: this.id,
+            questionId: this.questionList[index].questionId,
+            goodsId: this.goodsId || "",
+            orderGoodsId: this.orderGoodsId,
+          })
+          .then((res) => {
+            if (res.data.code == 200) {
+              this.$set(this.collectList, index, true);
+              uni.showToast({
+                title: "收藏成功",
+                duration: 2000,
+                icon: "none",
+              });
+              this.getCollectInfo(index);
+            }
+          });
+      } else {
+        this.$api
+          .deleteCollectQuestion(this.collectList[index].collectQuestionId)
+          .then((res) => {
+            if (res.data.code == 200) {
+              this.$set(this.collectList, index, false);
+              uni.showToast({
+                title: "取消收藏成功",
+                duration: 2000,
+                icon: "none",
+              });
+            }
+          });
+      }
+      return;
     },
-
     pdsubmit() {
       let ansCount = this.questionOverNum(true); //已答题数
       this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
@@ -2071,7 +2146,8 @@ export default {
     /**
      * 交卷
      */
-    submit() {
+    submit(typesubmit) {
+      console.log('交卷', typesubmit)
       let score = 0; //计算总分
       let reportStatus = 0;
       let number = 0; //做对的题目数量
@@ -2227,16 +2303,17 @@ export default {
           recordId: this.recordId,
           courseId: this.courseId,
           rightQuestionNum: number,
+          lessQuestionNum: lessQuestionNum,
           status: 1,
           doQuestionIds: doQuestionIds.join(","),
-          // rightQuestionIds:rightQuestionIds.join(','),
-          // doQuestionNum: doQuestionNum,
+          rightQuestionIds: rightQuestionIds.join(','),
+          doQuestionNum: doQuestionNum,
           performance: score,
           totalScore: allScore,
           type: this.examType,
-          // examTime: parseInt(this.allTimes),
-          // doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
-          // historyExamJson: JSON.stringify(this.questionList)
+          examTime: parseInt(this.allTimes),
+          doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
+          historyExamJson: JSON.stringify(this.questionList)
         })
         .then((res) => {
           this.isSubmit = true;
@@ -2247,7 +2324,8 @@ export default {
               mask: true,
               icon: "none",
             });
-
+            if (!typesubmit) {
+              console.log('跳转----')
             setTimeout(() => {
               uni.redirectTo({
                 url:
@@ -2263,11 +2341,30 @@ export default {
                   reportStatus +
 									"&lessQuestionNum=" +
 									lessQuestionNum +
-                  "&examId=" + this.id
+                  "&examId=" + this.id + '&recordId=' + this.recordId + '&type=' + this.examType + '&orderGoodsId='+ this.orderGoodsId,
               });
             }, 1000);
           }
+          }
         });
+
+        //错题集id提交(客观题)
+      this.$api
+        .examWrongRecord({
+          moduleId: this.moduleId || 0,
+          chapterId: this.chapterId || 0,
+          sectionId: this.sectionId || 0,
+          gradeId: this.gradeId,
+          courseId: this.courseId,
+          examId: this.id,
+          goodsId: this.goodsId,
+          orderGoodsId: this.orderGoodsId,
+          questionIds: doWrongQuestionIds,
+          recordId: this.recordId,
+          type:  2, // 视频课程的传2
+        })
+        .then((res) => {})
+        .catch((err) => {})
     },
 
     /**

+ 94 - 1
pages2/class/question_report.vue

@@ -33,6 +33,34 @@
 					</view>
 				</view>
 			</view>
+
+			<view class="dis_fst">
+				<navigator
+					 v-if="doWrongQuestionNum != 0"
+					:url="
+						'/pages2/bank/questionBankWrongExplain?recordId=' + reportdata.recordId+'&id='+ reportdata.examId + '&courseType=2'
+					"
+				>
+					<view class="btnACs">错题解析</view>
+				</navigator>
+				<navigator
+					:url="
+						'/pages2/bank/questionBankAllExplain?id=' +
+							reportdata.examId +
+							'&goodsid=' +
+							reportdata.goodsId +
+							'&moduleId=' +
+							reportdata.moduleId +
+							'&chapterId=' +
+							reportdata.chapterId +
+							'&recordId='+ reportdata.recordId + '&courseType=2'
+					"
+				>
+					<view class="btnACs">全部解析</view>
+				</navigator>
+				<view class="btnACs" @click="doRepeat(reportdata.examId, reportdata.goodsId, reportdata.moduleId, reportdata.chapterId)">重新做题</view>
+				<!-- <view class="btnACs" v-if="nextExamId" @click="backBank">继续做题</view> -->
+			</view>
 		</view>
 		<view class="bottom">
 			<view class="circle-wrap">
@@ -113,6 +141,10 @@ export default {
 			pageNum: 1,
 			pageSize: 10,
 			total: 0,
+			recordId: '',
+			reportdata: {},
+			examType: 0, // 3-模块,1-章,2-节
+			orderGoodsId: ''
 		};
 	},
 	onPullDownRefresh() {
@@ -202,7 +234,10 @@ export default {
 		});
 	},
 	async onLoad(option) {
+		this.examType = option.type
+		this.recordId = option.recordId
 		this.examId = option.examId
+		this.orderGoodsId = option.orderGoodsId
 		this.examTime = option.examTime;
 		this.doTime = option.doTime;
 		this.reportStatus = option.reportStatus;
@@ -212,7 +247,7 @@ export default {
 		this.lessQuestionNum = option.lessQuestionNum;
 		this.totalScore = +option.totalScore;
 		// this.hideBtns = Boolean(option.hideBtns);
-		
+		this.bankReport()
 	},
 	methods: {
 		getcourList() {
@@ -248,6 +283,64 @@ export default {
                 })
             }
         },
+		bankReport() {
+			this.$api.bankReportData(this.recordId).then((res) => {
+				this.reportdata = res.data.data
+				console.log('reportdata:', this.reportdata)
+			});
+		},
+		/**
+		 * 去做题
+		 */
+		async doRepeat(examId, goodsId, moduleId = 0, chapterId = 0) {
+			let count = await this.bankRecordDoNum()
+			let answerNum = await this.getExamDetail(examId);
+			//超过答题次数
+			if (answerNum > 0 && count >= answerNum) {
+				this.$u.toast('该试卷只能答题' + answerNum + '次!');
+				return;
+			}
+
+			// answerNum==0没有答题次数限制
+			if (answerNum == 0 || (answerNum - count > 0 && answerNum > 0)) {
+				const {courseId, gradeId, sectionId} = this.reportdata
+				uni.redirectTo({
+					url:"/pages2/class/questionBank?courseId=" + courseId + "&gradeId=" + gradeId + "&isFromVideo=1&id=" + examId +
+					"&goodsid=" + goodsId + "&moduleId=" + moduleId + "&chapterId=" + chapterId + "&sectionId=" + sectionId + "&orderGoodsId=" +
+					this.orderGoodsId + "&type=" + this.examType,
+				})
+			}
+			
+		},
+		/**
+		 * 获取试卷已做的次数
+		 */
+		bankRecordDoNum() {
+			return new Promise((resolve) => {
+				this.$api.bankRecordDoNum({
+					goodsId: this.reportdata.goodsId,
+					gradeId: this.reportdata.gradeId,
+					chapterId: this.reportdata.chapterId || 0,
+					courseId: this.reportdata.courseId,
+					moduleId: this.reportdata.moduleId || 0,
+					examId: this.reportdata.examId,
+				})
+				.then((res) => {
+					resolve(res.data.data);
+				});
+			});
+		},
+		/**
+		 * @param {Object} exam_id
+		 * 获取试卷可以做的次数
+		 */
+		getExamDetail(exam_id) {
+			return new Promise(resolve => {
+				this.$api.getExamDetail(exam_id).then(res => {
+					resolve(res.data.data.answerNum);
+				});
+			});
+		},
 	}
 };
 </script>