|
import gradio as gr |
|
|
|
|
|
learning_paths = { |
|
"Math": "Welcome to the Math path! Solve problems and explore concepts like algebra, calculus, and geometry.", |
|
"Science & Engineering": "Dive into physics, chemistry, and engineering concepts with interactive examples.", |
|
"Computer Science & Programming": "Learn programming, algorithms, and computer science fundamentals.", |
|
"Data Science & Data Analysis": "Master data manipulation, visualization, and analysis techniques." |
|
} |
|
|
|
|
|
def show_learning_content(selected_path): |
|
""" |
|
Displays content for the selected learning path. |
|
""" |
|
return f"You selected: {selected_path}\n\n{learning_paths[selected_path]}" |
|
|
|
|
|
def provide_feedback(selected_path): |
|
return f"Great choice! Let's dive into {selected_path}." |
|
|
|
|
|
with gr.Blocks() as app: |
|
gr.Markdown("## Interactive Learning Platform") |
|
gr.Markdown("Choose a topic to start learning:") |
|
|
|
|
|
gr.Markdown('<div style="width: 100%; background-color: lightgray; height: 5px; border-radius: 5px;">' |
|
'<div style="width: 25%; background-color: green; height: 100%;"></div></div>', |
|
unsafe_allow_html=True) |
|
|
|
|
|
selected_topic = gr.Radio( |
|
choices=list(learning_paths.keys()), |
|
label="Select a Learning Path", |
|
value="Math" |
|
) |
|
|
|
|
|
with gr.Row(): |
|
continue_button = gr.Button("Continue") |
|
feedback_button = gr.Button("Get Feedback") |
|
|
|
|
|
learning_output = gr.Textbox(lines=8, interactive=False, label="Learning Content") |
|
feedback_output = gr.Textbox(interactive=False, label="Feedback") |
|
|
|
|
|
continue_button.click(fn=show_learning_content, inputs=selected_topic, outputs=learning_output) |
|
feedback_button.click(fn=provide_feedback, inputs=selected_topic, outputs=feedback_output) |
|
|
|
|
|
app.launch() |
|
|