Browse Source

新增关联试卷

xuqiaoying 3 years ago
parent
commit
905ad6c056

+ 0 - 7
common/httpList/course.js

@@ -215,11 +215,4 @@ export default {
 			data: data
 		})
 	},
-	reSectionExamList(data) {
-		return myRequest({
-			url: '/course/sectionExamList',
-			method: 'get',
-			data: data
-		})
-	},
 }

+ 26 - 29
components/course/courseChapter.vue

@@ -28,7 +28,7 @@
             :menuItem="itemM"
             :levelId="levelId + '-' + itemM.sectionId"
             :testType="2"
-            :sectionExam='sectionExam'
+            :ChapterSectionExam='sectionExam'
             @togoBack='togoBack()'
           ></courseSection>
           <u-line v-if="indexM < list.length - 1"></u-line>
@@ -163,8 +163,8 @@ export default {
   },
   methods: {
     ...mapMutations(["updateChapterOpen"]),
+    // 调用节的方法
     togoBack(value) {
-      console.log('章的节', value , this.$refs.ChapterSection)
       this.$refs.ChapterSection[0].ChapterExam()
     },
     goodsTodayStudySectionNum() {
@@ -182,7 +182,6 @@ export default {
       });
     },
     refreshList(isRebuild) {
-      console.log(9999);
       let moduleId = this.menuItem.moduleId ? this.menuItem.moduleId : 0;
       if (this.isRebuild) {
         this.getReSectionList(
@@ -200,7 +199,6 @@ export default {
       }
 
       this.$emit("playEnd", { isRebuild: isRebuild.isRebuild });
-      console.log(10000);
       // let moduleId = this.menuItem.moduleId?this.menuItem.moduleId:0
       // this.getBuySectionList(this.menuItem.id,this.menuItem.courseId,moduleId)
     },
@@ -278,14 +276,14 @@ export default {
           return;
         }
       }
-      console.log(this.learningOrder, "this.learningOrder");
+      // console.log(this.learningOrder, "this.learningOrder");
       if (this.learningOrder == 1) {
         if (this.canLearn) {
           let num = await this.bankRecordDoNum(item.typeId);
           //有次数限制
           if (item.answerNum - num > 0 && item.answerNum > 0) {
             // this.$set(this.list[index],'doNum',(item.doNum+1))
-            console.log(this.list[index]);
+            // console.log(this.list[index]);
             uni.navigateTo({
               url:
                 "/pages2/class/questionBank?courseId=" +
@@ -301,7 +299,9 @@ export default {
                 "&chapterId=" +
                 chapterId +
                 "&orderGoodsId=" +
-                this.orderGoodsId,
+                this.orderGoodsId +
+				        "&types=1"
+                ,
             });
             this.studyLog()
             //没有答题次数限制
@@ -321,7 +321,8 @@ export default {
                 "&chapterId=" +
                 chapterId +
                 "&orderGoodsId=" +
-                this.orderGoodsId,
+                this.orderGoodsId +
+				        "&types=1",
             });
             this.studyLog()
           } else {
@@ -363,7 +364,7 @@ export default {
             }
           }
         }
-        console.log(newRows);
+        // console.log(newRows);
         let isAllLearn = newRows.every((item) => {
           return item.studyStatus == 1;
         });
@@ -377,7 +378,7 @@ export default {
           //有次数限制
           if (item.answerNum - num > 0 && item.answerNum > 0) {
             // this.$set(this.list[index],'doNum',(item.doNum+1))
-            console.log(this.list[index]);
+            // console.log(this.list[index]);
             uni.navigateTo({
               url:
                 "/pages2/class/questionBank?courseId=" +
@@ -393,7 +394,8 @@ export default {
                 "&chapterId=" +
                 chapterId +
                 "&orderGoodsId=" +
-                this.orderGoodsId,
+                this.orderGoodsId +
+				        "&types=1",
             });
             this.studyLog()
             //没有答题次数限制
@@ -413,7 +415,8 @@ export default {
                 "&chapterId=" +
                 chapterId +
                 "&orderGoodsId=" +
-                this.orderGoodsId,
+                this.orderGoodsId +
+				        "&types=1",
             });
             this.studyLog()
           } else {
@@ -435,7 +438,7 @@ export default {
         //有次数限制
         if (item.answerNum - item.doNum > 0 && item.answerNum > 0) {
           // this.$set(this.list[index],'doNum',(item.doNum+1))
-          console.log(this.list[index]);
+          // console.log(this.list[index]);
           uni.navigateTo({
             url:
               "/pages2/class/questionBank?courseId=" +
@@ -451,7 +454,8 @@ export default {
               "&chapterId=" +
               chapterId +
               "&orderGoodsId=" +
-              this.orderGoodsId,
+              this.orderGoodsId +
+              "&types=1",
           });
           this.studyLog()
           //没有答题次数限制
@@ -471,7 +475,8 @@ export default {
               "&chapterId=" +
               chapterId +
               "&orderGoodsId=" +
-              this.orderGoodsId,
+              this.orderGoodsId +
+              "&types=1",
           });
           this.studyLog()
         } else {
@@ -501,11 +506,11 @@ export default {
       });
     },
     async openChapter(item) {
-      console.log('---zhang',this.menuItem, this.down,this.list, item.id, item.courseId, item.moduleId);
+      // console.log('---zhang',this.menuItem, this.down,this.list, item.id, item.courseId, item.moduleId);
       this.down = !this.down;
       if (!this.down && this.list.length == 0) {
-        console.log(item.id, 69);
-        //获取所有节试卷列表
+        // console.log(item.id, 69);
+        //获取章下面所有节试卷列表
         await this.$api.reSectionExamList({
           chapterId: item.chapterId || item.menuId,
           courseId: item.courseId,
@@ -545,7 +550,6 @@ export default {
         });
     },
     getSectionList(chapterId) {
-      console.log('=============2', 'chapterId:', chapterId)
       let self = this;
     //   url: '/app/common/course/sectionList/'+data,
       this.$api.sectionList(chapterId).then((res) => {
@@ -562,11 +566,9 @@ export default {
           }
 
           let newArr = res.data.data.filter((item) => {
-            console.log(item);
             return item.type != 2;
           });
           this.canLearn = newArr.every((item) => {
-            console.log(item);
             if (item.learning == 1) {
               return true;
             } else {
@@ -574,12 +576,12 @@ export default {
             }
           });
           self.list = res.data.data;
-          console.log('=============2', self.list)
+          // console.log('=============2', self.list)
         }
       });
     },
     getReSectionList(chapterId, courseId, moduleId) {
-      console.log('=============3', 'chapterId:', chapterId, 'courseId:', courseId, 'moduleId:', moduleId)
+      // console.log('=============3', 'chapterId:', chapterId, 'courseId:', courseId, 'moduleId:', moduleId)
       let self = this;
       this.$api
         .reSectionList({
@@ -602,11 +604,9 @@ export default {
               }
             }
             let newArr = res.data.data.filter((item) => {
-              console.log(item);
               return item.type != 2;
             });
             this.canLearn = newArr.every((item) => {
-              console.log(item);
               if (item.learning == 1) {
                 return true;
               } else {
@@ -614,12 +614,11 @@ export default {
               }
             });
             self.list = res.data.data;
-            console.log('=============3', self.list)
           }
         });
     },
     getBuySectionList(chapterId, courseId, moduleId) {
-      console.log('=============1', 'chapterId:', chapterId, 'courseId:', courseId, 'moduleId:', moduleId)
+      // console.log('=============1', 'chapterId:', chapterId, 'courseId:', courseId, 'moduleId:', moduleId)
       let self = this;
       this.$api
         .reSectionList({
@@ -644,7 +643,6 @@ export default {
               return item.type != 2;
             });
             this.canLearn = newArr.every((item) => {
-              console.log(item);
               if (item.learning == 1) {
                 return true;
               } else {
@@ -652,7 +650,6 @@ export default {
               }
             });
             self.list = res.data.data;
-            console.log('=============1', self.list)
           }
         });
     },

+ 75 - 4
components/course/courseModule.vue

@@ -23,7 +23,7 @@
 					<view
 						class="examBox"
 						@click="
-						toDo(
+						toDoModuleExam(
 							itemM.typeId,
 							goodsId,
 							itemM.moduleId,
@@ -49,7 +49,7 @@
 							>
 							
 								<text v-if="itemM.learning == 1">合格</text>
-								<text v-else-if="itemM.learning == 0">不合格</text>
+								<text v-else>不合格</text>
 							</view>
 						</view>
 					</view>
@@ -112,7 +112,12 @@ export default {
 		},
 		sectionMaxNum:{
 			default:undefined
-		}
+		},
+		// 商品类型 1视频2题库 3补考 4前培 5虚拟赠送题库 6直播	
+		goodsType: {
+			type: [Number, String],
+			default: 0,
+		}, 
 	},
 	components: {
 		courseChapter
@@ -194,7 +199,32 @@ export default {
 				}
 			});
 		},
-	},computed: { ...mapGetters(['chapterOpen']) },
+		/**
+		 * 去做题
+		 */
+		async toDoModuleExam(id, goodsId = 0, moduleId = 0, chapterId = 0, item, index) {
+			uni.navigateTo({
+			url:
+				"/pages2/class/questionBank?courseId=" +
+				this.courseId +
+				"&gradeId=" +
+				this.gradeId +
+				"&isFromVideo=1&id=" +
+				id +
+				"&goodsid=" +
+				goodsId +
+				"&moduleId=" +
+				moduleId +
+				"&chapterId=" +
+				chapterId +
+				"&orderGoodsId=" +
+				this.orderGoodsId +
+				"&types=3",
+			})
+		},
+		
+	},
+	computed: { ...mapGetters(['chapterOpen']) },
 };
 </script>
 
