donb-hf commited on
Commit
94ab8f3
·
verified ·
1 Parent(s): 0f5db8a

add country authority to app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -14
app.py CHANGED
@@ -14,6 +14,7 @@ with demo:
14
  with gr.Row():
15
  teacher_name = gr.Textbox(label="Teacher Name (Required)", placeholder="Enter the teacher's full name", info="e.g., Sarah Johnson")
16
  school_board = gr.Textbox(label="School Board/Region (Optional)", placeholder="Enter the school board or region", info="e.g., Oakville District School Board")
 
17
 
18
  with gr.Row():
19
  subject = gr.Textbox(label="Subject (Required)", placeholder="Enter the subject name", info="e.g., Earth Science")
@@ -33,26 +34,31 @@ with demo:
33
  clear_btn = gr.Button("Clear Landscape")
34
 
35
  examples = [
36
- ["Sarah Johnson", "Oakville District School Board", "Earth Science", "Grade 7", "Understand the water cycle and its impact on Earth's climate", "Create a terrarium to model the water cycle", "Group presentation on terrarium observations", "Terrarium kit, climate diagrams"],
37
- ["Marek Nowak", "Warsaw School District", "Matematyka", "Klasa 2", "Zrozumienie podstawowych operacji matematycznych", "Rozwiązywanie prostych zadań tekstowych", "Praca grupowa nad rozwiązywaniem zadań", "Podręcznik, karty pracy, tablica interaktywna"]
38
  ]
39
 
40
- gr.Examples(examples=examples, inputs=[teacher_name, school_board, subject, grade_level, learning_objective, activity, assessment, resource])
 
 
 
41
 
42
  search_output = gr.Textbox(label="Content Discovery Search String", show_copy_button=True)
43
  graph_output = gr.Image(label="Your Educational Landscape")
44
  message_output = gr.Textbox(label="Landscape Status", show_copy_button=True)
45
 
46
- def handle_generate(teacher_name, subject, grade_level, learning_objective, activity, assessment, resource, school_board):
47
  try:
48
- search_string, image = lesson_graph.process_inputs(teacher_name, subject, grade_level, learning_objective, activity, assessment, resource, school_board)
 
 
49
  return search_string, image, "Lesson plan mapped successfully!"
50
  except ValueError as e:
51
  return "", None, f"Error: {str(e)}. Please fill in all required fields."
52
 
53
  generate_btn.click(
54
  handle_generate,
55
- inputs=[teacher_name, subject, grade_level, learning_objective, activity, assessment, resource, school_board],
56
  outputs=[search_output, graph_output, message_output]
57
  )
58
 
@@ -67,7 +73,6 @@ with demo:
67
 
68
  def handle_reset():
69
  reset_state = lesson_graph.reset_state()
70
- # Return values for all components, including search_output and graph_output
71
  return (
72
  reset_state.teacher_name,
73
  reset_state.subject,
@@ -77,6 +82,7 @@ with demo:
77
  reset_state.assessment,
78
  reset_state.resource,
79
  reset_state.school_board,
 
80
  "", # Reset search_output
81
  None, # Reset graph_output
82
  reset_state.message
@@ -86,7 +92,7 @@ with demo:
86
  handle_reset,
87
  outputs=[
88
  teacher_name, subject, grade_level, learning_objective,
89
- activity, assessment, resource, school_board,
90
  search_output, graph_output, message_output
91
  ]
92
  )
@@ -106,15 +112,16 @@ with demo:
106
  - **Required Fields**: Teacher Name, Subject, and Grade Level
107
  - **Optional Fields**: Learning Objective, Activity, Assessment, Resource/Material, and School Board/Region
108
 
109
- ### Logical Flow of the Knowledge Graph:
110
  1. The **Teacher** node connects to the **Subject** node (representing what the teacher teaches).
111
  2. The **Subject** node connects to the **Grade Level** (defining what is taught and to whom).
112
  3. If provided, the **Learning Objective** node links to the **Subject** (showing what specific goal is covered).
113
- 4. If both are provided, the **Activity** node links to the **Learning Objective** (showing how the objective is achieved through student engagement).
114
- 5. If provided, the **Assessment** node connects to the **Learning Objective** (indicating how learning is evaluated).
115
- 6. If both are provided, the **Resource** node connects to the **Activity** (detailing what materials are needed for the activity).
116
- 7. If provided, the **Teacher** also connects to the **School Board** (showing which governing body the teacher belongs to).
117
- 8. If both are provided, the **Learning Objective** aligns with **School Board** standards (ensuring that the lesson adheres to curriculum requirements).
 
118
 
119
  ### Example Use Case:
120
  A teacher, Sarah Johnson, inputs her lesson plan for Grade 7 Earth Science. She must provide her name, the subject, and the grade level. Optionally, she can add a learning objective about understanding the water cycle, an activity to create a terrarium, a group presentation for assessment, and specify resources like a terrarium kit. The system visualizes the relationships between these elements in the graph and generates a content discovery string to help her find additional resources.
 
