vladyslav commited on
Commit
9f10b71
·
1 Parent(s): 834de25

Added 3 new questions for feedback

Browse files
Files changed (2) hide show
  1. app.py +106 -14
  2. utils/db.py +13 -1
app.py CHANGED
@@ -66,6 +66,9 @@ def get_next_question(selected_answer):
66
  gr.update(visible=False), # rating_slider
67
  gr.update(visible=False), # submit_feedback_button
68
  gr.update(visible=False), # rating_text
 
 
 
69
  )
70
 
71
  # Writing answer in log
@@ -87,6 +90,9 @@ def get_next_question(selected_answer):
87
  gr.update(visible=False), # rating_slider
88
  gr.update(visible=False), # submit_feedback_button
89
  gr.update(visible=False), # rating_text
 
 
 
90
  )
91
  else:
92
  # All questions are completed — ask for feedback
@@ -99,19 +105,34 @@ def get_next_question(selected_answer):
99
  gr.update(visible=True), # rating_slider
100
  gr.update(visible=True), # submit_feedback_button
101
  gr.update(visible=True), # rating_text
 
 
 
102
  )
103
 
104
 
105
- def summarize_results(student_name, class_name, model, book, feedback, rating):
 
 
 
 
 
 
 
 
106
  global questions_data, answers_log
107
  questions = []
108
 
109
- if not feedback:
110
  return (
111
  "# Залиште відгук про тест!", # question_output
112
  gr.update(visible=True), # feedback_input
113
  gr.update(visible=True), # rating_slider
114
- gr.update(visible=True) # submit_feedback_button
 
 
 
 
115
  )
116
 
117
  for question, answer in zip(questions_data, answers_log):
@@ -120,7 +141,18 @@ def summarize_results(student_name, class_name, model, book, feedback, rating):
120
  "answer": answer
121
  })
122
 
123
- save_results(student_name, class_name, MODELS[model], book, questions, feedback, rating)
 
 
 
 
 
 
 
 
 
 
 
124
 
125
  correct_answers_count = sum(1 for answer in answers_log if answer['isCorrect'])
126
  total_questions = len(questions_data)
@@ -136,8 +168,12 @@ def summarize_results(student_name, class_name, model, book, feedback, rating):
136
  return (
137
  summary, # question_output
138
  gr.update(visible=False, value=""), # feedback_input
139
- gr.update(visible=False, value=0), # rating_slider
140
- gr.update(visible=False) # submit_feedback_button
 
 
 
 
141
  )
142
 
143
 
@@ -155,8 +191,14 @@ with gr.Blocks() as demo:
155
  answer_radio = gr.Radio([], label="Варіанти відповіді", interactive=True, visible=False)
156
  next_button = gr.Button("Наступне питання", visible=False)
157
 
 
 
 
 
158
  feedback_input = gr.Textbox(label="Ваш відгук про тест", visible=False)
159
- rating_text = gr.Markdown("### Шкала оцінювання:\n\n#### -2 — дуже погано\n\n#### -1 — погано\n\n#### 0 — задовільно\n\n#### 1 — добре\n\n#### 2 — відмінно", visible=False)
 
 
160
  rating_buttons = gr.Radio([-2, -1, 0, 1, 2], label="Оцініть тест", visible=False, interactive=True)
161
  submit_feedback_button = gr.Button("Завершити тест", visible=False)
162
 
@@ -168,28 +210,78 @@ with gr.Blocks() as demo:
168
  question, # question_output
169
  gr.update(choices=answers, interactive=True, visible=is_field_filled), # answer_radio
170
  gr.update(visible=is_field_filled), # next_button
171
- gr.update(visible=False), # feedback_input
172
- gr.update(visible=False), # rating_slider
173
  gr.update(visible=False), # submit_feedback_button
 
 
 
 
174
  )
175
 
176
 
177
  load_button.click(
178
  update_question,
179
- inputs=[model_radio, book_radio, student_name_input, class_name_input],
180
- outputs=[question_output, answer_radio, next_button, feedback_input, rating_buttons, submit_feedback_button]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  )
182
 
