SanHQin 10 months ago
parent
commit
facec23f68

+ 4 - 4
src/components/pages/pblCourse/component/chatArea.vue

@@ -55,9 +55,9 @@
 			<span class="c_controls_item" @click="clearChat">清空对话</span>
 		</div> -->
 		<div class="c_bottom" 	v-loading="chatLoading">
-			<div class="c_b_record">
+			<!-- <div class="c_b_record">
 				<span></span>
-			</div>
+			</div> -->
 			<div class="c_b_inputArea">
 				<el-input
 					class="c_b_input"
@@ -66,7 +66,7 @@
 				
 				>
 				</el-input>
-				<span></span>
+				<!-- <span></span> -->
 			</div>
 			<div class="c_b_send" @click="send">
 				<span></span>
@@ -482,7 +482,7 @@ export default {
 }
 
 .c_b_inputArea {
-	width: calc(100% - 140px);
+	width: calc(100% - 100px);
 	background-color: #f3f3f3;
 	border-radius: 50px;
 	height: 80%;

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

@@ -11,7 +11,10 @@
 			</div>
 		</div>
 		<div class="dw_work">
-			<work :task="task" @submitTask="down" @choiceAnswer="choiceAnswer" @getTaskList="getTaskList" :phase="phase"/>
+			<work v-if="task" :task="task" @submitTask="down" @choiceAnswer="choiceAnswer" @getTaskList="getTaskList" :phase="phase"/>
+			<div v-else>
+				<h3>等待生成数据...</h3>
+			</div>
 		</div>
 		<div class="dw_bottom">
 			<div class="dw_b_btn" @click.stop="submitTask()">

+ 75 - 0
src/components/pages/pblCourse/component/selectTopicDialog.vue

@@ -0,0 +1,75 @@
+<template>
+  <div>
+    <el-dialog
+      title="选题设置"
+      :visible.sync="dialogVisible"
+      width="500px"
+			:show-close="false"
+			:close-on-click-modal="false"
+			:close-on-press-escape="false"
+      v-loading="loading"
+    >
+      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
+        <el-form-item label="选题:" prop="title">
+          <el-input v-model="form.title"></el-input>
+        </el-form-item>
+			</el-form>
+      <span slot="footer" class="shareFooter">
+        <el-button type="primary" @click="submitFrom('form')">确定</el-button>
+      </span>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+export default {
+  data() {
+    return {
+      dialogVisible: false,
+      loading: false,
+      form: {
+        title:"",
+      },
+			rules:{
+				title:[
+					{ required: true, message: '请输入选题', trigger: 'blur' },
+				]
+			}
+    };
+  },
+  watch: {
+    
+  },
+  methods: {
+    open() {
+      this.dialogVisible = true;
+    },
+    close() {
+      this.dialogVisible = false;
+      this.form = {
+        title:""
+      };
+    },
+		submitFrom(formName){
+			this.$refs[formName].validate((valid) => {
+        if (valid) {
+          this.$emit("success",this.form);
+        } else {
+          console.log('error submit!!');
+          return false;
+        }
+      });
+		},
+
+  }
+};
+</script>
+
+<style scoped>
+.shareContent {
+  width: 500px;
+  max-width: 500px;
+  height: auto;
+}
+
+</style>

+ 15 - 6
src/components/pages/pblCourse/component/work.vue

@@ -12,10 +12,10 @@
 				</div>
 			</div>
 			<div class="w_nw_introduce">
-				<div v-html="task.target" style="font-weight: bold;"></div>
-				<div v-html="task.detail"></div>
-				<div v-html="task.steps"></div>
-				<div v-html="task.tips"></div>
+				<div v-html="htmlText(task.target)" style="font-weight: bold;"></div>
+				<div v-html="htmlText(task.detail)"></div>
+				<div v-html="htmlText(task.steps)"></div>
+				<div v-html="htmlText(task.tips)"></div>
 			</div>
 		</div>
 		<div class="w_doWork">
@@ -43,7 +43,7 @@
 </template>
 
 <script>
-	
+	import MarkdownIt from "markdown-it";
 	export default {
 		emits:['choiceAnswer','submitTask',"getTaskList"],
 		props:{
@@ -72,10 +72,19 @@
 		data(){
 			return{
 				taskIndex:0,
+				detail:"",
+				steps:"",
+				target:"",
+				tips:"",
 			}
 		},
 		computed:{
-
+			htmlText(){
+				return (mdText)=>{
+					const md = new MarkdownIt();
+					return md.render(mdText)
+				}
+			}
 		},
 		watch:{
 			task(){

+ 88 - 65
src/components/pages/pblCourse/index.vue

@@ -11,6 +11,7 @@
 		<div class="pc_right">
 			<chatArea />
 		</div>
+		<selectTopicDialog ref="selectTopicDialogRef" @success="selectTopicSuccess"/>
 	</div>
 </template>
 
@@ -19,12 +20,13 @@ import chatArea from './component/chatArea'
 import doWorkArea from './component/doWorkArea'
 import procedureArea from './component/procedureArea'
 import { v4 as uuidv4 } from "uuid";
-import MarkdownIt from "markdown-it";
+import selectTopicDialog from './component/selectTopicDialog'
 export default {
 	components: {
 		chatArea,
 		doWorkArea,
 		procedureArea,
+		selectTopicDialog,
 	},
 	data() {
 		return {
@@ -33,6 +35,7 @@ export default {
 				doPhase:0,
 				atPhase:0,
 			},
+			selectTopic:"",
 			taskList:[]
 		};
 	},
@@ -46,68 +49,70 @@ export default {
 			this.loading = true;
 		const _uuid = uuidv4()
 		const _msg = `
-			NOTICE
-			Role: 作为学生的学习指导Agent,你熟悉熟悉PBL(基于问题的学习)和5EX教学模型,能够根据学生的学情数据(当前的学习任务设计、学习表现数据、作业数据等)生成自适应的学习任务和对应的5道考核题目。
-			Language: Please use the same language as the user requirement, if the user speaks Chinese, the specific text of your answer should also be in Chinese.
-			ATTENTION: Use '##' to SPLIT SECTIONS, not '#'. Output format carefully referenced "Format example".
-			Instruction: Based on the context, follow "Format example", write content.
+NOTICE
+Role: 作为学生的学习指导Agent,你熟悉熟悉PBL(基于问题的学习)和5EX教学模型,能够根据学生的学情数据(当前的学习任务设计、学习表现数据、作业数据等)生成自适应的学习任务和对应的5道考核题目。
+Language: Please use the same language as the user requirement, if the user speaks Chinese, the specific text of your answer should also be in Chinese.
+ATTENTION: Use '##' to SPLIT SECTIONS, not '#'. Output format carefully referenced "Format example".
+Instruction: Based on the context, follow "Format example", write content.
 
-			# Context
-			## 语气
-			你的语气应该是亲切地,有趣的,循循善诱的一个老师
+# Context
+## 语气
+你的语气应该是亲切地,有趣的,循循善诱的一个老师
 
-			## 工具能力
-			1. 5E教学模型应用:
-			你需要熟悉并应用5E教学模型(即引入、探索、解释、扩展和评估)于学习任务的设计中,确保学习过程的有效性和吸引力。5E教学模型是一种以学生为中心的教学方法,旨在通过五个阶段(Engage, Explore, Explain, Elaborate, Evaluate)来促进学生的学习和理解。
-			Engage(引入):在这个阶段,教师通过引人入胜的活动或问题来激发学生的兴趣和好奇心,帮助他们建立与新知识的联系。
-			Explore(探索):学生通过动手实验或调查活动来探索新概念,培养他们的探究能力和批判性思维。
-			Explain(解释):学生在这个阶段分享他们的发现,教师提供进一步的解释和指导,帮助学生理解新概念。
-			Elaborate(拓展):学生通过应用新知识来解决更复杂的问题,进一步深化他们的理解。
-			Evaluate(评估):教师和学生共同评估学习效果,反思学习过程,确定需要改进的地方。
-			2. 学生表现与选择的感知:
-			    通过与学生互动,实时感知学生的学习表现和选择,理解他们的学习需求和难点。
-			3. 自适应任务生成:
-			    基于学生的反馈和选择,自动生成个性化的学习任务,任务难度和类型随学生的表现和需求而变化。
+## 工具能力
+1. 5E教学模型应用:
+你需要熟悉并应用5E教学模型(即引入、探索、解释、扩展和评估)于学习任务的设计中,确保学习过程的有效性和吸引力。5E教学模型是一种以学生为中心的教学方法,旨在通过五个阶段(Engage, Explore, Explain, Elaborate, Evaluate)来促进学生的学习和理解。
+Engage(引入):在这个阶段,教师通过引人入胜的活动或问题来激发学生的兴趣和好奇心,帮助他们建立与新知识的联系。
+Explore(探索):学生通过动手实验或调查活动来探索新概念,培养他们的探究能力和批判性思维。
+Explain(解释):学生在这个阶段分享他们的发现,教师提供进一步的解释和指导,帮助学生理解新概念。
+Elaborate(拓展):学生通过应用新知识来解决更复杂的问题,进一步深化他们的理解。
+Evaluate(评估):教师和学生共同评估学习效果,反思学习过程,确定需要改进的地方。
+2. 学生表现与选择的感知:
+通过与学生互动,实时感知学生的学习表现和选择,理解他们的学习需求和难点。
+3. 自适应任务生成:
+基于学生的反馈和选择,自动生成个性化的学习任务,任务难度和类型随学生的表现和需求而变化。
 
-			## 工作流程
-			1. 判断学生当前处在5E模型中哪一个学习阶段。如果未提供学情数据,或无法判断学生当前处在5E教学模型中的哪一个解释,则默认处在第一个阶段(引入)阶段。请随机选择一个适合小学五年级学生的科学学习主题,并生成相应的符合引入阶段的学习任务。
-			2. 结合学生当前的学情数据,生成紧随其后的下一个阶段的学习任务,但是仅仅生成紧随其后的下一个阶段的学习任务。你需要沿着这个顺序判断:引入阶段→探索阶段→解释阶段→拓展阶段→评估阶段。比如,当你判断学情数据中,学生目前已经完成了引入阶段的学习,那么你需要提供探索阶段的学习任务。
-			3. 生成上一步中学习任务对应的5道考核选择题
+## 工作流程
+1. 判断学生当前处在5E模型中哪一个学习阶段。如果未提供学情数据,或无法判断学生当前处在5E教学模型中的哪一个解释,则默认处在第一个阶段(引入)阶段。请随机选择一个适合小学五年级学生的科学学习主题,并生成相应的符合引入阶段的学习任务。
+2. 结合学生当前的学情数据,生成紧随其后的下一个阶段的学习任务,但是仅仅生成紧随其后的下一个阶段的学习任务。你需要沿着这个顺序判断:引入阶段→探索阶段→解释阶段→拓展阶段→评估阶段。比如,当你判断学情数据中,学生目前已经完成了引入阶段的学习,那么你需要提供探索阶段的学习任务。
+3. 生成上一步中学习任务对应的5道考核选择题
 
-			## 限制
-			1. 请仅仅生成某一个阶段对应的学习任务。不要同时给出多个阶段、多个学习任务。
-			2. 请严格按照以下格式要求输出内容,请仅仅告知相应的5E阶段名称和对应的任务描述,不需要包含学情数据等与【任务】无关的内容。
-			3. 生成相应的考核题目,仅限单选题
-			4. 任务描述的格式以markdown方式输出
-			${
-				this.phase.doPhase==0?'':`
-				## 学情数据
-				这是你生成适应性学习任务时,需要参考的前置学情数据${JSON.stringify(this.taskList[this.phase.doPhase])}(当前的学习任务设计、学习表现数据、作业数据等)。`
-			}
+## 限制
+1. 请仅仅生成某一个阶段对应的学习任务。不要同时给出多个阶段、多个学习任务。
+2. 请严格按照以下格式要求输出内容,请仅仅告知相应的5E阶段名称和对应的任务描述,不需要包含学情数据等与【任务】无关的内容。
+3. 生成相应的考核题目,仅限单选题
+4. 任务描述的格式以markdown方式输出
+
+## 学情数据
+选题:${this.selectTopic}
+${this.phase.doPhase==0?'':`这是你生成适应性学习任务时,需要参考的前置学情数据${JSON.stringify(this.taskList[this.phase.doPhase-1])}(当前的学习任务设计、学习表现数据、作业数据等)。`}
 
-			# Format example
-			{
-			    "name": "任务名字",
-			    "detail": "任务描述(要求markdown的格式)",
-			    "target":"任务目标",
-			    "steps":"任务步骤",
-			    "tips":"任务提示",
-			    "answerArray":[
-			      {
-			        title: "标题",
-			        type: "单选题",
-			        option: ["选项1","选项2","选项3","选项4"],
-			        answer: "答案(最好是index)"
-			      },
-			      {
-			        title: "标题",
-			        type: "单选题",
-			        option: ["选项1","选项2","选项3","选项4"],
-			        answer: "答案(最好是index)"
-			      }
-			    ]
-			}`
+# Format example
+{
+"name": "任务名字",
+"detail": "任务描述(要求markdown的格式)",
+"target":"任务目标",
+"steps":"任务步骤",
+"tips":"任务提示",
+"answerArray":[
+{
+	"title": "标题",
+	"type": "单选题",
+	"option": ["选项1","选项2","选项3","选项4"],
+	"answer": "答案(最好是index)"
+},
+{
+	"title": "标题",
+	"type": "单选题",
+	"option": ["选项1","选项2","选项3","选项4"],
+	"answer": "答案(最好是index)"
+}
+]
+}
 
+Instruction: Based on the context, follow "Format example", write content.
+`
+			console.log(_msg)
 			// ${
 			// 	this.phase.doPhase==0?'':`
 			// 	## 学情数据
@@ -131,14 +136,15 @@ export default {
 			.then((res) => {
 				let _data = res.data.FunctionResponse.choices[0];
 				let content = _data.message.content;
-				content.replaceAll('```json','')
-				content.replaceAll('```','')
+				console.log(content)
+				content = content.replaceAll('```json','').replaceAll('```','')
+				// console.log(content)
 				const _result = JSON.parse(content);
-				const md = new MarkdownIt();
-				_result.detail = _result.detail?md.render(_result.detail):"",
-				_result.steps = _result.steps?md.render(_result.steps):"",
-				_result.target = _result.target?md.render(_result.target):"",
-				_result.tips =_result.tips?md.render(_result.tips):""
+				
+				_result.detail = _result.detail?_result.detail:"",
+				_result.steps = _result.steps?_result.steps:"",
+				_result.target = _result.target?_result.target:"",
+				_result.tips =_result.tips?_result.tips:""
 				this.taskList[phase] = _result;
 				// this.phase.doPhase = phase;
 				this.phase.atPhase = phase;
@@ -149,6 +155,9 @@ export default {
 			.catch((e) => {
 				this.loading = false;
 				this.$message.error("获取任务失败")
+				if(this.phase.doPhase!=0){
+					this.phase.doPhase--;
+				}
 				resolve();
 				console.log(e);
 			});
@@ -182,10 +191,24 @@ export default {
 				}
 				this.getTaskList(this.phase.doPhase)
 			}
+		},
+		selectTopicSuccess(_form){
+			if(_form.title){
+					this.phase = {
+					doPhase:0,
+					atPhase:0,
+				}
+				this.selectTopic = _form.title;
+				this.getTaskList()
+				this.$refs.selectTopicDialogRef.close();
+			}
 		}
 	},
 	mounted() {
-		this.getTaskList()
+		
+		this.selectTopic = "";
+		this.$refs.selectTopicDialogRef.open();
+		// this.getTaskList()
 	},
 };
 </script>