-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
172 lines (145 loc) · 7.54 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import streamlit as st
from streamlit_tags import st_tags
from docx import Document
from io import BytesIO
import json
# Set the title of your application
st.title("Generate a Lesson Plan for Climate related issues!")
# Create a form
with st.form(key='my_form'):
# Create a text input for the lesson title
lesson_title = st.text_input("Enter Lesson Title")
all_topics = st_tags(
label='Enter Key Topics:',
text='Write topics and press enter to add',
value=[],
suggestions=['CO2', 'Keeling Curve', 'Solar Panels'],
maxtags=10,
key='4'
)
learning_objectives = st_tags(
label='Enter learning_objectives :',
text='Write objectives and press enter to add',
value=[],
suggestions=[],
maxtags=10,
key='5'
)
st.markdown("# Audience")
all_audience = st_tags(
label='Enter audiences:',
text='Write audiences and press enter to add',
value=[],
suggestions=["High School", "General Audience", "AP"],
maxtags=10,
key='6'
)
# Create a text input for number of students
number_of_students = st.text_input("How many students?")
all_locations = st_tags(
label='Enter locations:',
text='Write locations and press enter to add',
value=[],
suggestions=["classroom", "field", "Bay Area"],
maxtags=10,
key='7'
)
all_acrqs = st_tags(
label='Enter Accessibilty Requirments:',
text='Write Accessibilty Requirments and press enter to add',
value=[],
suggestions=["Students with Visual Impairements"],
maxtags=10,
key='8'
)
st.markdown("# Classroom Practicalities")
all_avrs = st_tags(
label='Enter Available Resources:',
text='Write Available Resources and press enter to add',
value=[],
suggestions=["WhiteBoard","Computers"],
maxtags=10,
key='9'
)
# Create a text input for lesson length
lesson_length = st.text_input("Lesson Length (minutes): ")
all_teme = st_tags(
label='Enter Teaching Methods:',
text='Write Teaching Methods and press enter to add',
value=[],
suggestions=["Lecture", "Discussion", "Hands-On"],
maxtags=10,
key='10'
)
# Create a submit button inside the form
submit_button = st.form_submit_button(label='Generate')
# You can use the variables from the form anywhere in your code
if submit_button:
# Print all the variables
st.write("Lesson Title: ", lesson_title)
st.write("All Topics: ", all_topics)
st.write("Learning Objectives: ", learning_objectives)
st.write("All Audience: ", all_audience)
st.write("Number of Students: ", number_of_students)
st.write("All Locations: ", all_locations)
st.write("All Accessibility Requirements: ", all_acrqs)
st.write("All Available Resources: ", all_avrs)
st.write("Lesson Length: ", lesson_length)
st.write("All Teaching Methods: ", all_teme)
final = [lesson_title, all_topics, learning_objectives, all_audience, number_of_students, all_locations, all_acrqs, all_avrs, lesson_length, all_teme ]
print(final)
#we can call for the api here using final
json_data = json.dumps(final)
# Convert the JSON string to a Python list of dictionaries
data = json.loads(json_data)
# Create a new Word document
doc = Document()
# We can format this to have titles in a docx file
doc.add_paragraph(str(data))
# Save the Word document to a BytesIO object
b = BytesIO()
doc.save(b)
b.seek(0)
# Create a download link for the Word document
st.download_button(
label="Download Word document",
data=b,
file_name='document.docx',
mime='application/vnd.openxmlformats-officedocument.wordprocessingml.document',
)
json_data = """
{
"introduction": "Begin the lesson with a brief discussion of climate change, highlighting the role of carbon dioxide as a greenhouse gas. Explain how the increase in greenhouse gases, particularly CO2, leads to global warming and ultimately climate change. Introduce the concept of the Keeling Curve, its significance, and its importance in understanding the relationship between atmospheric CO2 concentrations and global climate change.",
"core_content": "Explain the main contributors of CO2 emissions, such as fossil fuel burning (coal, oil, and natural gas), deforestation, and other land-use changes. Discuss how these human activities have led to increased atmospheric CO2 concentrations over time. Present the data from the Keeling Curve, showing the increasing trend of CO2 concentrations from the late 1950s to current times. Explain the seasonality seen in the curve and its relation to plant growth and decay.",
"learning_activities": [
"1. Distribute the Keeling Curve handout to students, either individually or in groups. Have them carefully examine the graph and annotate it, noting significant events (e.g., 400 ppm milestone) and relating these events to human activities. Encourage students to also observe the seasonal variations in the curve.",
"2. Using the trend shown on the Keeling Curve, encourage students to predict likely future increases in CO2 levels. Students can create their own rough graph projections, or use a simple linear equation to calculate estimated future CO2 concentrations. Discuss the potential consequences if CO2 emissions continue to increase.",
"3. Discuss the potential impacts of increasing atmospheric CO2 levels on global climate patterns, ecosystems, and human society. Allow students to share their thoughts in a class discussion or small group discussions. Encourage them to consider both physical consequences (e.g., sea level rise, extreme weather events) and societal consequences (e.g., food security, migration)."
],
"assessment_evaluation": "Assess students' understanding of the relationship between atmospheric carbon dioxide and climate change through their predictions and discussions. Consider evaluating their ability to recognize trends in the Keeling Curve data, the accuracy of their predictions based on that data, and their understanding of the potential impacts of continuing CO2 emissions on the climate system and human societies.",
"conclusion": "Summarize the findings of the class, highlighting the main points of discussion and the potential implications of continuing CO2 emissions on our planet. Encourage students to consider personal and societal actions that could help reduce CO2 emissions and mitigate the potential impacts of climate change, such as adopting renewable energy sources, reforestation efforts, and reducing personal carbon footprints."
}
"""
# Convert the JSON string to a Python dictionary
data = json.loads(json_data)
# Create a new Word document
doc = Document()
# Add a section to the Word document for each item in the data
for key, value in data.items():
doc.add_heading(key.replace('_', ' ').title(), level=1)
if isinstance(value, list):
for item in value:
doc.add_paragraph(item)
else:
doc.add_paragraph(value)
# Save the Word document to a BytesIO object
b = BytesIO()
doc.save(b)
b.seek(0)
# Create a download link for the Word document
st.download_button(
label="Download Word document",
data=b,
file_name='document.docx',
mime='application/vnd.openxmlformats-officedocument.wordprocessingml.document',
)