@@ -221,4 +251,45 @@ export default {
 		height: 24rpx;
 	}
 }
+
+.examBox {
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+  .exam {
+		font-size: 30rpx;
+		display: flex;
+		align-items: center;
+		margin: 20rpx 0;
+	}
+	.eTag {
+		width: 56rpx;
+		height: 42rpx;
+		text-align: center;
+		line-height: 42rpx;
+		font-size: 20rpx;
+		background: #007aff;
+		border-radius: 8rpx;
+		color: #ffffff;
+	}
+}
+.tagRe {
+  width: 80rpx;
+  height: 28rpx;
+  background: #ff3b30;
+  border-radius: 8rpx;
+  font-size: 20rpx;
+  color: #ffffff;
+  text-align: center;
+}
+.tagGreen {
+  width: 80rpx;
+  height: 28rpx;
+  background: #34c759;
+  border-radius: 8rpx;
+  font-size: 20rpx;
+  color: #ffffff;
+  text-align: center;
+}
+
 </style>

+ 93 - 20
components/course/courseSection.vue

@@ -63,7 +63,7 @@
 				</view>
 			</template>
 
-			<view v-if="checkTest()">习题</view>
+			<view v-if="checkTest()" class="exercises" @click.stop="toDoSectionExam()">习题</view>
 			
 			
 		</view>
