Spaces:
Sleeping
Sleeping
File size: 5,643 Bytes
1221662 81f3f6f 1221662 81f3f6f 1221662 81f3f6f 1221662 81f3f6f 1221662 81f3f6f 1221662 81f3f6f |
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 |
import streamlit as st
import pandas as pd
import numpy as np
import os
import time
from dotenv import load_dotenv
from gpt_method import (
generate_lesson_plan,
generate_objectives,
generate_materials,
generate_steps,
generate_assessment
)
from lesson_editor import edit_lesson_plan
# Load environment variables
load_dotenv()
# Set page config
st.set_page_config(
page_title="Lesson Plan Generator",
page_icon="๐",
layout="wide"
)
# Add custom CSS
st.markdown("""
<style>
.main {
padding: 2rem;
}
.stButton>button {
width: 100%;
}
.stTextArea>div>div>textarea {
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
font-size: 16px;
line-height: 1.2;
font-weight: 500;
}
.stMarkdown {
font-family: 'Figtree', sans-serif;
}
</style>
""", unsafe_allow_html=True)
# Initialize session state for lesson plan
if 'lesson_plan' not in st.session_state:
st.session_state.lesson_plan = {}
# Title and description
st.title("๐ Lesson Plan Generator")
st.markdown("""
Welcome to the Lesson Plan Generator! This tool helps educators create comprehensive lesson plans.
Fill out the form below to generate your lesson plan.
""")
# Create tabs for Create and Edit
tab1, tab2 = st.tabs(["Create New", "Edit Existing"])
with tab1:
# Create a form for lesson plan details
with st.form("lesson_plan_form"):
# Basic Information
st.subheader("Basic Information")
lesson_name = st.text_input("Course Name (Required)", placeholder="e.g., Data Structures and Algorithms")
lesson_theme = st.text_input("Course Theme (Required)", placeholder="e.g., Quick Sort")
grade_level = st.selectbox("Student Level (Required)",
["Elementary School", "Middle School", "High School", "College", "Graduate"])
# Learning Objectives
st.subheader("Learning Objectives")
st.markdown("""
Please enter your course objectives (Optional). If left empty, we will generate them based on Bloom's Taxonomy.
Each objective should be on a new line.
""")
objectives = st.text_area("Course Objectives", height=200)
# Materials
st.subheader("Materials")
materials = st.text_area("List the materials needed for this lesson (One per line)")
# Lesson Duration
st.subheader("Lesson Duration")
duration = st.number_input("Duration (in minutes)", min_value=15, step=15)
# Lesson Steps
st.subheader("Lesson Steps")
steps = st.text_area("Describe the lesson steps (One per line)")
# Assessment
st.subheader("Assessment")
assessment = st.text_area("How will you assess student learning?")
# Submit button
submitted = st.form_submit_button("Generate Lesson Plan")
if submitted:
# Show a spinner while generating the lesson plan
with st.spinner("Generating your lesson plan..."):
try:
# Generate missing components if needed
if not objectives.strip():
objectives = generate_objectives(
lesson_theme,
lesson_name=lesson_name,
lesson_type=grade_level
)
if not materials.strip():
materials = generate_materials(lesson_theme, grade_level)
if not steps.strip():
steps = generate_steps(lesson_theme, grade_level, duration)
if not assessment.strip():
assessment = generate_assessment(lesson_theme, grade_level)
# Generate the complete lesson plan
lesson_plan = generate_lesson_plan(
lesson_name,
lesson_theme,
grade_level,
objectives,
materials,
duration,
steps,
assessment
)
# Save to session state
st.session_state.lesson_plan = {
'lesson_name': lesson_name,
'lesson_theme': lesson_theme,
'grade_level': grade_level,
'duration': duration,
'objectives': objectives,
'materials': materials,
'steps': steps,
'assessment': assessment,
'full_plan': lesson_plan
}
# Create a container for the generated lesson plan
with st.container():
st.markdown("## Generated Lesson Plan")
st.markdown(lesson_plan)
# Add a download button for the lesson plan
st.download_button(
label="Download Lesson Plan",
data=lesson_plan,
file_name=f"lesson_plan_{lesson_name.lower().replace(' ', '_')}.txt",
mime="text/plain"
)
except Exception as e:
st.error(f"An error occurred while generating the lesson plan: {str(e)}")
st.info("Please try again or contact support if the issue persists.")
with tab2:
edit_lesson_plan() |