rahul-appu commited on
Commit
e3562c3
·
verified ·
1 Parent(s): 5e7d3fb

init Commit

Browse files
Files changed (6) hide show
  1. app.py +23 -0
  2. content.py +106 -0
  3. helper.py +25 -0
  4. lesson_plan.py +97 -0
  5. mcq.py +147 -0
  6. worksheet.py +195 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from dotenv import load_dotenv
3
+
4
+ from mcq import mcq_generation
5
+ from lesson_plan import lesson_plan
6
+ from worksheet import worksheet_generation
7
+ from content import content_generation
8
+
9
+ load_dotenv()
10
+
11
+ with gr.Blocks() as app:
12
+ gr.Markdown("# API Demo")
13
+ with gr.Tabs():
14
+ with gr.TabItem("MCQ Generation"):
15
+ mcq_generation()
16
+ with gr.TabItem("Lesson Plan Generation"):
17
+ lesson_plan()
18
+ with gr.TabItem("Worksheet Generation"):
19
+ worksheet_generation()
20
+ with gr.TabItem("Content Generation"):
21
+ content_generation()
22
+
23
+ app.launch()
content.py ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import gradio as gr
3
+
4
+ from helper import generate_access_token
5
+
6
+ def generate_content(grade, subject, topics, learning_outcomes, notes, stories, activities, group_dicussion, extras):
7
+
8
+ data = {
9
+ "institution_id": "inst789",
10
+ "teacher_id": "teacher456",
11
+ "grade": grade,
12
+ "subject": subject,
13
+ "topics": topics.split(", "),
14
+ "learning_outcomes": learning_outcomes.split(", "),
15
+ "content_type": {
16
+ "notes": notes,
17
+ "stories": stories,
18
+ "activities": activities,
19
+ "group_dicussion": group_dicussion
20
+ },
21
+ "extras": extras.split(", ")
22
+ }
23
+
24
+ access_token = generate_access_token()
25
+
26
+ if access_token is None:
27
+ return {"Error": "Failed to generate access token"}
28
+
29
+ response = requests.post("http://20.193.151.200:8080/k12/generate/content",
30
+ headers={
31
+ "accept": "application/json",
32
+ "content-type": "application/json",
33
+ "Authorization": f"{access_token}"},
34
+ json=data)
35
+
36
+ if(str(response.status_code)[0] != '2'):
37
+ return {"Error": f"{response.status_code}"}
38
+
39
+ return response.json()
40
+
41
+ def get_content_generation(request_id):
42
+
43
+ access_token = generate_access_token()
44
+
45
+ if access_token is None:
46
+ return {"Error": "Failed to generate access token"}
47
+
48
+ url = f"http://20.193.151.200:8080/k12/generate/content/{request_id}"
49
+ headers = {"accept": "application/json",
50
+ "Authorization": access_token}
51
+
52
+ response = requests.get(url, headers=headers)
53
+
54
+ if str(response.status_code)[0] == "2":
55
+ return response.json()
56
+ else:
57
+ return {"Error" : f"{response.status_code}"}
58
+
59
+ def post_interface():
60
+
61
+ with gr.Blocks() as post_page:
62
+ grade = gr.Textbox(label="Grade", value="8")
63
+ subject = gr.Textbox(label="Subject", value="Science")
64
+
65
+ topics = gr.Textbox(label="Topics (comma-separated)", value="Plant and Animal Cells, Reproduction in Humans and Animals")
66
+ learning_outcomes = gr.Textbox(label="Learning Outcomes (comma-separated)")
67
+
68
+ notes = gr.Radio(label="Notes", choices=["Yes", "No"], value="No")
69
+ stories = gr.Radio(label="Stories", choices=["Yes", "No"], value="No")
70
+ activities = gr.Radio(label="Activities", choices=["Yes", "No"], value="No")
71
+ group_dicussion = gr.Radio(label="Group Discussion", choices=["Yes", "No"], value="No")
72
+
73
+ extras = gr.Textbox(label="Extras (comma-separated)")
74
+
75
+ submit_button = gr.Button("Invoke Request")
76
+ output = gr.JSON(label="Content Generation ID")
77
+
78
+ submit_button.click(
79
+ fn=generate_content,
80
+ inputs=[grade, subject, topics, learning_outcomes, notes, stories, activities, group_dicussion, extras],
81
+ outputs=output,
82
+ )
83
+
84
+ return post_page
85
+
86
+ def get_interface():
87
+ with gr.Blocks() as get_page:
88
+
89
+ interface = gr.Interface(
90
+ fn=get_content_generation,
91
+ inputs=gr.Textbox(label="Enter Request ID"),
92
+ outputs="json",
93
+ )
94
+
95
+ return get_page
96
+
97
+ def content_generation():
98
+ gr.Markdown("# Content Generation")
99
+ with gr.Blocks() as content_generation:
100
+ with gr.Tabs():
101
+ with gr.TabItem("POST"):
102
+ post_interface()
103
+ with gr.TabItem("GET"):
104
+ get_interface()
105
+
106
+ return content_generation
helper.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import requests
3
+
4
+ def generate_access_token():
5
+
6
+ url = "http://20.193.151.200:8080/token"
7
+ headers = {
8
+ "accept": "application/json",
9
+ "Content-Type": "application/x-www-form-urlencoded"
10
+ }
11
+ data = {
12
+ "grant_type": "",
13
+ "username": os.getenv("TOKEN_USERNAME"),
14
+ "password": os.getenv("TOKEN_PASSWORD"),
15
+ "scope": "",
16
+ "client_id": "",
17
+ "client_secret": ""
18
+ }
19
+
20
+ response = requests.post(url, headers=headers, data=data)
21
+
22
+ if(response.status_code != 200):
23
+ return None
24
+
25
+ return response.json()["access_token"]
lesson_plan.py ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import gradio as gr
3
+
4
+ from helper import generate_access_token
5
+
6
+ def generate_lesson_plan(board, grade, subject, topics, duration, learning_outcomes, curriculum_framework):
7
+
8
+ data = {
9
+ "board": board,
10
+ "curriculum_framework": curriculum_framework,
11
+ "duration": duration,
12
+ "grade": grade,
13
+ "institution_id": "inst789",
14
+ "learning_outcomes": learning_outcomes.split(", "),
15
+ "subject": subject,
16
+ "teacher_id": "teacher456",
17
+ "topics": topics.split(", ")
18
+ }
19
+
20
+ access_token = generate_access_token()
21
+
22
+ if access_token is None:
23
+ return {"Error": "Failed to generate access token"}
24
+
25
+ response = requests.post("http://20.193.151.200:8080/v1/k12/generate/lesson-plan",
26
+ headers={
27
+ "accept": "application/json",
28
+ "content-type": "application/json",
29
+ "Authorization": f"{access_token}"},
30
+ json=data)
31
+
32
+ if(str(response.status_code)[0] != '2'):
33
+ return {"Error": f"{response.status_code}"}
34
+
35
+ return response.json()
36
+
37
+ def get_lesson_plan(request_id):
38
+
39
+ access_token = generate_access_token()
40
+
41
+ if access_token is None:
42
+ return {"Error": "Failed to generate access token"}
43
+
44
+ url = f"http://20.193.151.200:8080/v1/k12/generate/lesson-plan/{request_id}"
45
+ headers = {"accept": "application/json",
46
+ "Authorization": access_token}
47
+
48
+ response = requests.get(url, headers=headers)
49
+
50
+ if response.status_code == 200:
51
+ return response.json()
52
+ else:
53
+ return {"Error" : f"{response.status_code}"}
54
+
55
+ def post_interface():
56
+
57
+ with gr.Blocks() as post_page:
58
+
59
+ board = gr.Textbox(label="Board", value="NCERT")
60
+ grade = gr.Textbox(label="Grade", value="8")
61
+ subject = gr.Textbox(label="Subject", value="Science")
62
+ topics = gr.Textbox(label="Topics (comma-separated)", value="Plant and Animal Cells, Reproduction in Humans and Animals")
63
+
64
+ duration = gr.Number(label="Duration (minutes)", value=45)
65
+ learning_outcomes = gr.Textbox(label="Learning Outcomes (comma-separated)")
66
+ curriculum_framework = gr.Textbox(label="Curriculum Framework", value="ncf2023")
67
+
68
+ output = gr.JSON(label="Lesson Plan ID")
69
+ submit_button = gr.Button("Invoke Request")
70
+
71
+ submit_button.click(
72
+ generate_lesson_plan,
73
+ inputs=[board, grade, subject, topics, duration, learning_outcomes, curriculum_framework],
74
+ outputs=output
75
+ )
76
+
77
+ def get_interface():
78
+ with gr.Blocks() as get_page:
79
+
80
+ interface = gr.Interface(
81
+ fn=get_lesson_plan,
82
+ inputs=gr.Textbox(label="Enter Request ID"),
83
+ outputs="json",
84
+ )
85
+
86
+ return get_page
87
+
88
+ def lesson_plan():
89
+ gr.Markdown("# Lesson Plan Generation")
90
+ with gr.Blocks() as lesson_plan:
91
+ with gr.Tabs():
92
+ with gr.TabItem("POST"):
93
+ post_interface()
94
+ with gr.TabItem("GET"):
95
+ get_interface()
96
+
97
+ return lesson_plan
mcq.py ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import gradio as gr
3
+
4
+ from helper import generate_access_token
5
+
6
+ def generate_mcq_questions(grade, subject, topics, number_of_questions, multiple_answer, single_answer,
7
+ easy, medium, hard, remember, understand, apply, analyze, evaluate, create,
8
+ hint, curricular_goal, competency, lo, lob, difficulty_level, bloom_taxonomy,
9
+ solution_sheet):
10
+
11
+ data = {
12
+ "institution_id": "string",
13
+ "teacher_id": "string",
14
+ "board": "NCERT",
15
+ "grade": grade,
16
+ "subject": subject,
17
+ "topics": topics.split(", "),
18
+ "number_of_questions": number_of_questions,
19
+ "question_type_distribution_percentage": {
20
+ "multiple_answer": multiple_answer,
21
+ "single_answer": single_answer,
22
+ },
23
+ "difficulty_distribution_percentage": {
24
+ "easy": easy,
25
+ "medium": medium,
26
+ "hard": hard
27
+ },
28
+ "blooms_taxonomy_distribution_percentage": {
29
+ "Remember": remember,
30
+ "Understand": understand,
31
+ "Apply": apply,
32
+ "Analyze": analyze,
33
+ "Evaluate": evaluate,
34
+ "Create": create
35
+ },
36
+ "question_tagging_options": {
37
+ "Hint": hint,
38
+ "Curricular_Goal": curricular_goal,
39
+ "Competency": competency,
40
+ "LO": lo,
41
+ "LOB": lob,
42
+ "Difficulty_level": difficulty_level,
43
+ "Bloom_Taxonomy": bloom_taxonomy
44
+ },
45
+ "solution_sheet": solution_sheet
46
+ }
47
+
48
+ access_token = generate_access_token()
49
+
50
+ if access_token is None:
51
+ return {"Error": "Failed to generate access token"}
52
+
53
+ response = requests.post("http://20.193.151.200:8080/v1/k12/generate/mcqs",
54
+ headers={
55
+ "accept": "application/json",
56
+ "content-type": "application/json",
57
+ "Authorization": f"{access_token}"},
58
+ json=data)
59
+
60
+ if(str(response.status_code)[0] != '2'):
61
+ return {"Error": f"{response.status_code}"}
62
+
63
+ return response.json()
64
+
65
+ def get_mcq_questions(request_id):
66
+
67
+ access_token = generate_access_token()
68
+
69
+ if access_token is None:
70
+ return {"Error": "Failed to generate access token"}
71
+
72
+ url = f"http://20.193.151.200:8080/v1/k12/generate/mcqs/{request_id}"
73
+ headers = {"accept": "application/json",
74
+ "Authorization": access_token}
75
+
76
+ response = requests.get(url, headers=headers)
77
+
78
+ if response.status_code == 200:
79
+ return response.json()
80
+ else:
81
+ return {"Error" : f"{response.status_code}"}
82
+
83
+ def post_interface():
84
+
85
+ with gr.Blocks() as post_page:
86
+ grade = gr.Textbox(label="Grade", value="6")
87
+ subject = gr.Textbox(label="Subject", value="Science")
88
+ topics = gr.Textbox(label="Topics (comma-separated)", value="Light")
89
+ number_of_questions = gr.Number(label="Number of Questions", value=20)
90
+
91
+ multiple_answer = gr.Slider(label="Multiple Answer Questions (%)", minimum=0, maximum=100, value=100)
92
+ single_answer = gr.Slider(label="Single Answer Questions (%)", minimum=0, maximum=100, value=0)
93
+
94
+ easy = gr.Slider(label="Easy Questions (%)", minimum=0, maximum=100, value=0)
95
+ medium = gr.Slider(label="Medium Questions (%)", minimum=0, maximum=100, value=0)
96
+ hard = gr.Slider(label="Hard Questions (%)", minimum=0, maximum=100, value=0)
97
+
98
+ remember = gr.Slider(label="Remember (%)", minimum=0, maximum=100, value=0)
99
+ understand = gr.Slider(label="Understand (%)", minimum=0, maximum=100, value=0)
100
+ apply = gr.Slider(label="Apply (%)", minimum=0, maximum=100, value=0)
101
+ analyze = gr.Slider(label="Analyze (%)", minimum=0, maximum=100, value=0)
102
+ evaluate = gr.Slider(label="Evaluate (%)", minimum=0, maximum=100, value=0)
103
+ create = gr.Slider(label="Create (%)", minimum=0, maximum=100, value=0)
104
+
105
+ hint = gr.Radio(label="Hint", choices=["Yes", "No"], value="No")
106
+ curricular_goal = gr.Radio(label="Curricular Goal", choices=["Yes", "No"], value="No")
107
+ competency = gr.Radio(label="Competency", choices=["Yes", "No"], value="No")
108
+ lo = gr.Radio(label="LO", choices=["Yes", "No"], value="No")
109
+ lob = gr.Radio(label="LOB", choices=["Yes", "No"], value="No")
110
+ difficulty_level = gr.Radio(label="Difficulty Level", choices=["Yes", "No"], value="No")
111
+ bloom_taxonomy = gr.Radio(label="Bloom Taxonomy", choices=["Yes", "No"], value="No")
112
+
113
+ solution_sheet = gr.Radio(label="Solution Sheet", choices=["Yes", "No"], value="Yes")
114
+
115
+ submit_button = gr.Button("Invoke Request")
116
+
117
+ submit_button.click(generate_mcq_questions,
118
+ inputs= [grade, subject, topics, number_of_questions, multiple_answer, single_answer,
119
+ easy, medium, hard, remember, understand, apply, analyze, evaluate, create,
120
+ hint, curricular_goal, competency, lo, lob, difficulty_level, bloom_taxonomy,
121
+ solution_sheet],
122
+ outputs=gr.JSON())
123
+
124
+ return post_page
125
+
126
+ def get_interface():
127
+
128
+ with gr.Blocks() as get_page:
129
+
130
+ interface = gr.Interface(
131
+ fn=get_mcq_questions,
132
+ inputs=gr.Textbox(label="Enter Request ID"),
133
+ outputs="json",
134
+ )
135
+
136
+ return get_page
137
+
138
+ def mcq_generation():
139
+ gr.Markdown("# MCQ Generation")
140
+ with gr.Blocks() as mcq_generation:
141
+ with gr.Tabs():
142
+ with gr.TabItem("POST"):
143
+ post_interface()
144
+ with gr.TabItem("GET"):
145
+ get_interface()
146
+
147
+ return mcq_generation
worksheet.py ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import gradio as gr
3
+
4
+ from helper import generate_access_token
5
+
6
+ def yes_no(value, array):
7
+ if value in array:
8
+ return "Yes"
9
+ else:
10
+ return "No"
11
+
12
+ def generate_worksheet(grade, subject, topics, learning_objectives, question_tagging_options,
13
+ number_of_questions, easy, medium, hard, remember, understand, apply, analyze,
14
+ evaluate, create, mcq_single_answer, mcq_multiple_answer, true_false, fill_in_the_blanks,
15
+ match_the_column, very_short_answer, short_answer, long_answer, solution_sheet, format, extras):
16
+
17
+ data = {
18
+ "institution_id": "inst789",
19
+ "teacher_id": "teacher456",
20
+ "grade": grade,
21
+ "subject": subject,
22
+ "topics": topics.split(", "),
23
+ "learning_objectives": learning_objectives.split(", "),
24
+ "question_tagging_options": {
25
+ "Hint": yes_no("Hint", question_tagging_options),
26
+ "Curricular_Goal": yes_no("Curricular Goal", question_tagging_options),
27
+ "Competency": yes_no("Competency", question_tagging_options),
28
+ "LO": yes_no("LO", question_tagging_options),
29
+ "LOB": yes_no("LOB", question_tagging_options),
30
+ "Difficulty_level": yes_no("Difficulty Level", question_tagging_options),
31
+ "Bloom_Taxonomy": yes_no("Bloom Taxonomy", question_tagging_options)
32
+ },
33
+ "number_of_questions": number_of_questions,
34
+ "difficulty_distribution_percentage": {
35
+ "easy": easy,
36
+ "medium": medium,
37
+ "hard": hard
38
+ },
39
+ "blooms_taxonomy_distribution_percentage": {
40
+ "Remember": remember,
41
+ "Understand": understand,
42
+ "Apply": apply,
43
+ "Analyze": analyze,
44
+ "Evaluate": evaluate,
45
+ "Create": create
46
+ },
47
+ "question_type_distribution_absolute": {
48
+ "MCQ_single_answer": mcq_single_answer,
49
+ "MCQ_Multiple_answer": mcq_multiple_answer,
50
+ "True_False": true_false,
51
+ "Fill_in_the_blanks": fill_in_the_blanks,
52
+ "Match_the_column": match_the_column,
53
+ "Very_Short_answer": very_short_answer,
54
+ "Short_answer": short_answer,
55
+ "Long_answer": long_answer
56
+ },
57
+ "solution_sheet": solution_sheet,
58
+ "format": format,
59
+ "extras": extras.split(", ")
60
+ }
61
+
62
+ access_token = generate_access_token()
63
+
64
+ if access_token is None:
65
+ return {"Error": "Failed to generate access token"}
66
+
67
+ response = requests.post("http://20.193.151.200:8080/k12/generate/worksheet",
68
+ headers={
69
+ "accept": "application/json",
70
+ "content-type": "application/json",
71
+ "Authorization": f"{access_token}"},
72
+ json=data)
73
+
74
+ if(str(response.status_code)[0] != '2'):
75
+ return {"Error": f"{response.status_code}"}
76
+
77
+ return response.json()
78
+
79
+ def get_worksheet(request_id):
80
+
81
+ access_token = generate_access_token()
82
+
83
+ if access_token is None:
84
+ return {"Error": "Failed to generate access token"}
85
+
86
+ url = f"http://20.193.151.200:8080/k12/generate/worksheet/{request_id}"
87
+ headers = {"accept": "application/json",
88
+ "Authorization": access_token}
89
+
90
+ response = requests.get(url, headers=headers)
91
+
92
+ if str(response.status_code)[0] == '2':
93
+ return response.json()
94
+ else:
95
+ return {"Error" : f"{response.status_code}"}
96
+
97
+ def post_interface():
98
+
99
+ with gr.Blocks() as post_page:
100
+
101
+ grade = gr.Textbox(label="Grade", value="8")
102
+ subject = gr.Textbox(label="Subject", value="Science")
103
+ topics = gr.Textbox(label="Topics (comma-separated)")
104
+ learning_objectives = gr.Textbox(label="Learning Objectives (comma-separated)")
105
+ question_tagging_options = gr.CheckboxGroup(["Hint", "Curricular Goal", "Competency", "LO", "LOB", "Difficulty Level", "Bloom Taxonomy"], label="Question Tagging Options")
106
+ number_of_questions = gr.Number(label="Number of Questions", value=10)
107
+
108
+ gr.Markdown("## Difficulty Distribution (easy, medium, hard)")
109
+ # Difficulty Distribution (easy, medium, hard)
110
+ with gr.Row():
111
+ with gr.Column():
112
+ easy = gr.Number(label="Easy", minimum=0, maximum=100, value=0)
113
+ with gr.Column():
114
+ medium = gr.Number(label="Medium", minimum=0, maximum=100, value=0)
115
+ with gr.Column():
116
+ hard = gr.Number(label="Hard", minimum=0, maximum=100, value=0)
117
+
118
+ gr.Markdown("## Bloom Taxonomy Distribution (Remember, Understand, Apply, Analyze, Evaluate, Create)")
119
+ # Bloom Taxonomy Distribution (Remember, Understand, Apply, Analyze, Evaluate, Create)
120
+ with gr.Row():
121
+ with gr.Column():
122
+ remember = gr.Number(minimum=0, maximum=100, step=1, label="Remember", value=0)
123
+ with gr.Column():
124
+ understand = gr.Number(minimum=0, maximum=100, step=1, label="Understand", value=0)
125
+ with gr.Column():
126
+ apply = gr.Number(minimum=0, maximum=100, step=1, label="Apply", value=0)
127
+ with gr.Row():
128
+ with gr.Column():
129
+ analyze = gr.Number(minimum=0, maximum=100, step=1, label="Analyze", value=0)
130
+ with gr.Column():
131
+ evaluate = gr.Number(minimum=0, maximum=100, step=1, label="Evaluate", value=0)
132
+ with gr.Column():
133
+ create = gr.Number(minimum=0, maximum=100, step=1, label="Create", value=0)
134
+
135
+ gr.Markdown("## Question Type Distribution (MCQ Single, MCQ Multiple, True/False, Fill in the Blanks, Match the Column, Very Short, Short, Long)")
136
+ with gr.Row():
137
+ with gr.Column():
138
+ mcq_single_answer = gr.Number(minimum=0, maximum=100, step=1, label="MCQ Single Answer", value=0)
139
+ with gr.Column():
140
+ mcq_multiple_answer = gr.Number(minimum=0, maximum=100, step=1, label="MCQ Multiple Answer", value=0)
141
+ with gr.Column():
142
+ true_false = gr.Number(minimum=0, maximum=100, step=1, label="True/False", value=0)
143
+ with gr.Row():
144
+ with gr.Column():
145
+ fill_in_the_blanks = gr.Number(minimum=0, maximum=100, step=1, label="Fill in the Blanks", value=0)
146
+ with gr.Column():
147
+ match_the_column = gr.Number(minimum=0, maximum=100, step=1, label="Match the Column", value=0)
148
+ with gr.Column():
149
+ very_short_answer = gr.Number(minimum=0, maximum=100, step=1, label="Very Short Answer", value=0)
150
+ with gr.Row():
151
+ with gr.Column():
152
+ short_answer = gr.Number(minimum=0, maximum=100, step=1, label="Short Answer", value=0)
153
+ with gr.Column():
154
+ long_answer = gr.Number(minimum=0, maximum=100, step=1, label="Long Answer", value=0)
155
+
156
+ solution_sheet = gr.Radio(label="Solution Sheet", choices=["Yes", "No"], value="Yes")
157
+ format = gr.Textbox(label="Format", value="JSON")
158
+ extras = gr.Textbox(label="Extras (comma-separated)")
159
+
160
+ submit_button = gr.Button("Invoke Request")
161
+
162
+ output = gr.JSON(label="Request Data")
163
+
164
+ submit_button.click(
165
+ generate_worksheet,
166
+ inputs=[grade, subject, topics, learning_objectives, question_tagging_options,
167
+ number_of_questions, easy, medium, hard, remember, understand, apply, analyze,
168
+ evaluate, create, mcq_single_answer, mcq_multiple_answer, true_false, fill_in_the_blanks,
169
+ match_the_column, very_short_answer, short_answer, long_answer, solution_sheet, format, extras],
170
+ outputs=output
171
+ )
172
+
173
+ return post_page
174
+
175
+ def get_interface():
176
+ with gr.Blocks() as get_page:
177
+
178
+ interface = gr.Interface(
179
+ fn=get_worksheet,
180
+ inputs=gr.Textbox(label="Enter Request ID"),
181
+ outputs="json",
182
+ )
183
+
184
+ return get_page
185
+
186
+ def worksheet_generation():
187
+ gr.Markdown("# Worksheet Generation")
188
+ with gr.Blocks() as worksheet_generation:
189
+ with gr.Tabs():
190
+ with gr.TabItem("POST"):
191
+ post_interface()
192
+ with gr.TabItem("GET"):
193
+ get_interface()
194
+
195
+ return worksheet_generation