183
  next_button.click(
184
  get_next_question,
185
  inputs=[answer_radio],
186
- outputs=[question_output, answer_radio, next_button, feedback_input, rating_buttons, submit_feedback_button, rating_text]
 
 
 
 
 
 
 
 
 
 
 
187
  )
188
 
189
  submit_feedback_button.click(
190
  summarize_results,
191
- inputs=[student_name_input, class_name_input, model_radio, book_radio, feedback_input, rating_buttons],
192
- outputs=[question_output, feedback_input, rating_buttons, submit_feedback_button]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
  )
194
 
195
  if __name__ == "__main__":
 
66
  gr.update(visible=False), # rating_slider
67
  gr.update(visible=False), # submit_feedback_button
68
  gr.update(visible=False), # rating_text
69
+ gr.update(visible=False), # question_correct
70
+ gr.update(visible=False), # text_coverage
71
+ gr.update(visible=False), # interesting_question
72
  )
73
 
74
  # Writing answer in log
 
90
  gr.update(visible=False), # rating_slider
91
  gr.update(visible=False), # submit_feedback_button
92
  gr.update(visible=False), # rating_text
93
+ gr.update(visible=False), # question_correct
94
+ gr.update(visible=False), # text_coverage
95
+ gr.update(visible=False), # interesting_question
96
  )
97
  else:
98
  # All questions are completed — ask for feedback
 
105
  gr.update(visible=True), # rating_slider
106
  gr.update(visible=True), # submit_feedback_button
107
  gr.update(visible=True), # rating_text
108
+ gr.update(visible=True), # question_correct
109
+ gr.update(visible=True), # text_coverage
110
+ gr.update(visible=True), # interesting_question
111
  )
112
 
113
 
114
+ def summarize_results(student_name,
115
+ class_name,
116
+ model,
117
+ book,
118
+ feedback,
119
+ rating,
120
+ question_correct,
121
+ text_coverage,
122
+ interesting_question):
123
  global questions_data, answers_log
124
  questions = []
125
 
126
+ if not feedback or not question_correct or not text_coverage or not interesting_question or not rating:
127
  return (
128
  "# Залиште відгук про тест!", # question_output
129
  gr.update(visible=True), # feedback_input
130
  gr.update(visible=True), # rating_slider
131
+ gr.update(visible=True), # submit_feedback_button
132
+ gr.update(visible=True), # question_correct
133
+ gr.update(visible=True), # text_coverage
134
+ gr.update(visible=True), # interesting_question
135
+ gr.update(visible=True), # rating_text
136
  )
137
 
138
  for question, answer in zip(questions_data, answers_log):
 
141
  "answer": answer
142
  })
143
 
144
+ save_results(
145
+ student_name,
146
+ class_name,
147
+ MODELS[model],
148
+ book,
149
+ questions,
150
+ feedback,
151
+ rating,
152
+ question_correct,
153
+ text_coverage,
154
+ interesting_question
155
+ )
156
 
157
  correct_answers_count = sum(1 for answer in answers_log if answer['isCorrect'])
158
  total_questions = len(questions_data)
 
168
  return (
169
  summary, # question_output
170
  gr.update(visible=False, value=""), # feedback_input
171
+ gr.update(visible=False, value=None), # rating_slider
172
+ gr.update(visible=False), # submit_feedback_button
173
+ gr.update(visible=False, value=""), # question_correct
174
+ gr.update(visible=False, value=""), # text_coverage
175
+ gr.update(visible=False, value=""), # interesting_question
176
+ gr.update(visible=False), # rating_text
177
  )
178
 
179
 
 
191
  answer_radio = gr.Radio([], label="Варіанти відповіді", interactive=True, visible=False)
192
  next_button = gr.Button("Наступне питання", visible=False)
193
 
194
+ question_correct_input = gr.Textbox(label="Чи коректно поставлено запитання і варіанти відповідей?",
195
+ visible=False)
196
+ text_coverage_input = gr.Textbox(label="Рівномірність покриття тексту", visible=False)
197
+ interesting_question_input = gr.Textbox(label="Цікавість запитань", visible=False)
198
  feedback_input = gr.Textbox(label="Ваш відгук про тест", visible=False)
