Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from database_functions import getUniqueSubmitDate, getUniqueClass | |
| from teachers_dashboard import show_dashboard, updateReportByDateAndClass, chat_with_json_output | |
| def create_teachers_dashboard_tab(): | |
| with gr.Tab("Teacher's Dashboard") as teacher_dash_tab: | |
| with gr.Column() as login_dash: | |
| password_input = gr.Textbox(label="Enter Password", type="password") | |
| btn_login_dash = gr.Button("Submit") | |
| dashboard_content = gr.HTML() | |
| with gr.Column(visible=False) as teacher_dash: | |
| gr.Markdown("## Teacher Dash (unlocked)") | |
| with gr.Tab("Select Date Range and Class"): | |
| date_choices = getUniqueSubmitDate() | |
| ddl_start_date = gr.Dropdown(choices=date_choices, label="Start Date") | |
| ddl_end_date = gr.Dropdown(choices=date_choices, label="End Date") | |
| class_choices = getUniqueClass() | |
| ddl_class = gr.Dropdown(choices=class_choices, label="Select a class") | |
| display_ai_feedback = gr.Checkbox(label="Display AI Feedback", value=True) | |
| btn_show_report_date_range_class = gr.Button("Display Submissions") | |
| submission_report = gr.JSON(label="Submissions for Selected Date Range and Class") | |
| gr.Markdown("You can use the following example queries to analyze the student responses:") | |
| query_input = gr.Textbox(label="Teacher's Query") | |
| additional_inputs_accordion = gr.Accordion(label="Example Queries", open=True) | |
| with additional_inputs_accordion: | |
| gr.Examples(examples=[ | |
| ["General Analysis: Summarize overall performance and identify patterns"], | |
| ["Specific Analysis: Identify common misconceptions and suggest interventions"], | |
| ["Specific Analysis: Analyze the effectiveness of strategies used"], | |
| ["Specific Analysis: Compare performance of different student groups"], | |
| ["Specific Analysis: Track individual student progress over time"], | |
| ["Completion Rate Analysis: Breakdown of questions attempted and insights"] | |
| ], inputs=[query_input]) | |
| chat_interface = gr.Chatbot(label="Overall Analysis on Students Responses") | |
| chat_button = gr.Button("Chat") | |
| chat_button.click( | |
| chat_with_json_output, | |
| inputs=[query_input, submission_report, chat_interface], | |
| outputs=chat_interface | |
| ) | |
| btn_login_dash.click(show_dashboard, inputs=[password_input], outputs=[dashboard_content, teacher_dash, login_dash, ddl_start_date, ddl_class]) | |
| btn_show_report_date_range_class.click(updateReportByDateAndClass, inputs=[ddl_start_date, ddl_end_date, ddl_class, display_ai_feedback], outputs=[submission_report, chat_interface]) | |
| return teacher_dash_tab |