vladyslav
commited on
Commit
·
bd5fe79
1
Parent(s):
9e9dcef
Reseting fields when config is changed
Browse files
app.py
CHANGED
@@ -213,6 +213,17 @@ def update_students(class_name):
|
|
213 |
gr.update(choices=students, value=None, visible=True), # student_name_input
|
214 |
gr.update(choices=[], value=None, visible=False), # book_radio
|
215 |
gr.update(choices=[], value=None, visible=False), # model_radio
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
)
|
217 |
|
218 |
|
@@ -222,21 +233,69 @@ def handle_student_name_change(student_name):
|
|
222 |
return (
|
223 |
gr.update(choices=[], value=None, visible=False), # book_radio
|
224 |
gr.update(choices=[], value=None, visible=False), # model_radio
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
)
|
226 |
|
227 |
return (
|
228 |
gr.update(choices=list(BOOKS.keys()), value=None, visible=True), # book_radio
|
229 |
gr.update(choices=[], value=None, visible=False), # model_radio
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
)
|
231 |
|
232 |
|
233 |
def filter_models(student_name, class_name, book):
|
234 |
print('filter_models')
|
235 |
if not book:
|
236 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
237 |
|
238 |
if student_name == "Вчитель":
|
239 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
|
241 |
tests = get_test_by_student_class_book(student_name, class_name, book)
|
242 |
available_models = list(MODELS.values())
|
@@ -255,8 +314,52 @@ def filter_models(student_name, class_name, book):
|
|
255 |
for model in list(available_models):
|
256 |
models_list.append(MODEL_NAME_TO_CHOICE.get(model))
|
257 |
|
258 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
259 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
260 |
|
261 |
with gr.Blocks() as demo:
|
262 |
with gr.Column():
|
@@ -295,6 +398,17 @@ with gr.Blocks() as demo:
|
|
295 |
student_name_input,
|
296 |
book_radio,
|
297 |
model_radio,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
298 |
]
|
299 |
)
|
300 |
|
@@ -306,6 +420,17 @@ with gr.Blocks() as demo:
|
|
306 |
outputs=[
|
307 |
book_radio,
|
308 |
model_radio,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
309 |
]
|
310 |
)
|
311 |
|
@@ -318,6 +443,37 @@ with gr.Blocks() as demo:
|
|
318 |
],
|
319 |
outputs=[
|
320 |
model_radio,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
321 |
]
|
322 |
)
|
323 |
|
|
|
213 |
gr.update(choices=students, value=None, visible=True), # student_name_input
|
214 |
gr.update(choices=[], value=None, visible=False), # book_radio
|
215 |
gr.update(choices=[], value=None, visible=False), # model_radio
|
216 |
+
gr.update(value=""), # questions_output
|
217 |
+
gr.update(choices=[], value=None, visible=False), # answer_radio
|
218 |
+
gr.update(visible=False), # next_button
|
219 |
+
gr.update(value="", visible=False), # feedback_questions_output
|
220 |
+
gr.update(visible=False), # rating_text
|
221 |
+
gr.update(visible=False), # feedback_not_provided
|
222 |
+
gr.update(value=None, visible=False), # question_correct_radio
|
223 |
+
gr.update(value=None, visible=False), # answers_correct_radio
|
224 |
+
gr.update(value=None, visible=False), # interesting_question_radio
|
225 |
+
gr.update(value="", visible=False), # feedback_input
|
226 |
+
gr.update(visible=False), # submit_feedback_button
|
227 |
)
|
228 |
|
229 |
|
|
|
233 |
return (
|
234 |
gr.update(choices=[], value=None, visible=False), # book_radio
|
235 |
gr.update(choices=[], value=None, visible=False), # model_radio
|
236 |
+
gr.update(value=""), # questions_output
|
237 |
+
gr.update(choices=[], value=None, visible=False), # answer_radio
|
238 |
+
gr.update(visible=False), # next_button
|
239 |
+
gr.update(value="", visible=False), # feedback_questions_output
|
240 |
+
gr.update(visible=False), # rating_text
|
241 |
+
gr.update(visible=False), # feedback_not_provided
|
242 |
+
gr.update(value=None, visible=False), # question_correct_radio
|
243 |
+
gr.update(value=None, visible=False), # answers_correct_radio
|
244 |
+
gr.update(value=None, visible=False), # interesting_question_radio
|
245 |
+
gr.update(value="", visible=False), # feedback_input
|
246 |
+
gr.update(visible=False), # submit_feedback_button
|
247 |
)
|
248 |
|
249 |
return (
|
250 |
gr.update(choices=list(BOOKS.keys()), value=None, visible=True), # book_radio
|
251 |
gr.update(choices=[], value=None, visible=False), # model_radio
|
252 |
+
gr.update(value=""), # questions_output
|
253 |
+
gr.update(choices=[], value=None, visible=False), # answer_radio
|
254 |
+
gr.update(visible=False), # next_button
|
255 |
+
gr.update(value="", visible=False), # feedback_questions_output
|
256 |
+
gr.update(visible=False), # rating_text
|
257 |
+
gr.update(visible=False), # feedback_not_provided
|
258 |
+
gr.update(value=None, visible=False), # question_correct_radio
|
259 |
+
gr.update(value=None, visible=False), # answers_correct_radio
|
260 |
+
gr.update(value=None, visible=False), # interesting_question_radio
|
261 |
+
gr.update(value="", visible=False), # feedback_input
|
262 |
+
gr.update(visible=False), # submit_feedback_button
|
263 |
)
|
264 |
|
265 |
|
266 |
def filter_models(student_name, class_name, book):
|
267 |
print('filter_models')
|
268 |
if not book:
|
269 |
+
return (
|
270 |
+
gr.update(choices=[], value=None, visible=False),
|
271 |
+
gr.update(value=""), # questions_output
|
272 |
+
gr.update(choices=[], value=None, visible=False), # answer_radio
|
273 |
+
gr.update(visible=False), # next_button
|
274 |
+
gr.update(value="", visible=False), # feedback_questions_output
|
275 |
+
gr.update(visible=False), # rating_text
|
276 |
+
gr.update(visible=False), # feedback_not_provided
|
277 |
+
gr.update(value=None, visible=False), # question_correct_radio
|
278 |
+
gr.update(value=None, visible=False), # answers_correct_radio
|
279 |
+
gr.update(value=None, visible=False), # interesting_question_radio
|
280 |
+
gr.update(value="", visible=False), # feedback_input
|
281 |
+
gr.update(visible=False), # submit_feedback_button
|
282 |
+
)
|
283 |
|
284 |
if student_name == "Вчитель":
|
285 |
+
return (
|
286 |
+
gr.update(choices=MODELS.keys(), value=None, visible=True),
|
287 |
+
gr.update(value=""), # questions_output
|
288 |
+
gr.update(choices=[], value=None, visible=False), # answer_radio
|
289 |
+
gr.update(visible=False), # next_button
|
290 |
+
gr.update(value="", visible=False), # feedback_questions_output
|
291 |
+
gr.update(visible=False), # rating_text
|
292 |
+
gr.update(visible=False), # feedback_not_provided
|
293 |
+
gr.update(value=None, visible=False), # question_correct_radio
|
294 |
+
gr.update(value=None, visible=False), # answers_correct_radio
|
295 |
+
gr.update(value=None, visible=False), # interesting_question_radio
|
296 |
+
gr.update(value="", visible=False), # feedback_input
|
297 |
+
gr.update(visible=False), # submit_feedback_button
|
298 |
+
)
|
299 |
|
300 |
tests = get_test_by_student_class_book(student_name, class_name, book)
|
301 |
available_models = list(MODELS.values())
|
|
|
314 |
for model in list(available_models):
|
315 |
models_list.append(MODEL_NAME_TO_CHOICE.get(model))
|
316 |
|
317 |
+
return (
|
318 |
+
gr.update(choices=models_list, value=None, visible=True),
|
319 |
+
gr.update(value=""), # questions_output
|
320 |
+
gr.update(choices=[], value=None, visible=False), # answer_radio
|
321 |
+
gr.update(visible=False), # next_button
|
322 |
+
gr.update(value="", visible=False), # feedback_questions_output
|
323 |
+
gr.update(visible=False), # rating_text
|
324 |
+
gr.update(visible=False), # feedback_not_provided
|
325 |
+
gr.update(value=None, visible=False), # question_correct_radio
|
326 |
+
gr.update(value=None, visible=False), # answers_correct_radio
|
327 |
+
gr.update(value=None, visible=False), # interesting_question_radio
|
328 |
+
gr.update(value="", visible=False), # feedback_input
|
329 |
+
gr.update(visible=False), # submit_feedback_button
|
330 |
+
)
|
331 |
|
332 |
+
def handle_model_change(model):
|
333 |
+
print(model)
|
334 |
+
print("handle_model_change")
|
335 |
+
if model is not None:
|
336 |
+
return (
|
337 |
+
gr.update(value=""), # questions_output
|
338 |
+
gr.update(choices=[], value=None, visible=False), # answer_radio
|
339 |
+
gr.update(visible=False), # next_button
|
340 |
+
gr.update(value="", visible=False), # feedback_questions_output
|
341 |
+
gr.update(visible=False), # rating_text
|
342 |
+
gr.update(visible=False), # feedback_not_provided
|
343 |
+
gr.update(value=None, visible=False), # question_correct_radio
|
344 |
+
gr.update(value=None, visible=False), # answers_correct_radio
|
345 |
+
gr.update(value=None, visible=False), # interesting_question_radio
|
346 |
+
gr.update(value="", visible=False), # feedback_input
|
347 |
+
gr.update(visible=False), # submit_feedback_button
|
348 |
+
)
|
349 |
+
|
350 |
+
return (
|
351 |
+
gr.update(visible=True), # questions_output
|
352 |
+
gr.update(choices=[], value=None, visible=False), # answer_radio
|
353 |
+
gr.update(visible=False), # next_button
|
354 |
+
gr.update(value="", visible=False), # feedback_questions_output
|
355 |
+
gr.update(visible=False), # rating_text
|
356 |
+
gr.update(visible=False), # feedback_not_provided
|
357 |
+
gr.update(value=None, visible=False), # question_correct_radio
|
358 |
+
gr.update(value=None, visible=False), # answers_correct_radio
|
359 |
+
gr.update(value=None, visible=False), # interesting_question_radio
|
360 |
+
gr.update(value="", visible=False), # feedback_input
|
361 |
+
gr.update(visible=False), # submit_feedback_button
|
362 |
+
)
|
363 |
|
364 |
with gr.Blocks() as demo:
|
365 |
with gr.Column():
|
|
|
398 |
student_name_input,
|
399 |
book_radio,
|
400 |
model_radio,
|
401 |
+
question_output,
|
402 |
+
answer_radio,
|
403 |
+
next_button,
|
404 |
+
feedback_questions_output,
|
405 |
+
rating_text,
|
406 |
+
feedback_not_provided,
|
407 |
+
question_correct_radio,
|
408 |
+
answers_correct_radio,
|
409 |
+
interesting_question_radio,
|
410 |
+
feedback_input,
|
411 |
+
submit_feedback_button,
|
412 |
]
|
413 |
)
|
414 |
|
|
|
420 |
outputs=[
|
421 |
book_radio,
|
422 |
model_radio,
|
423 |
+
question_output,
|
424 |
+
answer_radio,
|
425 |
+
next_button,
|
426 |
+
feedback_questions_output,
|
427 |
+
rating_text,
|
428 |
+
feedback_not_provided,
|
429 |
+
question_correct_radio,
|
430 |
+
answers_correct_radio,
|
431 |
+
interesting_question_radio,
|
432 |
+
feedback_input,
|
433 |
+
submit_feedback_button,
|
434 |
]
|
435 |
)
|
436 |
|
|
|
443 |
],
|
444 |
outputs=[
|
445 |
model_radio,
|
446 |
+
question_output,
|
447 |
+
answer_radio,
|
448 |
+
next_button,
|
449 |
+
feedback_questions_output,
|
450 |
+
rating_text,
|
451 |
+
feedback_not_provided,
|
452 |
+
question_correct_radio,
|
453 |
+
answers_correct_radio,
|
454 |
+
interesting_question_radio,
|
455 |
+
feedback_input,
|
456 |
+
submit_feedback_button,
|
457 |
+
]
|
458 |
+
)
|
459 |
+
|
460 |
+
model_radio.change(
|
461 |
+
handle_model_change,
|
462 |
+
inputs=[
|
463 |
+
model_radio
|
464 |
+
],
|
465 |
+
outputs=[
|
466 |
+
question_output,
|
467 |
+
answer_radio,
|
468 |
+
next_button,
|
469 |
+
feedback_questions_output,
|
470 |
+
rating_text,
|
471 |
+
feedback_not_provided,
|
472 |
+
question_correct_radio,
|
473 |
+
answers_correct_radio,
|
474 |
+
interesting_question_radio,
|
475 |
+
feedback_input,
|
476 |
+
submit_feedback_button,
|
477 |
]
|
478 |
)
|
479 |
|