199
+ rating_text = gr.Markdown(
200
+ "### Шкала оцінювання:\n\n#### -2 — дуже погано\n\n#### -1 — п��гано\n\n#### 0 — задовільно\n\n#### 1 — добре\n\n#### 2 — відмінно",
201
+ visible=False)
202
  rating_buttons = gr.Radio([-2, -1, 0, 1, 2], label="Оцініть тест", visible=False, interactive=True)
203
  submit_feedback_button = gr.Button("Завершити тест", visible=False)
204
 
 
210
  question, # question_output
211
  gr.update(choices=answers, interactive=True, visible=is_field_filled), # answer_radio
212
  gr.update(visible=is_field_filled), # next_button
213
+ gr.update(visible=False, value=""), # feedback_input
214
+ gr.update(visible=False, value=None), # rating_buttons
215
  gr.update(visible=False), # submit_feedback_button
216
+ gr.update(visible=False), # rating_text
217
+ gr.update(visible=False, value=""), # question_correct
218
+ gr.update(visible=False, value=""), # text_coverage
219
+ gr.update(visible=False, value=""), # interesting_question
220
  )
221
 
222
 
223
  load_button.click(
224
  update_question,
225
+ inputs=[
226
+ model_radio,
227
+ book_radio,
228
+ student_name_input,
229
+ class_name_input,
230
+ ],
231
+ outputs=[
232
+ question_output,
233
+ answer_radio,
234
+ next_button,
235
+ feedback_input,
236
+ rating_buttons,
237
+ submit_feedback_button,
238
+ rating_text,
239
+ question_correct_input,
240
+ text_coverage_input,
241
+ interesting_question_input,
242
+ ]
243
  )
244
 
245
  next_button.click(
246
  get_next_question,
247
  inputs=[answer_radio],
248
+ outputs=[
249
+ question_output,
250
+ answer_radio,
251
+ next_button,
252
+ feedback_input,
253
+ rating_buttons,
254
+ submit_feedback_button,
255
+ rating_text,
256
+ question_correct_input,
257
+ text_coverage_input,
258
+ interesting_question_input,
259
+ ]
260
  )
261
 
262
  submit_feedback_button.click(
263
  summarize_results,
264
+ inputs=[
265
+ student_name_input,
266
+ class_name_input,
267
+ model_radio,
268
+ book_radio,
269
+ feedback_input,
270
+ rating_buttons,
271
+ question_correct_input,
272
+ text_coverage_input,
273
+ interesting_question_input,
274
+ ],
275
+ outputs=[
276
+ question_output,
277
+ feedback_input,
278
+ rating_buttons,
279
+ submit_feedback_button,
280
+ question_correct_input,
281
+ text_coverage_input,
282
+ interesting_question_input,
283
+ rating_text,
284
+ ]
285
  )
286
 
287
  if __name__ == "__main__":
utils/db.py CHANGED
@@ -24,7 +24,16 @@ collection = db[collection_name]
24
  print("Using collection:", collection_name)
25
 
26
 
27
- def save_results(student_name, class_name, model, book, questions, feedback, rating):
 
 
 
 
 
 
 
 
 
28
  print("Saving results")
29
  collection.insert_one({
30
  "student_name": student_name,
@@ -32,6 +41,9 @@ def save_results(student_name, class_name, model, book, questions, feedback, rat
32
  "model": model,
33
  "book": book,
34
  "questions": questions,
 
 
 
35
  "feedback": feedback,
36
  "rating": rating,
37
  "created_at": db.command("serverStatus")["localTime"]
 
24
  print("Using collection:", collection_name)
25
 
26
 
27
+ def save_results(student_name,
28
+ class_name,
29
+ model,
30
+ book,
31
+ questions,
32
+ feedback,
33
+ rating,
34
+ question_correct,
35
+ text_coverage,
36
+ interesting_question):
37
  print("Saving results")
38
  collection.insert_one({
39
  "student_name": student_name,
 
41
  "model": model,
42
  "book": book,
43
  "questions": questions,
44
+ "question_correct": question_correct,
45
+ "text_coverage": text_coverage,
46
+ "interesting_question": interesting_question,
47
  "feedback": feedback,
48
  "rating": rating,
49
  "created_at": db.command("serverStatus")["localTime"]