ソースを参照

plbCourse提交

SanHQin 10 ヶ月 前
コミット
46cf5a31b5

+ 1 - 1
src/components/pages/pblCourse/component/doWorkArea.vue

@@ -11,7 +11,7 @@
 			</div>
 		</div>
 		<div class="dw_work">
-			<work :task="task" @submitTask="submitTask" @choiceAnswer="choiceAnswer" @getTaskList="getTaskList" :phase="phase"/>
+			<work :task="task" @submitTask="down" @choiceAnswer="choiceAnswer" @getTaskList="getTaskList" :phase="phase"/>
 		</div>
 		<div class="dw_bottom">
 			<div class="dw_b_btn" @click.stop="submitTask()">

+ 41 - 8
src/components/pages/pblCourse/component/work.vue

@@ -25,15 +25,16 @@
 					<span>通关挑战({{taskIndex+1}}/{{task.answerArray?task.answerArray.length:5}})</span>
 				</div>
 				<div class="w_dw_h_controls">
-					<span @click.stop="back()">上一题</span>
-					<span @click.stop="down()">下一题</span>
+					<span @click.stop="back()" :class="[taskIndex==0?'w_dw_h_c_disabled':'']">上一题</span>
+					<span @click.stop="down()" v-show="taskIndex!=4">下一题</span>
+					<span @click.stop="submitTask()" class="w_dw_h_c_submit" v-show="taskIndex==4">提交</span>
 				</div>
 			</div>
 			<div class="w_dw_work">
-					<span class="w_dw_w_title">{{ taskIndex+1 }}.{{ task.answerArray[taskIndex].title }}</span>
+					<span class="w_dw_w_title">{{ taskIndex+1 }}.{{ task.answerArray?task.answerArray[taskIndex].title:"" }}</span>
 					<div class="w_dw_w_radio">
 						<el-radio-group class="w_dw_w_r_group" v-model="task.answerArray[taskIndex].userAnswer" size="medium" @input="choiceAnswer">
-  					  <el-radio class="w_dw_w_r_g_item" v-for="(item,index) in task.answerArray[taskIndex].option" :key="index+''+taskIndex" size="medium " :label="index" @input="choiceAnswer">{{ item }}</el-radio>
+  					  <el-radio class="w_dw_w_r_g_item" v-for="(item,index) in task.answerArray?task.answerArray[taskIndex].option:[]" :key="index+''+taskIndex" size="medium " :label="index" @input="choiceAnswer">{{ item }}</el-radio>
   					</el-radio-group>
 					</div>
 				</div>
@@ -50,7 +51,9 @@
 				type:Object,
 				default:()=>{
 					return{
-						
+						answerArray:[
+							{}
+						]
 					}
 				},
 				
@@ -70,11 +73,15 @@
 			return{
 				taskIndex:0,
 			}
+		},
+		computed:{
+
 		},
 		watch:{
 			task(){
 				this.taskIndex = 0;
-				this.$refs.workRef.scrollTop = 0;
+				this.$refs.workRef?this.$refs.workRef.scrollTop = 0:'';
+				// this.$refs.workRef.scrollTop = 0;
 			}
 		},
 		methods:{
@@ -82,16 +89,20 @@
 				this.$emit("getTaskList",this.phase.atPhase)
 			},
 			back(){
-				if(this.taskIndex==0)return this.$message.info("已经是第一题咯");
+				if(this.taskIndex==0)return;
 				this.taskIndex-=1;
 			},
 			down(){
-				if(this.taskIndex>=(this.task?this.task.answerArray.length-1:5))return this.$message.info("已经是最后一题咯");
+				if(this.taskIndex>=(this.task?this.task.answerArray.length-1:5))return;
 				this.taskIndex+=1;
 			},
 			choiceAnswer(_index){
 				this.$emit("choiceAnswer",[this.taskIndex,_index])
 				this.$forceUpdate();
+			},
+			submitTask(){
+				if((this.phase.doPhase>this.phase.atPhase) || this.phase.doPhase>=5)return this.$message.error("该阶段已提交过了")
+				this.$emit("submitTask")
 			}
 		}
 	}
@@ -236,6 +247,23 @@
 	align-items: center;
 }
 
+.w_dw_h_c_disabled{
+	opacity: .5;
+	cursor: not-allowed !important;
+}
+
+.w_dw_h_c_submit{
+	background:linear-gradient(to right,#6082E5,#A293F3);
+	color: white;
+	padding: 0 23px !important;
+	/* 不可选中 */
+	-webkit-user-select: none;
+	-moz-user-select: none;
+	-ms-user-select: none;
+	user-select: none;
+}
+
+
 .w_dw_h_controls>span{
 	font-size: 16px;
 	margin-left: 20px;
@@ -250,6 +278,11 @@
 	align-items: center;
 	border-radius: 100px;
 	border: solid 1px #AD88FD;
+	/* 不可选中 */
+	-webkit-user-select: none;
+	-moz-user-select: none;
+	-ms-user-select: none;
+	user-select: none;
 }
 
 .w_dw_h_controls>span:hover{

+ 6 - 1
src/components/pages/pblCourse/index.vue

@@ -130,7 +130,9 @@ export default {
 			.post("https://gpt4.cocorobo.cn/chat", params)
 			.then((res) => {
 				let _data = res.data.FunctionResponse.choices[0];
-				const content = _data.message.content;
+				let content = _data.message.content;
+				content.replaceAll('```json','')
+				content.replaceAll('```','')
 				const _result = JSON.parse(content);
 				const md = new MarkdownIt();
 				_result.detail = _result.detail?md.render(_result.detail):"",
@@ -175,6 +177,9 @@ export default {
 			}else{
 				this.loading = false;
 				this.phase.doPhase++;
+				if(this.phase.doPhase==5){
+					return this.$message.error('所有阶段已经完成');
+				}
 				this.getTaskList(this.phase.doPhase)
 			}
 		}