Spaces:
Sleeping
Sleeping
Upload 8 files
Browse files- pages/example.py +5 -0
- pages/example2.py +5 -0
- pages/generated_page.py +123 -0
- pages/step2.py +538 -0
- pages/step3.py +181 -0
- pages/step3_result2.py +17 -0
- pages/step3_result3.py +19 -0
- pages/step3_result4.py +62 -0
pages/example.py
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from st_pages import Page, Section, show_pages, add_indentation
|
3 |
+
|
4 |
+
add_indentation()
|
5 |
+
st.write("An example lesson 1");
|
pages/example2.py
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from st_pages import Page, Section, show_pages, add_indentation
|
3 |
+
|
4 |
+
add_indentation()
|
5 |
+
st.write("An example lesson 2");
|
pages/generated_page.py
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import streamlit as st
|
3 |
+
|
4 |
+
def main():
|
5 |
+
st.title("Generated Courses")
|
6 |
+
|
7 |
+
st.write("Course 1:")
|
8 |
+
st.write("""Course Title: Mastering Effective Feedback
|
9 |
+
|
10 |
+
Description: Have you ever been in an online tutoring session where your students seem disengaged or confused, and you want to enhance their learning experience? In this module, we will introduce effective feedback techniques as a way of tutoring students in an online session more effectively, ensuring they understand and apply the concepts being taught.
|
11 |
+
|
12 |
+
Learning Objectives:
|
13 |
+
Objective 1: Understand the principles and importance of providing effective feedback in online tutoring sessions to enhance student engagement and comprehension.
|
14 |
+
|
15 |
+
Objective 2: Create tailored feedback strategies that address individual student needs and improve learning outcomes by the end of this module.""")
|
16 |
+
|
17 |
+
st.write("Course 2:")
|
18 |
+
st.write("""**Course Title: Mastering Online Tutoring: Effective Teaching Strategies for Novice Tutors**
|
19 |
+
|
20 |
+
**Scenario 1: Creating an Engaging Learning Environment**
|
21 |
+
|
22 |
+
**Scenario Context:**
|
23 |
+
While tutoring online, the tutor encounters a challenge with a student named Alex, who seems disengaged during sessions. Alex often looks away from the screen and provides short, non-committal responses. The tutor needs to find a way to motivate and engage Alex effectively.
|
24 |
+
|
25 |
+
**Questions:**
|
26 |
+
|
27 |
+
1. **Constructed-response Open-Ended Question (Motivation):**
|
28 |
+
* **Question:** How would you address Alex's apparent lack of engagement during online tutoring sessions? Propose your initial response or solution to improve Alex's motivation.
|
29 |
+
* **Purpose:** Initial reaction, free expression.
|
30 |
+
* **Reason:** Encourages creative thinking and reflection.
|
31 |
+
|
32 |
+
2. **Selected-response Question (Assessment of Understanding):**
|
33 |
+
* **Question:** Choose the most effective tutor response to engage Alex in the session.
|
34 |
+
* **Options:**
|
35 |
+
* A. "Alex, I noticed you seem distracted. Let's take a quick break and come back refreshed."
|
36 |
+
* B. "You need to focus more, Alex. Let's get back to the topic."
|
37 |
+
* C. "Alex, can you share what interests you about this topic? Let's connect it to your interests."
|
38 |
+
* D. "If you don't want to participate, we can end the session early."
|
39 |
+
* **Correct Answer:** C. "Alex, can you share what interests you about this topic? Let's connect it to your interests."
|
40 |
+
* **Explanation:** Option C aligns with research on motivating students by connecting learning to their interests, making the content relevant and engaging. Options A and D do not address the root cause of disengagement, and B may come off as dismissive or confrontational.
|
41 |
+
|
42 |
+
3. **Constructed-response Open-Ended Question (Justification):**
|
43 |
+
* **Question:** Explain why you chose the specific option in the previous question. What reasoning supports your selection?
|
44 |
+
* **Purpose:** Encourage deep reasoning and reflection to reinforce the tutor's understanding and justification.
|
45 |
+
* **Reason:** Ensures participants can justify their choices and demonstrate a solid grasp of effective teaching strategies related to the scenario.
|
46 |
+
|
47 |
+
4. **Selected-response Question (Assessment of Understanding):**
|
48 |
+
* **Question:** Select the principle that best supports your chosen response to engage Alex effectively.
|
49 |
+
* **Options:**
|
50 |
+
* A. Building a personal connection enhances student engagement.
|
51 |
+
* B. Strict discipline is essential for maintaining focus.
|
52 |
+
* C. Immediate rewards increase student participation.
|
53 |
+
* D. Minimizing student involvement reduces distractions.
|
54 |
+
* **Correct Answer:** A. Building a personal connection enhances student engagement.
|
55 |
+
* **Explanation:** Building a personal connection aligns with the research recommendation to engage students by relating the material to their personal interests, fostering a more engaging and motivating learning environment.""")
|
56 |
+
|
57 |
+
st.write("Course 3:")
|
58 |
+
st.write("""Course Title: Mastering Online Tutoring: Techniques for Effective Student Engagement
|
59 |
+
|
60 |
+
Scenario 2:
|
61 |
+
|
62 |
+
Scenario Context: During an online tutoring session, the tutor encounters a new student named Jamie. Jamie seems hesitant to participate actively in discussions. The tutor notices that Jamie often waits for explicit instructions before attempting any problem-solving task, which seems to slow down the learning process.
|
63 |
+
|
64 |
+
Questions:
|
65 |
+
|
66 |
+
1. Constructed-response Open-Ended Question (Motivation):
|
67 |
+
- Question: How would you encourage Jamie to become more proactive in engaging with the material during your online sessions?
|
68 |
+
- Purpose: Initial reaction, free expression.
|
69 |
+
- Reason: Encourages creative thinking and reflection.
|
70 |
+
|
71 |
+
2. Selected-response Question (Assessment of Understanding):
|
72 |
+
- Question: Which of the following tutor responses would most effectively encourage Jamie to engage more actively in the learning process?
|
73 |
+
- Options:
|
74 |
+
* A. "Jamie, you should try to solve the problems on your own first, without waiting for me."
|
75 |
+
* B. "Let's work together on the next problem. Tell me what you think the first step should be."
|
76 |
+
* C. "It's fine if you don't want to participate actively. Just let me know when you're ready."
|
77 |
+
* D. "I'll give you all the instructions you need, just follow them one by one."
|
78 |
+
- Correct Answer: B. "Let's work together on the next problem. Tell me what you think the first step should be."
|
79 |
+
- Explanation: Option B aligns with the research by encouraging active participation and collaborative problem solving. Option A might be too abrupt, while C and D do not encourage proactive engagement.
|
80 |
+
|
81 |
+
3. Constructed-response Open-Ended Question (Justification):
|
82 |
+
- Question: Why did you choose the specific option in the previous question? Please detail your reasoning behind this selection.
|
83 |
+
- Purpose: Encourage deep reasoning and reflection to reinforce the tutor's understanding and justification.
|
84 |
+
- Reason: Ensures participants can justify their choices and demonstrate a solid grasp of effective teaching strategies related to the scenario.
|
85 |
+
|
86 |
+
4. Selected-response Question (Assessment of Understanding):
|
87 |
+
- Question: Which principle best supports the approach of encouraging Jamie to suggest the first step in problem-solving?
|
88 |
+
- Options:
|
89 |
+
* A. Students learn best through direct instruction and repetition.
|
90 |
+
* B. Active participation fosters deeper understanding and retention.
|
91 |
+
* C. Minimizing student autonomy leads to more efficient learning.
|
92 |
+
* D. Providing all necessary information upfront avoids confusion.
|
93 |
+
- Correct Answer: B. Active participation fosters deeper understanding and retention.
|
94 |
+
- Explanation: Option B is correct as it highlights the importance of engaging students actively, which is supported by research recommendations for effective teaching. Options A, C, and D do not align with fostering student engagement and independence.""")
|
95 |
+
|
96 |
+
st.write("Course 4:")
|
97 |
+
st.write("""Course Title: Effective Online Tutoring: Strategies for Novice Tutors
|
98 |
+
|
99 |
+
**Research Insights:**
|
100 |
+
|
101 |
+
**Research says...**
|
102 |
+
Research by Dr. Margaret Cargill and Patrick O��Connor (2013) emphasizes the importance of structuring educational content in a manner that aligns with the cognitive processes of learners. Their findings suggest that a well-structured introduction in teaching materials can significantly enhance students' understanding and retention of new concepts. By clearly defining the scope and objectives of a lesson, tutors can create a focused learning environment that aids in the comprehension of complex materials.
|
103 |
+
|
104 |
+
**Research says...**
|
105 |
+
Furthermore, the research highlights the significance of creating a knowledge gap to stimulate curiosity and engagement among students. By presenting information that students are likely unfamiliar with, tutors can foster an investigative learning atmosphere. This approach encourages students to actively participate in the learning process, seeking to fill the gaps in their knowledge through guided inquiry and exploration.
|
106 |
+
|
107 |
+
**Research says...**
|
108 |
+
In addition to structuring content, the study underscores the value of providing context to the subject matter being taught. By relating new information to known concepts, tutors can help students build connections that facilitate deeper learning. This contextualization not only aids in comprehension but also in the application of knowledge to real-world scenarios, thus enhancing the overall educational experience.
|
109 |
+
|
110 |
+
**Strategy Table:**
|
111 |
+
|
112 |
+
| Strategy | Description | Good Example | Bad Example |
|
113 |
+
|------------------------|-----------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------|
|
114 |
+
| Structured Introduction| Begin lessons with a clear introduction outlining objectives and scope. | "Today, we'll explore the fundamentals of algebra, focusing on solving equations. This will help us understand how to manipulate mathematical expressions." (Correct because it sets clear objectives and scope) | "Let's just dive into some math problems today without any specific focus." (Incorrect because it lacks clear objectives and structure) |
|
115 |
+
| Creating Knowledge Gaps| Introduce a topic by highlighting what is unknown or not yet covered. | "We've learned about photosynthesis, but how do plants adapt to low-light environments? Let's investigate this further." (Correct as it creates curiosity) | "Since you already know a lot about plants, let's just move on." (Incorrect because it assumes prior knowledge without creating curiosity) |
|
116 |
+
| Contextualization | Relate new information to familiar concepts to aid understanding. | "Just like how we use recipes to cook, we'll use formulas in chemistry to predict reactions." (Correct as it connects new info to known concepts) | "Chemistry is just a set of random reactions." (Incorrect because it doesn't relate new info to familiar concepts, making it harder to grasp) |
|
117 |
+
|
118 |
+
**References:**
|
119 |
+
|
120 |
+
- Cargill, M., & O'Connor, P. (2013). Writing Scientific Research Articles: Strategy and Steps. (Incomplete citation)""")
|
121 |
+
|
122 |
+
if __name__ == "__main__":
|
123 |
+
main()
|
pages/step2.py
ADDED
@@ -0,0 +1,538 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from langchain_community.vectorstores import Chroma
|
3 |
+
from langchain_community.embeddings import OpenAIEmbeddings
|
4 |
+
from langchain.prompts import PromptTemplate
|
5 |
+
from langchain.chains import RetrievalQA
|
6 |
+
from langchain.schema import Document
|
7 |
+
from langchain_openai import ChatOpenAI
|
8 |
+
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
9 |
+
from PyPDF2 import PdfReader
|
10 |
+
import shutil
|
11 |
+
import os
|
12 |
+
import time
|
13 |
+
import uuid
|
14 |
+
|
15 |
+
from streamlit_extras.switch_page_button import switch_page
|
16 |
+
from st_pages import Page, Section, show_pages, add_indentation
|
17 |
+
|
18 |
+
add_indentation()
|
19 |
+
|
20 |
+
# Define your prompt template
|
21 |
+
prompt_template = """
|
22 |
+
You are an expert course generator tasked with creating a comprehensive tutor training course for online tutors. Use the retrieved information to answer the question and follow the template the user gives you, but you should not refer to the template context. Please generate a course based on the research paper. The users of the course are novice tutors who are experts in the subjects they are teaching but unfamiliar with the best method of teaching what they know to the students. The course should have a course title and some practical examples (each scenario should have 4 questions) and some practical research recommendation examples for the tutor to show how they could perform in their classrooms.
|
23 |
+
|
24 |
+
For the contents you generated, please make sure the Flesch-Kincaid Score is below 10.
|
25 |
+
|
26 |
+
If you don't know the answer, just say "I don't know".
|
27 |
+
{context}
|
28 |
+
Question: {question}
|
29 |
+
"""
|
30 |
+
|
31 |
+
# Math Templates (for Mastery of Content)
|
32 |
+
template_1 = """
|
33 |
+
Do you know what math topic the paper is talking about? Can you generate a scenario-based tutor training course about how to teach the mathematic topic effectively as discussed in the retrieved research paper?
|
34 |
+
|
35 |
+
I need your help to generate the course title, description and learning objectives, please follow the below template.
|
36 |
+
|
37 |
+
Course Title: Generate a title of this math course using three words, the title should begin with a verb. It should be related to the specific math topic of the research paper and the course objective.
|
38 |
+
Example titles are: Using polite language, Managing inequity, Managing effective praise
|
39 |
+
|
40 |
+
Description: A short description about the purpose of this course and why. The structure could be similar to: Have you ever met a situation where you want to teach [the math topic] but you find yourself unable to explain the concept clearly to the students? In this module, we will be introducing [strategy name] as a way of tutoring students about [the math topic].
|
41 |
+
|
42 |
+
Learning Objectives:
|
43 |
+
You should generate based on the given learning objective here {learning_objective}
|
44 |
+
Requirement for generation: You should generate 2 learning objectives. The learning objectives should address the "understanding" and the "creating" level of Bloom's taxonomy.
|
45 |
+
Creating means use information to create something new, understanding means grasp meaning of instructional materials. You should generate two learning objectives.
|
46 |
+
|
47 |
+
Objective 1: Describe the expected outcome of this course.
|
48 |
+
Objective 2: Outline what learners will achieve by the end of this module regarding the second objective.
|
49 |
+
|
50 |
+
One of the objectives should clearly state the most effective strategy about teaching this math topic that is advocated in the retrieved research paper.
|
51 |
+
|
52 |
+
You don't need to generate the specific scenario at this time.
|
53 |
+
"""
|
54 |
+
|
55 |
+
template_2 = """
|
56 |
+
Can you generate the scenario-based math tutor training course's first scenario about the below course title and learning objective based on the retrieved research paper? Please follow the below template to generate the first scenario for the training course based on the title and the learning objective.
|
57 |
+
|
58 |
+
Please generate the math equation directly, rather than giving word in latex format like 'fraction'.
|
59 |
+
|
60 |
+
Background information:
|
61 |
+
|
62 |
+
{Course title + Description + Learning Objective generated}
|
63 |
+
|
64 |
+
You don't need to show the above information again in your output.
|
65 |
+
|
66 |
+
You need to generate below components:
|
67 |
+
|
68 |
+
Scenario Description:
|
69 |
+
|
70 |
+
Scenario 1: [The Initial Training Scenario describing a common challenge or issue a student is facing when a teacher is tutoring this math topic]
|
71 |
+
|
72 |
+
Context: Please generate a scenario involving a challenge related to the math topic of the paper for a student named [Student Name].
|
73 |
+
The scenario should be about the student encountering a problem or challenge related to [the specific math topic or situation], and their response to the challenge.
|
74 |
+
Focus on what part of learning the math topic makes the student feel frustrated.
|
75 |
+
|
76 |
+
Scenario Context (3-4 sentences): [Generated scenario context]
|
77 |
+
|
78 |
+
Questions: Design Four New Questions about this Scenario
|
79 |
+
|
80 |
+
1. Constructed-response Open-Ended Question (Motivation):
|
81 |
+
Question: Ask participants to propose their response or solution to the scenario, directly addressing the mathematical topic related issue in the scenario.
|
82 |
+
Purpose: Initial reaction, free expression.
|
83 |
+
Reason: Encourages creative thinking and reflection.
|
84 |
+
|
85 |
+
2. Selected-response Question (Assessment of Understanding):
|
86 |
+
Question: Present 4 possible tutor responses about how to teach this math topic effectively with varied appropriateness that could be applied in the scenario. Ask tutors to choose the option they believe is most effective. Mark the correct response and give the reason why the others are not correct.
|
87 |
+
4 Options: The options should all be practical real-life conversations for the tutor to teach the math topic to the student in an online math tutoring session.
|
88 |
+
Requirements:
|
89 |
+
* Make one option the correct one.
|
90 |
+
* Among the three distractors, one should be obviously wrong/unrelated to the situation.
|
91 |
+
* The other two should be close distractions that would seem appropriate in other situations but not aligned with the recommendation of the paper.
|
92 |
+
* Ensure all four options are similar in length.
|
93 |
+
* Consider using some real-life math manipulatives in your examples (e.g., pizza, cup, cake) related to the strategy.
|
94 |
+
Options:
|
95 |
+
* A. [Option A]
|
96 |
+
* B. [Option B]
|
97 |
+
* C. [Option C]
|
98 |
+
* D. [Option D]
|
99 |
+
Mark the correct one and explain why the others are incorrect.
|
100 |
+
|
101 |
+
3. Constructed-response Open-Ended Question (Justification):
|
102 |
+
Question: Ask participants to explain why they chose the specific option in the previous question, detailing the reasoning behind their selection.
|
103 |
+
Purpose: Encourage deep reasoning and reflection to reinforce the tutor's understanding and justification.
|
104 |
+
Reason: This question aims to delve into the thought process of participants, ensuring they can justify their choices and demonstrate a solid grasp of effective teaching strategies related to the scenario.
|
105 |
+
|
106 |
+
4. Matching Questions
|
107 |
+
Please design a matching question that aligns with expert-recommended tutoring strategies. The question should include a table with two columns. The first column contains a realistic conversation between a tutor and a student about a math topic. The second column contains a set of multiple-choice questions, each highlighting a part of the tutor's conversation. The student needs to match these highlighted parts with the appropriate tutoring strategy. Use the following structure:
|
108 |
+
* Provide a realistic conversation between a tutor and a student, including multiple steps to help resolve the student's challenge.
|
109 |
+
* Highlight three parts of the conversation where the tutor is using specific strategies to teach the math topic.
|
110 |
+
* Create a menu with four options representing real-world effective strategies to teach the topic. And the strategy mentioned here in the options should be consistent with the research insights table I need your help to generate later.
|
111 |
+
* For each highlighted part of the conversation, repeat the menu of options and ask the student to select the strategy that most closely matches the conversation part.
|
112 |
+
* Indicate the correct answer and provide reasons for the incorrect options.
|
113 |
+
|
114 |
+
Example Table Template:
|
115 |
+
|
116 |
+
| Conversation | Options |
|
117 |
+
| -------- | ------- |
|
118 |
+
| A conversation happening with tutor and the student, including multiple steps to help resolve the challenge of the student. Highlight 3 parts of the conversation where the tutor is using some strategy to tutor the student about the math topic. | Menu with: 4 options about the real-world effective strategy to teach this topic related to the 3 highlighted conversation parts. And the strategy mentioned here in the options should be consistent with the research insights table I need your help to generate later. (Correct Answer: the strategy that most matches this part of the conversation), (Incorrect Ones: please state the reason). For other parts of the conversation, repeat the same menu with the same options. Repeat the MCQ menu 3 times. |
|
119 |
+
"""
|
120 |
+
|
121 |
+
template_3 = """
|
122 |
+
Can you generate the scenario-based math tutor training course's second scenario about the below course title and learning objective based on the retrieved research paper? Please follow the below template to generate the second scenario for the training course based on the title and the learning objective.
|
123 |
+
The situation of another student [use a new student name] in Scenario 2 will be different from Scenario 1 but analogous to it. That is, it should have different surface features but should be about math tutoring and address the same learning objectives.
|
124 |
+
It should be the same difficulty to answer as Scenario 1. The length will also be the same.
|
125 |
+
|
126 |
+
Background information:
|
127 |
+
{Course title + Description + Learning Objective generated + Scenario 1 generated}
|
128 |
+
|
129 |
+
You don't need to show the above information again in your output. You need to generate a completely different scenario, the structure will be as below.
|
130 |
+
|
131 |
+
You need to generate below components:
|
132 |
+
|
133 |
+
Scenario 2: [The Transfer Training Scenario describing a common challenge or issue a student is facing when a teacher is tutoring this math topic]
|
134 |
+
|
135 |
+
Context: Please generate a scenario involving a challenge related to the math topic of the paper for a student named [New Student Name].
|
136 |
+
The scenario should be about the student encountering a problem or challenge related to [the specific math topic or situation], and their response to the challenge.
|
137 |
+
Focus on what part of learning the math topic makes the student feel frustrated.
|
138 |
+
|
139 |
+
Scenario Context (3-4 sentences): [Generated scenario context]
|
140 |
+
|
141 |
+
Questions: Design Four New Questions about this Scenario
|
142 |
+
|
143 |
+
1. Constructed-response Open-Ended Question (Motivation):
|
144 |
+
Question: Ask participants to propose their response or solution to the scenario, directly addressing the mathematical topic related issue in the scenario.
|
145 |
+
Purpose: Initial reaction, free expression.
|
146 |
+
Reason: Encourages creative thinking and reflection.
|
147 |
+
|
148 |
+
2. Selected-response Question (Assessment of Understanding):
|
149 |
+
Question: Present 4 possible tutor responses about how to teach this math topic effectively with varied appropriateness that could be applied in the scenario. Ask tutors to choose the option they believe is most effective. Mark the correct response and give the reason why the others are not correct.
|
150 |
+
4 Options: The options should all be practical real-life conversations for the tutor to teach the math topic to the student in an online math tutoring session.
|
151 |
+
Requirements:
|
152 |
+
* Make one option the correct one.
|
153 |
+
* Among the three distractors, one should be obviously wrong/unrelated to the situation.
|
154 |
+
* The other two should be close distractions that would seem appropriate in other situations but not aligned with the recommendation of the paper.
|
155 |
+
* Ensure all four options are similar in length.
|
156 |
+
* Consider using some real-life math manipulatives in your examples (e.g., pizza, cup, cake) related to the strategy.
|
157 |
+
Options:
|
158 |
+
* A. [Option A]
|
159 |
+
* B. [Option B]
|
160 |
+
* C. [Option C]
|
161 |
+
* D. [Option D]
|
162 |
+
Mark the correct one and explain why the others are incorrect.
|
163 |
+
|
164 |
+
3. Constructed-response Open-Ended Question (Justification):
|
165 |
+
Question: Ask participants to explain why they chose the specific option in the previous question, detailing the reasoning behind their selection.
|
166 |
+
Purpose: Encourage deep reasoning and reflection to reinforce the tutor's understanding and justification.
|
167 |
+
Reason: This question aims to delve into the thought process of participants, ensuring they can justify their choices and demonstrate a solid grasp of effective teaching strategies related to the scenario.
|
168 |
+
|
169 |
+
4. Matching Questions
|
170 |
+
Please design a matching question that aligns with expert-recommended tutoring strategies. The question should include a table with two columns. The first column contains a realistic conversation between a tutor and a student about a math topic. The second column contains a set of multiple-choice questions, each highlighting a part of the tutor's conversation. The student needs to match these highlighted parts with the appropriate tutoring strategy. Use the following structure:
|
171 |
+
* Provide a realistic conversation between a tutor and a student, including multiple steps to help resolve the student's challenge.
|
172 |
+
* Highlight three parts of the conversation where the tutor is using specific strategies to teach the math topic.
|
173 |
+
* Create a menu with four options representing real-world effective strategies to teach the topic. And the strategy mentioned here in the options should be consistent with the research insights table I need your help to generate later.
|
174 |
+
* For each highlighted part of the conversation, repeat the menu of options and ask the student to select the strategy that most closely matches the conversation part.
|
175 |
+
* Indicate the correct answer and provide reasons for the incorrect options.
|
176 |
+
|
177 |
+
Example Table Template:
|
178 |
+
|
179 |
+
| Conversation | Options |
|
180 |
+
| -------- | ------- |
|
181 |
+
| A conversation happening with tutor and the student, including multiple steps to help resolve the challenge of the student. Highlight 3 parts of the conversation where the tutor is using some strategy to tutor the student about the math topic. | Menu with: 4 options about the real-world effective strategy to teach this topic related to the 3 highlighted conversation parts. And the strategy mentioned here in the options should be consistent with the research insights table I need your help to generate later. (Correct Answer: the strategy that most matches this part of the conversation), (Incorrect Ones: please state the reason). For other parts of the conversation, repeat the same menu with the same options. Repeat the MCQ menu 3 times. |
|
182 |
+
"""
|
183 |
+
|
184 |
+
template_4 = """
|
185 |
+
Can you generate the scenario-based course's research insights part based on the retrieved research paper and the below information? Please follow the template I give you.
|
186 |
+
|
187 |
+
Information:
|
188 |
+
|
189 |
+
You should generate the below content:
|
190 |
+
|
191 |
+
Research Insights:
|
192 |
+
|
193 |
+
Summarize key research findings that support the learning objectives.
|
194 |
+
You should have at least 3 paragraphs to talk about these research findings, and add in-text citations.
|
195 |
+
Discuss practical applications of these insights.
|
196 |
+
An example could be as below and you can use the same structure:
|
197 |
+
|
198 |
+
"Research says…
|
199 |
+
{Research paper context}
|
200 |
+
{Summary}
|
201 |
+
"
|
202 |
+
|
203 |
+
Strategy Table:
|
204 |
+
Generate a table with three rows and four columns based on the topic of [Learning Objective of the course] according to the research recommendations. Each row should include the following:
|
205 |
+
|
206 |
+
Strategy: [Specify the strategy about the topic].
|
207 |
+
Description: [Provide a brief description of the strategy and its effectiveness in communication.]
|
208 |
+
Good Example: [Give an example demonstrating how the strategy can be applied in a tutoring scenario, including the tone of a tutor. You should also list the reason why it is correct or not correct]
|
209 |
+
Bad Example: [Give an example demonstrating how the strategy can be applied in a tutoring scenario, including the tone of a tutor. You should provide one incorrect example here, to be opposite to a good example. You should also list the reason why it is correct or not correct]
|
210 |
+
|
211 |
+
References:
|
212 |
+
Cite all scholarly references and sources used in developing this course. You should list the source of the research papers you use here.
|
213 |
+
Do not list sources you didn't use.
|
214 |
+
"""
|
215 |
+
|
216 |
+
# General Templates (for other topics)
|
217 |
+
template_1_1 = """
|
218 |
+
Do you know what tutoring strategy the paper is talking about? Can you generate a scenario-based tutor training course about how to use the tutoring strategy effectively in classrooms as discussed in the retrieved research paper?
|
219 |
+
|
220 |
+
I need your help to generate the course title, description and learning objective, please follow the below template.
|
221 |
+
|
222 |
+
Course Title: Generate a title of this tutor training course using three words, the title should begin with a verb. It should be related to the specific tutoring strategy of the research paper and the course objective.
|
223 |
+
Example titles are: Using polite language, Managing inequity, Managing effective praise
|
224 |
+
|
225 |
+
Description: A short description (50-60 words) about the purpose of this course and why it's important for the tutor. The structure could be similar to: Have you ever met a situation when you are in an online tutoring session, you find your students are [the background of the tutoring topic] and you want to change the situation? In this module, we will be introducing [strategy name] as a way of tutoring students in an online session more effectively.
|
226 |
+
|
227 |
+
Learning Objectives (15-20 words for each):
|
228 |
+
Requirement for generation: You should generate 2 learning objectives. The learning objectives should address the "understanding" and the "creating" level of Bloom's taxonomy.
|
229 |
+
Creating means use information to create something new, understanding means grasp meaning of instructional materials. You should generate two learning objectives.
|
230 |
+
|
231 |
+
Objective 1: Describe the expected outcome of this course.
|
232 |
+
Objective 2: Outline what learners will achieve by the end of this module regarding the second objective.
|
233 |
+
|
234 |
+
One of the objectives should clearly state the most effective strategy about how to apply this tutoring strategy in online tutoring session that is advocated in the retrieved research paper.
|
235 |
+
"""
|
236 |
+
|
237 |
+
template_1_2 = """
|
238 |
+
Generate the first scenario for an online tutor training course based on the course topic, using the retrieved research paper. Follow the template below to structure the scenario.
|
239 |
+
|
240 |
+
You need to generate below components:
|
241 |
+
|
242 |
+
Template:
|
243 |
+
Scenario Structure:
|
244 |
+
Scenario 1: Describe an initial training scenario involving a common situation related to the course topic when a teacher is tutoring online.
|
245 |
+
Scenario Context: Create a scenario involving a challenge related to the topic of the paper when the teacher is tutoring a student named [Student Name]. The scenario should focus on the student's response that relates to the course topic. Use approximately 50 words.
|
246 |
+
|
247 |
+
Questions:
|
248 |
+
1. Constructed-response Open-Ended Question (Motivation):
|
249 |
+
* Question: Ask participants to propose their response or solution to the scenario, directly addressing the tutoring-related issue in the scenario.
|
250 |
+
* Purpose: Initial reaction, free expression.
|
251 |
+
* Reason: Encourages creative thinking and reflection.
|
252 |
+
|
253 |
+
2. Selected-response Question (Assessment of Understanding):
|
254 |
+
* Question: Present four possible tutor responses in conversation style about how to handle the situation effectively, with varied appropriateness, that could be applied in the scenario. Ask tutors to choose the most effective option.
|
255 |
+
* Requirements:
|
256 |
+
* Make one option correct, aligning with the paper's suggestion.
|
257 |
+
* One option should be obviously wrong/unrelated.
|
258 |
+
* Two options should be close distractions but not aligned with the paper's recommendation.
|
259 |
+
* Ensure all options are similar in length (20-30 words each).
|
260 |
+
* Options:
|
261 |
+
* A. [Option A]
|
262 |
+
* B. [Option B]
|
263 |
+
* C. [Option C]
|
264 |
+
* D. [Option D]
|
265 |
+
* Mark the correct one and explain why the others are incorrect.
|
266 |
+
|
267 |
+
3. Constructed-response Open-Ended Question (Justification):
|
268 |
+
* Question: Ask participants to explain why they chose the specific option in the previous question, detailing the reasoning behind their selection.
|
269 |
+
* Purpose: Encourage deep reasoning and reflection to reinforce the tutor's understanding and justification.
|
270 |
+
* Reason: Ensures participants can justify their choices and demonstrate a solid grasp of effective teaching strategies related to the scenario.
|
271 |
+
|
272 |
+
4. Selected-response Question (Assessment of Understanding):
|
273 |
+
* Question: Present four possible tutor responses about how to handle this situation effectively (statements, not conversations) that align with the responses in the previous questions, revealing the research-recommended strategy for the formative training scenario. Ask participants to select the principle that best supports their chosen response.
|
274 |
+
* Requirements:
|
275 |
+
* Provide statements reflecting various educational, ethical, or theoretical underpinnings related to the scenario.
|
276 |
+
* Highlight the correct answer.
|
277 |
+
* Options:
|
278 |
+
* A. [Option A]
|
279 |
+
* B. [Option B]
|
280 |
+
* C. [Option C]
|
281 |
+
* D. [Option D]
|
282 |
+
* Mark the correct answer and explain the reason for its selection.
|
283 |
+
"""
|
284 |
+
|
285 |
+
template_1_3 = """
|
286 |
+
Generate the second scenario for an online tutor training course based on the course topic, using the retrieved research paper.
|
287 |
+
Follow the template below to structure the scenario. It should be the same difficulty to answer as Scenario 1.
|
288 |
+
The length will also be the same.
|
289 |
+
|
290 |
+
Template:
|
291 |
+
Scenario Structure:
|
292 |
+
Scenario 2: Describe a transfer training scenario involving a common situation related to the course topic when a teacher is tutoring online. This scenario should involve a new student [use a different student name than in Scenario 1] and is designed for tutors who have completed the initial scenario, but still focuses on the same topic.
|
293 |
+
Scenario Context: Create a scenario involving a challenge related to the topic of the paper when the teacher is tutoring a student named [Student Name]. The scenario should focus on the student's response that relates to the course topic. Use approximately 50 words.
|
294 |
+
|
295 |
+
Questions:
|
296 |
+
1. Constructed-response Open-Ended Question (Motivation):
|
297 |
+
* Question: Ask participants to propose their response or solution to the scenario, directly addressing the tutoring-related issue in the scenario.
|
298 |
+
* Purpose: Initial reaction, free expression.
|
299 |
+
* Reason: Encourages creative thinking and reflection.
|
300 |
+
|
301 |
+
2. Selected-response Question (Assessment of Understanding):
|
302 |
+
* Question: Present four possible tutor responses in conversation style about how to handle the situation effectively, with varied appropriateness, that could be applied in the scenario. Ask tutors to choose the most effective option.
|
303 |
+
* Requirements:
|
304 |
+
* Make one option correct, aligning with the paper's suggestion.
|
305 |
+
* One option should be obviously wrong/unrelated.
|
306 |
+
* Two options should be close distractions but not aligned with the paper's recommendation.
|
307 |
+
* Ensure all options are similar in length (20-30 words each).
|
308 |
+
* Options:
|
309 |
+
* A. [Option A]
|
310 |
+
* B. [Option B]
|
311 |
+
* C. [Option C]
|
312 |
+
* D. [Option D]
|
313 |
+
* Mark the correct one and explain why the others are incorrect.
|
314 |
+
|
315 |
+
3. Constructed-response Open-Ended Question (Justification):
|
316 |
+
* Question: Ask participants to explain why they chose the specific option in the previous question, detailing the reasoning behind their selection.
|
317 |
+
* Purpose: Encourage deep reasoning and reflection to reinforce the tutor's understanding and justification.
|
318 |
+
* Reason: Ensures participants can justify their choices and demonstrate a solid grasp of effective teaching strategies related to the scenario.
|
319 |
+
|
320 |
+
4. Selected-response Question (Assessment of Understanding):
|
321 |
+
* Question: Present four possible tutor responses about how to handle this situation effectively (statements, not conversations) in the previous questions, revealing the research-recommended strategy for the formative training scenario. Ask participants to select the principle that best supports their chosen response.
|
322 |
+
* Requirements:
|
323 |
+
* Provide statements reflecting various educational, ethical, or theoretical underpinnings related to the scenario.
|
324 |
+
* Highlight the correct answer.
|
325 |
+
* Options:
|
326 |
+
* A. [Option A]
|
327 |
+
* B. [Option B]
|
328 |
+
* C. [Option C]
|
329 |
+
* D. [Option D]
|
330 |
+
* Mark the correct answer and explain the reason for its selection.
|
331 |
+
"""
|
332 |
+
|
333 |
+
template_1_4 = """
|
334 |
+
Can you generate the scenario-based course's research insights part based on the retrieved research paper and the below information? Please follow the template I give you.
|
335 |
+
|
336 |
+
You should generate the below content:
|
337 |
+
|
338 |
+
Research Insights:
|
339 |
+
|
340 |
+
Summarize key research findings that support the learning objectives.
|
341 |
+
You should have at least 3 paragraphs to talk about these research findings, and add in-text citations.
|
342 |
+
Discuss practical applications of these insights.
|
343 |
+
An example could be as below and you can use the same structure:
|
344 |
+
|
345 |
+
"Research says…
|
346 |
+
{context}
|
347 |
+
{summary}
|
348 |
+
"
|
349 |
+
|
350 |
+
Strategy Table:
|
351 |
+
Generate a table with three rows and four columns based on the topic of [Learning Objective of the course] according to the research recommendations. Each row should include the following:
|
352 |
+
|
353 |
+
Strategy: [Specify the strategy about the topic].
|
354 |
+
Description: [Provide a brief description of the strategy and its effectiveness in communication.]
|
355 |
+
Good Example: [Give an example demonstrating how the strategy can be applied in a tutoring scenario, including the tone of a tutor. You should also list the reason why it is correct or not correct]
|
356 |
+
Bad Example: [Give an example demonstrating how the strategy can be applied in a tutoring scenario, including the tone of a tutor. You should provide one incorrect example here, to be opposite to a good example. You should also list the reason why it is correct or not correct]
|
357 |
+
|
358 |
+
References:
|
359 |
+
Cite all scholarly references and sources used in developing this course. You should list the source of the research papers you use here.
|
360 |
+
Do not list sources you didn't use.
|
361 |
+
"""
|
362 |
+
|
363 |
+
# Function to read PDFs and extract text
|
364 |
+
def read_pdfs(pdf_files):
|
365 |
+
docs = []
|
366 |
+
for pdf_file in pdf_files:
|
367 |
+
reader = PdfReader(pdf_file)
|
368 |
+
text = ""
|
369 |
+
for page in reader.pages:
|
370 |
+
text += page.extract_text()
|
371 |
+
docs.append(Document(page_content=text))
|
372 |
+
return docs
|
373 |
+
|
374 |
+
# Function to split text into chunks
|
375 |
+
def split_text(docs):
|
376 |
+
text_splitter = RecursiveCharacterTextSplitter(
|
377 |
+
chunk_size=2000, chunk_overlap=100, separators=["\n\n", "\n\n\n", "\n", " ", ""]
|
378 |
+
)
|
379 |
+
return text_splitter.split_documents(documents=docs)
|
380 |
+
|
381 |
+
def clear_session_cache():
|
382 |
+
"""clear session state"""
|
383 |
+
cache_keys = [
|
384 |
+
'generated_course_1', 'generated_course_2',
|
385 |
+
'generated_course_3', 'generated_course_4',
|
386 |
+
'persist_directory'
|
387 |
+
]
|
388 |
+
|
389 |
+
for key in cache_keys:
|
390 |
+
if key in st.session_state:
|
391 |
+
del st.session_state[key]
|
392 |
+
|
393 |
+
def generate_course_section(openai_api_key, text_chunks, template):
|
394 |
+
"""generate course section based on the provided text chunks and template"""
|
395 |
+
|
396 |
+
unique_id = f"{uuid.uuid4().hex[:8]}_{int(time.time())}"
|
397 |
+
persist_directory = f"chroma_db_{unique_id}"
|
398 |
+
|
399 |
+
try:
|
400 |
+
if os.path.exists(persist_directory):
|
401 |
+
shutil.rmtree(persist_directory, ignore_errors=True)
|
402 |
+
|
403 |
+
embeddings = OpenAIEmbeddings(openai_api_key=openai_api_key)
|
404 |
+
vector_db = Chroma.from_documents(
|
405 |
+
documents=text_chunks,
|
406 |
+
embedding=embeddings,
|
407 |
+
persist_directory=persist_directory
|
408 |
+
)
|
409 |
+
|
410 |
+
custom_retriever = vector_db.as_retriever()
|
411 |
+
custom_retriever.search_type = "mmr"
|
412 |
+
custom_retriever.search_kwargs = {"fetchK": 10, "lambda": 0.25}
|
413 |
+
PROMPT = PromptTemplate(template=prompt_template, input_variables=["context", "question"])
|
414 |
+
|
415 |
+
qachain = RetrievalQA.from_chain_type(
|
416 |
+
llm=ChatOpenAI(
|
417 |
+
openai_api_key=openai_api_key,
|
418 |
+
model_name="gpt-4o",
|
419 |
+
temperature=0.6,
|
420 |
+
verbose=False,
|
421 |
+
),
|
422 |
+
chain_type="stuff",
|
423 |
+
chain_type_kwargs={"prompt": PROMPT},
|
424 |
+
retriever=custom_retriever,
|
425 |
+
)
|
426 |
+
|
427 |
+
doc_prompt = qachain.invoke({"query": template})
|
428 |
+
return doc_prompt["result"]
|
429 |
+
|
430 |
+
except Exception as e:
|
431 |
+
st.error(f"generate course section failed: {str(e)}")
|
432 |
+
return f"generate course section failed: {str(e)}"
|
433 |
+
|
434 |
+
finally:
|
435 |
+
if os.path.exists(persist_directory):
|
436 |
+
try:
|
437 |
+
shutil.rmtree(persist_directory, ignore_errors=True)
|
438 |
+
except Exception as e:
|
439 |
+
st.warning(f"clear cache directory failed: {str(e)}")
|
440 |
+
|
441 |
+
# Streamlit interface
|
442 |
+
def main():
|
443 |
+
st.text("What are you looking to learn today?")
|
444 |
+
st.header("Input your customized course topic")
|
445 |
+
|
446 |
+
current_step = st.progress(100)
|
447 |
+
|
448 |
+
col1, col2 = st.columns([1,1])
|
449 |
+
with col1:
|
450 |
+
st.page_link("app.py", label="State your learning goal", icon="1️⃣")
|
451 |
+
|
452 |
+
with col2:
|
453 |
+
st.page_link("pages/step2.py", label="Upload your research papers", icon="2️⃣")
|
454 |
+
|
455 |
+
if st.button("🔄 Clear All Cache", key="clear_cache_step2"):
|
456 |
+
for item in os.listdir("."):
|
457 |
+
if item.startswith("chroma_db"):
|
458 |
+
try:
|
459 |
+
shutil.rmtree(item, ignore_errors=True)
|
460 |
+
except:
|
461 |
+
pass
|
462 |
+
|
463 |
+
clear_session_cache()
|
464 |
+
st.success("Cache cleared successfully!")
|
465 |
+
|
466 |
+
openai_api_key = st.text_input("OpenAI API Key", type="password")
|
467 |
+
uploaded_files = st.file_uploader("Upload PDF files (please enter less than five files)", type=["pdf"], accept_multiple_files=True)
|
468 |
+
|
469 |
+
if 'topic' in st.session_state:
|
470 |
+
st.info(f"📌 Current Topic: {st.session_state.topic}")
|
471 |
+
if 'learning_objective' in st.session_state and st.session_state.learning_objective:
|
472 |
+
st.info(f"🎯 Learning Objective: {st.session_state.learning_objective}")
|
473 |
+
|
474 |
+
col1, col2 = st.columns([3.5,1.5])
|
475 |
+
with col1:
|
476 |
+
if st.button("Back"):
|
477 |
+
switch_page("app")
|
478 |
+
|
479 |
+
with col2:
|
480 |
+
generate_button = st.button("Generate Course Section")
|
481 |
+
|
482 |
+
if generate_button:
|
483 |
+
if not openai_api_key:
|
484 |
+
st.error("Please enter your OpenAI API Key")
|
485 |
+
return
|
486 |
+
|
487 |
+
if not uploaded_files:
|
488 |
+
st.error("Please upload at least one PDF file")
|
489 |
+
return
|
490 |
+
|
491 |
+
if 'topic' not in st.session_state or not st.session_state.topic:
|
492 |
+
st.error("Please go back and select a topic first")
|
493 |
+
return
|
494 |
+
|
495 |
+
clear_session_cache()
|
496 |
+
|
497 |
+
for item in os.listdir("."):
|
498 |
+
if item.startswith("chroma_db"):
|
499 |
+
try:
|
500 |
+
shutil.rmtree(item, ignore_errors=True)
|
501 |
+
except:
|
502 |
+
pass
|
503 |
+
|
504 |
+
try:
|
505 |
+
docs = read_pdfs(uploaded_files)
|
506 |
+
text_chunks = split_text(docs)
|
507 |
+
|
508 |
+
# session_state
|
509 |
+
st.session_state.key = openai_api_key
|
510 |
+
st.session_state.text = text_chunks
|
511 |
+
|
512 |
+
if st.session_state.get('topic') == "Mastery of Content":
|
513 |
+
st.session_state.is_math_template = True
|
514 |
+
st.session_state.template1 = template_1
|
515 |
+
st.session_state.template2 = template_2
|
516 |
+
st.session_state.template3 = template_3
|
517 |
+
st.session_state.template4 = template_4
|
518 |
+
st.success("📚 Using Math Content templates")
|
519 |
+
else:
|
520 |
+
st.session_state.is_math_template = False
|
521 |
+
st.session_state.template1 = template_1_1
|
522 |
+
st.session_state.template2 = template_1_2
|
523 |
+
st.session_state.template3 = template_1_3
|
524 |
+
st.session_state.template4 = template_1_4
|
525 |
+
st.success("🎯 Using General Tutoring templates")
|
526 |
+
|
527 |
+
if not st.session_state.get('learning_objective'):
|
528 |
+
st.session_state.learning_objective = "Explain and create effective instructional strategies for student engagement and learning"
|
529 |
+
|
530 |
+
st.success(f"✅ Ready to generate course for: {st.session_state.topic}")
|
531 |
+
switch_page("step3")
|
532 |
+
|
533 |
+
except Exception as e:
|
534 |
+
st.error(f"Error processing files: {str(e)}")
|
535 |
+
return
|
536 |
+
|
537 |
+
if __name__ == "__main__":
|
538 |
+
main()
|
pages/step3.py
ADDED
@@ -0,0 +1,181 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from streamlit_extras.switch_page_button import switch_page
|
3 |
+
import time
|
4 |
+
import streamlit.components.v1 as components
|
5 |
+
from st_pages import Page, Section, show_pages, add_indentation
|
6 |
+
import shutil
|
7 |
+
import os
|
8 |
+
|
9 |
+
|
10 |
+
try:
|
11 |
+
from pages.step2 import generate_course_section
|
12 |
+
except ImportError:
|
13 |
+
from step2 import generate_course_section
|
14 |
+
|
15 |
+
add_indentation()
|
16 |
+
|
17 |
+
def clear_generation_cache():
|
18 |
+
"""clear the session state for generated course sections"""
|
19 |
+
generation_keys = ['generated_course_1', 'generated_course_2', 'generated_course_3', 'generated_course_4']
|
20 |
+
for key in generation_keys:
|
21 |
+
if key in st.session_state:
|
22 |
+
del st.session_state[key]
|
23 |
+
|
24 |
+
def main():
|
25 |
+
st.header("📚 Generating Your Customized Course")
|
26 |
+
|
27 |
+
if hasattr(st.session_state, 'paper_category'):
|
28 |
+
category_display = {
|
29 |
+
"EDUCATION_LEARNING_SCIENCE": "Education/Learning Science",
|
30 |
+
"LINGUISTICS_THEORY": "Linguistics/Theory (Generating general language tutoring course)",
|
31 |
+
"NON_EDUCATION": "Non-Education Field (Generating general tutoring strategies)"
|
32 |
+
}
|
33 |
+
st.info(f"📋 Paper Classification: {category_display.get(st.session_state.paper_category, 'Unknown')}")
|
34 |
+
|
35 |
+
required_keys = ['key', 'text', 'template1', 'topic']
|
36 |
+
missing_keys = [key for key in required_keys if key not in st.session_state]
|
37 |
+
|
38 |
+
if missing_keys:
|
39 |
+
st.error(f"❌ Missing required data: {missing_keys}")
|
40 |
+
st.warning("Please go back and complete the setup process.")
|
41 |
+
|
42 |
+
col1, col2 = st.columns([1, 1])
|
43 |
+
with col1:
|
44 |
+
if st.button("🏠 Go to Home"):
|
45 |
+
switch_page("app")
|
46 |
+
with col2:
|
47 |
+
if st.button("📄 Go to Step 2"):
|
48 |
+
switch_page("step2")
|
49 |
+
return
|
50 |
+
|
51 |
+
with st.expander("📋 Current Configuration", expanded=False):
|
52 |
+
st.write(f"**Topic:** {st.session_state.get('topic', 'Not set')}")
|
53 |
+
st.write(f"**Learning Objective:** {st.session_state.get('learning_objective', 'Default objectives will be used')}")
|
54 |
+
st.write(f"**Template Type:** {'Math Content' if st.session_state.get('is_math_template', False) else 'General Tutoring'}")
|
55 |
+
st.write(f"**Text Chunks:** {len(st.session_state.get('text', []))} chunks loaded")
|
56 |
+
|
57 |
+
clear_generation_cache()
|
58 |
+
if not st.session_state.get('generated_course_1'):
|
59 |
+
progress_bar = st.progress(0)
|
60 |
+
status_text = st.empty()
|
61 |
+
|
62 |
+
try:
|
63 |
+
status_text.text("🔄 Generating Course Introduction...")
|
64 |
+
progress_bar.progress(10)
|
65 |
+
|
66 |
+
template1 = st.session_state.template1
|
67 |
+
if '{learning_objective}' in template1:
|
68 |
+
formatted_template = template1.format(
|
69 |
+
learning_objective=st.session_state.get('learning_objective', 'Develop effective tutoring strategies')
|
70 |
+
)
|
71 |
+
else:
|
72 |
+
formatted_template = template1
|
73 |
+
|
74 |
+
st.session_state.generated_course_1 = generate_course_section(
|
75 |
+
st.session_state.key,
|
76 |
+
st.session_state.text,
|
77 |
+
formatted_template
|
78 |
+
)
|
79 |
+
progress_bar.progress(30)
|
80 |
+
|
81 |
+
# Scenario 1
|
82 |
+
status_text.text("🔄 Generating Scenario 1...")
|
83 |
+
st.session_state.generated_course_2 = generate_course_section(
|
84 |
+
st.session_state.key,
|
85 |
+
st.session_state.text,
|
86 |
+
st.session_state.template2
|
87 |
+
)
|
88 |
+
progress_bar.progress(60)
|
89 |
+
|
90 |
+
# Scenario 2
|
91 |
+
status_text.text("🔄 Generating Scenario 2...")
|
92 |
+
st.session_state.generated_course_3 = generate_course_section(
|
93 |
+
st.session_state.key,
|
94 |
+
st.session_state.text,
|
95 |
+
st.session_state.template3
|
96 |
+
)
|
97 |
+
progress_bar.progress(85)
|
98 |
+
|
99 |
+
# Research Insights
|
100 |
+
status_text.text("🔄 Generating Research Insights...")
|
101 |
+
st.session_state.generated_course_4 = generate_course_section(
|
102 |
+
st.session_state.key,
|
103 |
+
st.session_state.text,
|
104 |
+
st.session_state.template4
|
105 |
+
)
|
106 |
+
progress_bar.progress(100)
|
107 |
+
|
108 |
+
status_text.text("✅ Course generation completed!")
|
109 |
+
time.sleep(1)
|
110 |
+
|
111 |
+
progress_bar.empty()
|
112 |
+
status_text.empty()
|
113 |
+
|
114 |
+
except Exception as e:
|
115 |
+
st.error(f"❌ Error generating course: {str(e)}")
|
116 |
+
st.write("Please try again or check your settings.")
|
117 |
+
|
118 |
+
col1, col2 = st.columns([1, 1])
|
119 |
+
with col1:
|
120 |
+
if st.button("🔄 Retry Generation"):
|
121 |
+
clear_generation_cache()
|
122 |
+
st.rerun()
|
123 |
+
with col2:
|
124 |
+
if st.button("🏠 Go Back to Home"):
|
125 |
+
switch_page("app")
|
126 |
+
return
|
127 |
+
|
128 |
+
st.success("🎉 Course Generated Successfully!")
|
129 |
+
|
130 |
+
with st.container():
|
131 |
+
st.markdown("### 📖 Course Introduction")
|
132 |
+
if st.session_state.get('generated_course_1'):
|
133 |
+
st.write(st.session_state.generated_course_1)
|
134 |
+
else:
|
135 |
+
st.warning("Course introduction not available")
|
136 |
+
|
137 |
+
st.markdown("---")
|
138 |
+
col1, col2, col3 = st.columns([2, 2, 2])
|
139 |
+
|
140 |
+
with col1:
|
141 |
+
if st.button("⬅️ Previous", help="Go back to setup"):
|
142 |
+
switch_page("step2")
|
143 |
+
|
144 |
+
with col2:
|
145 |
+
if st.button("🔄 Regenerate", help="Generate new content", key="regenerate_results"):
|
146 |
+
clear_generation_cache()
|
147 |
+
# 清理向量数据库
|
148 |
+
for item in os.listdir("."):
|
149 |
+
if item.startswith("chroma_db"):
|
150 |
+
try:
|
151 |
+
shutil.rmtree(item, ignore_errors=True)
|
152 |
+
except:
|
153 |
+
pass
|
154 |
+
st.rerun()
|
155 |
+
|
156 |
+
with col3:
|
157 |
+
if st.button("➡️ Next", help="Go to Scenario 1"):
|
158 |
+
switch_page("page 2: scenario 1")
|
159 |
+
|
160 |
+
st.markdown("---")
|
161 |
+
st.markdown("### 🚀 Quick Navigation")
|
162 |
+
nav_col1, nav_col2, nav_col3, nav_col4 = st.columns(4)
|
163 |
+
|
164 |
+
with nav_col1:
|
165 |
+
if st.button("📖 Introduction", key="nav1"):
|
166 |
+
switch_page("Page 1: Introduction")
|
167 |
+
|
168 |
+
with nav_col2:
|
169 |
+
if st.button("🎭 Scenario 1", key="nav2"):
|
170 |
+
switch_page("page 2: scenario 1")
|
171 |
+
|
172 |
+
with nav_col3:
|
173 |
+
if st.button("🎪 Scenario 2", key="nav3"):
|
174 |
+
switch_page("Page 3: Scenario 2")
|
175 |
+
|
176 |
+
with nav_col4:
|
177 |
+
if st.button("🔬 Research", key="nav4"):
|
178 |
+
switch_page("Page 4: Research Says")
|
179 |
+
|
180 |
+
if __name__ == "__main__":
|
181 |
+
main()
|
pages/step3_result2.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from streamlit_extras.switch_page_button import switch_page
|
3 |
+
from st_pages import Page, Section, show_pages, add_indentation
|
4 |
+
|
5 |
+
add_indentation()
|
6 |
+
|
7 |
+
st.write(st.session_state.generated_course_2)
|
8 |
+
# Navigation buttons
|
9 |
+
col1, col2 = st.columns([5,1])
|
10 |
+
|
11 |
+
with col1:
|
12 |
+
if st.button("Previous"):
|
13 |
+
switch_page("Page 1: Introduction")
|
14 |
+
|
15 |
+
with col2:
|
16 |
+
if st.button("Next"):
|
17 |
+
switch_page("Page 3: Scenario 2")
|
pages/step3_result3.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from streamlit_extras.switch_page_button import switch_page
|
3 |
+
from st_pages import Page, Section, show_pages, add_indentation
|
4 |
+
|
5 |
+
add_indentation()
|
6 |
+
|
7 |
+
st.write(st.session_state.generated_course_3)
|
8 |
+
# Navigation buttons
|
9 |
+
col1, col2 = st.columns([5,1])
|
10 |
+
|
11 |
+
with col1:
|
12 |
+
if st.button("Previous"):
|
13 |
+
# switch_page("Page 2: Scenario 2")
|
14 |
+
switch_page("page 2: scenario 1")
|
15 |
+
|
16 |
+
|
17 |
+
with col2:
|
18 |
+
if st.button("Next"):
|
19 |
+
switch_page("Page 4: Research Says")
|
pages/step3_result4.py
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from streamlit_extras.switch_page_button import switch_page
|
3 |
+
import os
|
4 |
+
from st_pages import Page, Section, show_pages, add_indentation
|
5 |
+
|
6 |
+
add_indentation()
|
7 |
+
|
8 |
+
st.write(st.session_state.generated_course_4)
|
9 |
+
# Navigation buttons
|
10 |
+
# col1, col2 = st.columns([5,1])
|
11 |
+
|
12 |
+
# with col1:
|
13 |
+
# if st.button("Previous"):
|
14 |
+
# switch_page("step3 result3")
|
15 |
+
|
16 |
+
def save_page():
|
17 |
+
|
18 |
+
# Define the page content
|
19 |
+
page_content = f"""
|
20 |
+
import streamlit as st
|
21 |
+
|
22 |
+
def main():
|
23 |
+
st.title("Generated Courses")
|
24 |
+
|
25 |
+
st.write("Course 1:")
|
26 |
+
st.write(\"\"\"{st.session_state.generated_course_1}\"\"\")
|
27 |
+
|
28 |
+
st.write("Course 2:")
|
29 |
+
st.write(\"\"\"{st.session_state.generated_course_2}\"\"\")
|
30 |
+
|
31 |
+
st.write("Course 3:")
|
32 |
+
st.write(\"\"\"{st.session_state.generated_course_3}\"\"\")
|
33 |
+
|
34 |
+
st.write("Course 4:")
|
35 |
+
st.write(\"\"\"{st.session_state.generated_course_4}\"\"\")
|
36 |
+
|
37 |
+
if __name__ == "__main__":
|
38 |
+
main()
|
39 |
+
"""
|
40 |
+
|
41 |
+
# Ensure the pages directory exists
|
42 |
+
if not os.path.exists('pages'):
|
43 |
+
os.makedirs('pages')
|
44 |
+
|
45 |
+
# Write the page content to a new Python file
|
46 |
+
with open('pages/generated_page.py', 'w') as f:
|
47 |
+
f.write(page_content)
|
48 |
+
|
49 |
+
st.success("Page generated and saved successfully!")
|
50 |
+
|
51 |
+
|
52 |
+
col1, col2, col3 = st.columns([1, 5, 1])
|
53 |
+
|
54 |
+
with col1:
|
55 |
+
if st.button("Previous"):
|
56 |
+
switch_page("Page 3: Scenario 2")
|
57 |
+
|
58 |
+
with col2:
|
59 |
+
if st.button("Save Page"):
|
60 |
+
save_page()
|
61 |
+
|
62 |
+
|