Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -71,8 +71,10 @@ style_count_map = {
|
|
71 |
# Quiz logic to analyze learning style
|
72 |
def learning_style_quiz(*answers):
|
73 |
scores = {'visual': 0, 'auditory': 0, 'reading/writing': 0}
|
74 |
-
for ans in answers:
|
75 |
-
|
|
|
|
|
76 |
best = max(scores, key=scores.get)
|
77 |
return best.capitalize()
|
78 |
|
@@ -117,10 +119,9 @@ def save_profile(file, *inputs):
|
|
117 |
if any(ans is None for ans in quiz_answers):
|
118 |
return "⚠️ Please answer all the learning style questions."
|
119 |
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
category_answers = inputs[len(learning_style_questions)+3:]
|
124 |
|
125 |
if any(ans.strip() == "" for ans in category_answers):
|
126 |
return "⚠️ Please complete all 'Get to Know You' sections before saving."
|
@@ -139,7 +140,6 @@ def save_profile(file, *inputs):
|
|
139 |
"transcript": df.to_dict(orient='records'),
|
140 |
"transcript_info": transcript_info,
|
141 |
"learning_style": learning_type,
|
142 |
-
"about_me": about_me,
|
143 |
"get_to_know_answers": responses,
|
144 |
"blog": blog_text
|
145 |
}
|
@@ -161,28 +161,26 @@ with gr.Blocks() as demo:
|
|
161 |
quiz_components = []
|
162 |
for i, (question, options) in enumerate(zip(learning_style_questions, learning_style_answers)):
|
163 |
quiz_components.append(gr.Radio(
|
164 |
-
choices=
|
165 |
label=f"{i+1}. {question}"
|
166 |
))
|
167 |
|
168 |
-
with gr.Column():
|
169 |
-
gr.Markdown("### ❤️ About You")
|
170 |
-
about_me = gr.Textbox(lines=6, label="About Me")
|
171 |
-
blog_opt_in = gr.Checkbox(label="I want to write a personal blog for better personalization")
|
172 |
-
blog_text = gr.Textbox(lines=5, label="✍️ Optional: Write a mini blog about your life", visible=True)
|
173 |
-
|
174 |
category_inputs = []
|
175 |
for category, questions in get_to_know_categories.items():
|
176 |
gr.Markdown(f"### 📘 {category}")
|
177 |
for q_text, _ in questions:
|
178 |
category_inputs.append(gr.Textbox(label=q_text))
|
179 |
|
|
|
|
|
|
|
180 |
submit = gr.Button("📥 Save My Profile")
|
181 |
output = gr.Textbox(label="Status")
|
182 |
|
183 |
submit.click(fn=save_profile,
|
184 |
-
inputs=[file, *quiz_components,
|
185 |
outputs=[output])
|
186 |
|
187 |
if __name__ == '__main__':
|
188 |
demo.launch()
|
|
|
|
71 |
# Quiz logic to analyze learning style
|
72 |
def learning_style_quiz(*answers):
|
73 |
scores = {'visual': 0, 'auditory': 0, 'reading/writing': 0}
|
74 |
+
for i, ans in enumerate(answers):
|
75 |
+
idx = learning_style_answers[i].index(ans) if ans in learning_style_answers[i] else None
|
76 |
+
if idx is not None:
|
77 |
+
scores[style_count_map[idx]] += 1
|
78 |
best = max(scores, key=scores.get)
|
79 |
return best.capitalize()
|
80 |
|
|
|
119 |
if any(ans is None for ans in quiz_answers):
|
120 |
return "⚠️ Please answer all the learning style questions."
|
121 |
|
122 |
+
blog_opt_in = inputs[len(learning_style_questions)]
|
123 |
+
blog_text = inputs[len(learning_style_questions)+1]
|
124 |
+
category_answers = inputs[len(learning_style_questions)+2:]
|
|
|
125 |
|
126 |
if any(ans.strip() == "" for ans in category_answers):
|
127 |
return "⚠️ Please complete all 'Get to Know You' sections before saving."
|
|
|
140 |
"transcript": df.to_dict(orient='records'),
|
141 |
"transcript_info": transcript_info,
|
142 |
"learning_style": learning_type,
|
|
|
143 |
"get_to_know_answers": responses,
|
144 |
"blog": blog_text
|
145 |
}
|
|
|
161 |
quiz_components = []
|
162 |
for i, (question, options) in enumerate(zip(learning_style_questions, learning_style_answers)):
|
163 |
quiz_components.append(gr.Radio(
|
164 |
+
choices=options,
|
165 |
label=f"{i+1}. {question}"
|
166 |
))
|
167 |
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
category_inputs = []
|
169 |
for category, questions in get_to_know_categories.items():
|
170 |
gr.Markdown(f"### 📘 {category}")
|
171 |
for q_text, _ in questions:
|
172 |
category_inputs.append(gr.Textbox(label=q_text))
|
173 |
|
174 |
+
blog_opt_in = gr.Checkbox(label="I want to write a personal blog for better personalization")
|
175 |
+
blog_text = gr.Textbox(lines=5, label="✍️ Optional: Write a mini blog about your life", visible=True)
|
176 |
+
|
177 |
submit = gr.Button("📥 Save My Profile")
|
178 |
output = gr.Textbox(label="Status")
|
179 |
|
180 |
submit.click(fn=save_profile,
|
181 |
+
inputs=[file, *quiz_components, blog_opt_in, blog_text, *category_inputs],
|
182 |
outputs=[output])
|
183 |
|
184 |
if __name__ == '__main__':
|
185 |
demo.launch()
|
186 |
+
|