@@ -128,7 +128,7 @@ export default {
 			default:undefined,
 		},
 		// 章->所有节试卷列表
-		sectionExam: {
+		ChapterSectionExam: {
 			type: Array,
 			default: () => [],
 		},
@@ -150,15 +150,28 @@ export default {
 			playId:'',
 			clickLock:false, //点击锁,防止连续点击多次
 			moduleSectionExam: [], // 模块下的所有节试卷列表
+			chapterExams: {},
+			moduleExams: {},
 		};
 	},
 	onLoad() {
 	},
 	created() {
-		
+		if (this.testType == 3) {
+			// 模块下的所有节试卷列表
+			this.$api.reSectionExamList({
+				chapterId: 0,
+				courseId: this.courseId,
+				gradeId: this.gradeId
+			}).then((res) => {
+				if (res.data.code == 200) {
+					this.moduleSectionExam = res.data.data || []
+					console.log(this.moduleSectionExam, 'this.moduleSectionExam');
+				}
+			})
+		}
 	},
 	mounted() {
-		console.log('testType', this.testType)
 		this.nowTime = Number(new  Date().getTime()/1000).toFixed(0)
 		this.newId= this.menuItem.sectionId>0?this.menuItem.sectionId:this.menuItem.menuId
 		// console.log(this.newId,'this.newId', this.playNextId)
@@ -171,7 +184,7 @@ export default {
 		let sectionId = this.menuItem.sectionId || this.menuItem.menuId;
 		let playNextId = `moduleId${moduleId}chapterId${chapterId}sectionId${sectionId}${this.isRebuild?'isRebuild':''}`;
 		this.playId = playNextId;
-		console.log('this.playId:', this.playId)
+		// console.log('this.playId:', this.playId)
 		uni.$off('playNext'+playNextId) //绑定前先移除之前的事件
 		uni.$once('playNext'+playNextId, (data) => {
 			//到时会触发每个节的监听事件,只允许当前节的接收
@@ -222,30 +235,82 @@ export default {
 				let sectionASame = this.liveLast.sectionId == (this.menuItem.sectionId || this.menuItem.menuId)
 				let chapterSame = this.liveLast.chapterId == (this.menuItem.chapterId || 0)
 				let moduleSame = this.liveLast.moduleId == (this.menuItem.moduleId || 0);
-				console.log(sectionASame && chapterSame && moduleSame,'sectionASame && chapterSame && moduleSame')
+				// console.log(sectionASame && chapterSame && moduleSame,'sectionASame && chapterSame && moduleSame')
 				return sectionASame && chapterSame && moduleSame
 			} else {
 				return false;
 			}
 			
 		},
+		toDoSectionExam() {
+			this.$emit('togoBack', 1)
+		},
 		checkTest() {
-			console.log(this.menuItem)
-			if (!this.sectionExam.length) {
-				return false
-			}
-			if (this.sectionExam.some((e) => e.sectionId == this.menuItem.sectionId)) {
-				return true
-			} else {
+			let data = this.testType == 3 ? this.moduleSectionExam : this.ChapterSectionExam
+			// console.log('data:',this.testType, data, this.moduleSectionExam, this.ChapterSectionExam)
+			let id = this.testType == 3 ? this.menuItem.menuId : this.menuItem.sectionId
+			if (!data) {
 				return false
 			}
+			return data.some((e) => e.sectionId == id)
 		},
 		ChapterExam() {
-			let item = this.sectionExam.find((e) => e.sectionId == this.menuItem.sectionId)
-			console.log('item', item)
+			this.chapterExams = this.ChapterSectionExam.find((e) => e.sectionId == this.menuItem.sectionId)
+			console.log('item', this.chapterExams)
+			let moduleId = this.chapterExams.moduleId || 0
+			let chapterId = this.chapterExams.chapterId || 0
+			let sectionId = this.chapterExams.sectionId || this.chapterExams.menuId
+			uni.navigateTo({
+              url:
+                "/pages2/class/questionBank?courseId=" +
+                this.courseId +
+                "&gradeId=" +
+                this.gradeId +
+                "&isFromVideo=1&id=" +
+                this.chapterExams.typeId +
+                "&goodsid=" +
+                this.goodsId +
+                "&moduleId=" +
+                moduleId +
+                "&chapterId=" +
+                chapterId +
+				"&sectionId=" +
+                sectionId +
+                "&orderGoodsId=" +
+                this.orderGoodsId +
+				"&types=2"
+                ,
+            });
 		},
 		ModuleExam() {
+			let sectionId = this.menuItem.sectionId || this.menuItem.menuId
+			console.log('this.moduleSectionExam: ', this.moduleSectionExam, sectionId)
+			this.moduleExams = this.moduleSectionExam.find((e) => e.sectionId == sectionId)
+			console.log('item--', this.moduleExams)
+			let moduleId = this.moduleExams.moduleId || 0
+			let chapterId = this.moduleExams.chapterId || 0
 			
+			uni.navigateTo({
+              url:
+                "/pages2/class/questionBank?courseId=" +
+                this.courseId +
+                "&gradeId=" +
+                this.gradeId +
+                "&isFromVideo=1&id=" +
+                this.moduleExams.typeId +
+                "&goodsid=" +
+                this.goodsId +
+                "&moduleId=" +
+                moduleId +
+                "&chapterId=" +
+                chapterId +
+				"&sectionId=" +
+                sectionId +
+                "&orderGoodsId=" +
+                this.orderGoodsId +
+				"&types=2"
+                ,
+            });
 		},
 		studyRecordMenuAllList() {
 			return new Promise(resolve => {
@@ -287,9 +352,7 @@ export default {
 			})
 		},
 		async getVideo(){
-			console.log('---点击节', )
-			this.$emit('togoBack', 1)
-			return
+			
 			if(this.clickLock) {
 				return;
 			}
@@ -487,8 +550,8 @@ export default {
 				let learnNum = await this.goodsTodayStudySectionNum()
 				let hasLearn = await this.gradeCheckGoodsStudy();
 				
-				console.log(this.sectionMaxNum,'this.sectionMaxNum')
-				console.log(learnNum,'learnNum')
+				// console.log(this.sectionMaxNum,'this.sectionMaxNum')
+				// console.log(learnNum,'learnNum')
 				if(this.sectionMaxNum > 0 && !this.isLive) {
 					if(learnNum >= this.sectionMaxNum && !hasLearn) {
 						uni.showToast({
@@ -709,4 +772,14 @@ export default {
 		font-size: 20rpx;
 		padding: 5rpx;
 	}
+	.exercises {
+		width: 56rpx;
+		height: 38rpx;
+		text-align: center;
+		line-height: 38rpx;
+		font-size: 20rpx;
+		background: #007aff;
+		border-radius: 8rpx;
+		color: #ffffff;
+	}
 </style>

+ 12 - 0
pages2/class/questionBank.vue

@@ -843,6 +843,7 @@ export default {
       lastCount: 0, //剩余没有回答的题目数
       chapterId: 0,
       moduleId: 0,
+      sectionId: 0,
       showArrow: false, //退出提示
       isFromVideo: "",
       gradeId: "",
@@ -855,13 +856,16 @@ export default {
       orderGoodsId: 0,
       isTaking: true, //是否正在拍照
       needPhoto: false, //是否需要拍照
+      examType: 0, // 3-模块,1-章,2-节
     };
   },
   async onLoad(option) {
+    this.examType = option.types
     this.id = option.id;
     this.goodsId = option.goodsid;
     this.chapterId = option.chapterId;
     this.courseId = option.courseId;
+    this.sectionId = option.sectionId
     this.moduleId = option.moduleId;
     this.isFromVideo = option.isFromVideo || "";
     this.gradeId = option.gradeId || "";
@@ -1458,6 +1462,7 @@ export default {
         .bankRecordEdit({
           chapterId: this.chapterId || 0,
           moduleId: this.moduleId || 0,
+          sectionId: this.sectionId || 0,
           examId: this.id,
           goodsId: this.goodsId,
           orderGoodsId: this.orderGoodsId,
@@ -1471,6 +1476,7 @@ export default {
           gradeId: this.gradeId,
           performance: score,
           totalScore: allScore,
+          type: this.examType,
           // examTime: parseInt(this.allTimes),
           // doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
           // historyExamJson: JSON.stringify(this.questionList)
@@ -1586,6 +1592,7 @@ export default {
           .bankRecordEdit({
             chapterId: this.chapterId || 0,
             moduleId: this.moduleId || 0,
+            sectionId: this.sectionId || 0,
             gradeId: this.gradeId,
             examId: this.id,
             courseId: this.courseId,
@@ -1596,6 +1603,7 @@ export default {
             performance: score,
             reportStatus: reportStatus,
             status: 1,
+            type: this.examType,
             // historyExamJson: JSON.stringify(this.questionList)
           })
           .then((res) => {});
@@ -1795,12 +1803,14 @@ export default {
             courseId: this.courseId,
             chapterExamId: this.chapterId || 0,
             moduleExamId: this.moduleId || 0,
+            sectionId: this.sectionId || 0,
             examId: this.id,
             goodsId: this.goodsId,
             orderGoodsId: this.orderGoodsId,
             gradeId: this.gradeId,
             totalQuestionNum: questionList,
             allQuestionNum: this.questionList.length,
+            type: this.examType,
           })
           .then((res) => {
             this.recordId = res.data.data;
@@ -2195,6 +2205,7 @@ export default {
         .bankRecordEdit({
           moduleId: this.moduleId || 0,
           chapterId: this.chapterId || 0,
+          sectionId: this.sectionId || 0,
           gradeId: this.gradeId,
           examId: this.id,
           goodsId: this.goodsId,
@@ -2209,6 +2220,7 @@ export default {
           // 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)

+ 5 - 1
pages3/polyv/detail.vue

@@ -148,6 +148,7 @@
                 :isBuy="true"
                 :menuItem="item"
                 :levelId="item.menuId"
+                :goodsType='1'
               ></courseModule
             ></view>
             <!--章 -->
@@ -185,6 +186,7 @@
                 :isBuy="true"
                 :menuItem="item"
                 :levelId="'0-0-' + item.menuId"
+                :goodsType='1'
                 :testType="3"
                 @togoBack="togoBack($event)"
               ></courseSection
@@ -766,8 +768,10 @@ export default {
   },
   methods: {
     ...mapMutations(["updateChapterOpen","updateLiveLast"]),
+    // 调用节的方法
     togoBack(value) {
-      console.log('模块的节', value , this.$refs.MoudleSection)
+      // console.log('模块的节', value , this.$refs.MoudleSection)
+      this.$refs.MoudleSection[0].ModuleExam()
     },
     // 新增微信公众号模板消息点击数据
     clickOfficial() {