14
  with gr.Row():
15
  teacher_name = gr.Textbox(label="Teacher Name (Required)", placeholder="Enter the teacher's full name", info="e.g., Sarah Johnson")
16
  school_board = gr.Textbox(label="School Board/Region (Optional)", placeholder="Enter the school board or region", info="e.g., Oakville District School Board")
17
+ country_authority = gr.Textbox(label="Country Authority (Optional)", placeholder="Enter the country-level education authority", info="e.g., Ministry of National Education of Poland")
18
 
19
  with gr.Row():
20
  subject = gr.Textbox(label="Subject (Required)", placeholder="Enter the subject name", info="e.g., Earth Science")
 
34
  clear_btn = gr.Button("Clear Landscape")
35
 
36
  examples = [
37
+ ["Sarah Johnson", "Oakville District School Board", "Ministry of Education", "Earth Science", "Grade 7", "Understand the water cycle and its impact on Earth's climate", "Create a terrarium to model the water cycle", "Group presentation on terrarium observations", "Terrarium kit, climate diagrams"],
38
+ ["Marek Nowak", "Warsaw School District", "Ministry of National Education of Poland", "Matematyka", "Klasa 2", "Zrozumienie podstawowych operacji matematycznych", "Rozwiązywanie prostych zadań tekstowych", "Praca grupowa nad rozwiązywaniem zadań", "Podręcznik, karty pracy, tablica interaktywna"]
39
  ]
40
 
41
+ gr.Examples(
42
+ examples=examples,
43
+ inputs=[teacher_name, school_board, country_authority, subject, grade_level, learning_objective, activity, assessment, resource]
44
+ )
45
 
46
  search_output = gr.Textbox(label="Content Discovery Search String", show_copy_button=True)
47
  graph_output = gr.Image(label="Your Educational Landscape")
48
  message_output = gr.Textbox(label="Landscape Status", show_copy_button=True)
49
 
50
+ def handle_generate(teacher_name, subject, grade_level, learning_objective, activity, assessment, resource, school_board, country_authority):
51
  try:
52
+ search_string, image = lesson_graph.process_inputs(
53
+ teacher_name, subject, grade_level, learning_objective, activity, assessment, resource, school_board, country_authority
54
+ )
55
  return search_string, image, "Lesson plan mapped successfully!"
56
  except ValueError as e:
57
  return "", None, f"Error: {str(e)}. Please fill in all required fields."
58
 
59
  generate_btn.click(
60
  handle_generate,
61
+ inputs=[teacher_name, subject, grade_level, learning_objective, activity, assessment, resource, school_board, country_authority],
62
  outputs=[search_output, graph_output, message_output]
63
  )
64
 
 
73
 
74
  def handle_reset():
75
  reset_state = lesson_graph.reset_state()
 
76
  return (
77
  reset_state.teacher_name,
78
  reset_state.subject,
 
82
  reset_state.assessment,
83
  reset_state.resource,
84
  reset_state.school_board,
85
+ reset_state.country_authority, # Include the new field
86
  "", # Reset search_output
87
  None, # Reset graph_output
88
  reset_state.message
 
92
  handle_reset,
93
  outputs=[
94
  teacher_name, subject, grade_level, learning_objective,
95
+ activity, assessment, resource, school_board, country_authority, # Include the new field
96
  search_output, graph_output, message_output
97
  ]
98
  )
 
112
  - **Required Fields**: Teacher Name, Subject, and Grade Level
113
  - **Optional Fields**: Learning Objective, Activity, Assessment, Resource/Material, and School Board/Region
114
 
115
+ ### Logical Flow of the Knowledge Graph:
116
  1. The **Teacher** node connects to the **Subject** node (representing what the teacher teaches).
117
  2. The **Subject** node connects to the **Grade Level** (defining what is taught and to whom).
118
  3. If provided, the **Learning Objective** node links to the **Subject** (showing what specific goal is covered).
119
+ 4. If provided, the **Country Authority** node connects to the **Learning Objective** (indicating that the national authority defines the learning objectives).
120
+ 5. If both are provided, the **Activity** node links to the **Learning Objective** (showing how the objective is achieved through student engagement).
121
+ 6. If provided, the **Assessment** node connects to the **Learning Objective** (indicating how learning is evaluated).
122
+ 7. If both are provided, the **Resource** node connects to the **Activity** (detailing what materials are needed for the activity).
123
+ 8. If provided, the **Teacher** also connects to the **School Board** (showing which governing body the teacher belongs to).
124
+ 9. If both are provided, the **Country Authority** node connects to the **School Board** (showing oversight from the national level).
125
 
126
  ### Example Use Case:
127
  A teacher, Sarah Johnson, inputs her lesson plan for Grade 7 Earth Science. She must provide her name, the subject, and the grade level. Optionally, she can add a learning objective about understanding the water cycle, an activity to create a terrarium, a group presentation for assessment, and specify resources like a terrarium kit. The system visualizes the relationships between these elements in the graph and generates a content discovery string to help her find additional resources.