OralCoachZeroGPU / teachers_dashboard.py
simonraj's picture
Upload 17 files
cf815ef verified
#teachers_dashboard.py
import gradio as gr
import thinkingframes
from dotenv import load_dotenv
from openai import OpenAI
from database_functions import get_submissions_by_date_and_class, getUniqueSubmitDate, getUniqueClass
load_dotenv()
client = OpenAI()
def validate_password(password):
correct_password = "Happyteacher2024"
return password == correct_password
def show_dashboard(password):
if validate_password(password):
date_choices = getUniqueSubmitDate()
class_choices = getUniqueClass()
return "<p>Dashboard content goes here</p>", gr.update(visible=True), gr.update(visible=False), gr.Dropdown(choices=date_choices, label="Select a date"), gr.Dropdown(choices=class_choices, label="Select a class")
return "<p>Incorrect password</p>", gr.update(visible=False), gr.update(visible=False), gr.Dropdown(choices='', label="Select a date"), gr.Dropdown(choices='', label="Select a class")
def updateReportByDateAndClass(start_date, end_date, class_name, display_ai_feedback):
json_output = get_submissions_by_date_and_class(start_date, end_date, class_name, display_ai_feedback)
chat_history = []
return json_output, chat_history
def chat_with_json_output(query, json_output, chat_history):
questions = thinkingframes.questions
strategies = [strategy[0] for strategy in thinkingframes.strategy_options.values()]
picture_description = thinkingframes.description
history_openai_format = [
{"role": "system", "content": f"Here is the JSON output of the student responses and AI interactions:\n{json_output}"},
{"role": "user", "content": f"Selected Analysis Prompt: {query}"}
]
for human, assistant in chat_history:
history_openai_format.append({"role": "user", "content": human})
history_openai_format.append({"role": "assistant", "content": assistant})
system_prompt = f"""
You are an English Language Teacher analyzing student responses to oral questions. The questions and strategies used are:
Questions:
1. {questions[0]}
2. {questions[1]}
3. {questions[2]}
Strategies:
1. {strategies[0]}
2. {strategies[1]}
3. {strategies[2]}
Picture Description (relevant only for Question 1):
{picture_description}
Based on the provided JSON output and the selected analysis prompt, please perform the following:
General Analysis:
- If the selected prompt is "General Analysis: Summarize overall performance and identify patterns":
- Summarize the overall performance of students for each question, considering the relevant strategies and picture description.
- Identify notable patterns and trends in student responses and AI feedback.
- Highlight exemplary responses or feedback that demonstrate effective use of strategies or insightful interpretations.
Specific Analysis:
- If the selected prompt is "Specific Analysis: Identify common misconceptions and suggest interventions":
- Identify common misconceptions or errors in student responses.
- Suggest targeted interventions to address these misconceptions and improve student understanding.
- If the selected prompt is "Specific Analysis: Analyze the effectiveness of strategies used":
- Analyze the effectiveness of each strategy used by students.
- Provide recommendations for improving the use of strategies and enhancing student performance.
- If the selected prompt is "Specific Analysis: Compare performance of different student groups":
- Compare the performance of different student groups (e.g., high performers vs. struggling students).
- Offer insights and recommendations based on the identified differences and patterns.
- If the selected prompt is "Specific Analysis: Track individual student progress over time":
- Track the progress of individual students over time, if data is available.
- Highlight areas where students have shown improvement or require additional support.
Completion Rate Analysis:
- If the selected prompt is "Completion Rate Analysis: Breakdown of questions attempted and insights":
- Identify the students who have attempted all three questions, two questions, only Question 1, or no questions at all.
- Calculate the percentage of students in each category.
- Provide insights on the potential reasons for the completion rates (e.g., difficulty level, student engagement, etc.).
- Offer recommendations for improving completion rates, such as providing additional support or incentives.
Please provide the analysis in a clear and organized format, using bullet points, tables, or paragraphs as appropriate. Include specific examples and data-driven insights to support your recommendations. Focus on actionable feedback that can directly impact student learning and engagement.
"""
history_openai_format.append({"role": "user", "content": system_prompt})
history_openai_format.append({"role": "user", "content": query})
response = client.chat.completions.create(
model='gpt-4o-2024-05-13',
messages=history_openai_format,
temperature=0.2,
max_tokens=1000,
stream=True
)
partial_message = ""
for chunk in response:
if chunk.choices[0].delta.content is not None:
partial_message += chunk.choices[0].delta.content
yield chat_history + [("Assistant", partial_message)]
chat_history.append(("Assistant", partial_message))
return chat_history