vladyslav
commited on
Commit
·
560d420
1
Parent(s):
bd5fe79
Fixed bug with removing model from choices list after passing the test
Browse files
app.py
CHANGED
@@ -20,6 +20,7 @@ questions_data = []
|
|
20 |
current_question_index = 0
|
21 |
answers_log = [] # Log for saving answers
|
22 |
feedback_questions = ""
|
|
|
23 |
|
24 |
|
25 |
def get_question():
|
@@ -122,7 +123,7 @@ def summarize_results(student_name,
|
|
122 |
question_correct,
|
123 |
answers_correct,
|
124 |
interesting_question):
|
125 |
-
global questions_data, answers_log, feedback_questions
|
126 |
questions = []
|
127 |
|
128 |
if question_correct is None or answers_correct is None or interesting_question is None:
|
@@ -169,9 +170,8 @@ def summarize_results(student_name,
|
|
169 |
f"#### Оцінка за 12-бальною шкалою: {grade_12:.2f}.\n\n"
|
170 |
)
|
171 |
|
172 |
-
models_list = list(MODELS.keys())
|
173 |
if student_name != "Вчитель":
|
174 |
-
|
175 |
|
176 |
return (
|
177 |
summary, # question_output
|
@@ -183,7 +183,7 @@ def summarize_results(student_name,
|
|
183 |
gr.update(visible=False), # rating_text
|
184 |
gr.update(visible=False, value=""), # feedback_questions_output
|
185 |
gr.update(visible=False), # feedback_not_provided
|
186 |
-
gr.update(choices=
|
187 |
)
|
188 |
|
189 |
|
@@ -264,6 +264,8 @@ def handle_student_name_change(student_name):
|
|
264 |
|
265 |
|
266 |
def filter_models(student_name, class_name, book):
|
|
|
|
|
267 |
print('filter_models')
|
268 |
if not book:
|
269 |
return (
|
@@ -298,22 +300,24 @@ def filter_models(student_name, class_name, book):
|
|
298 |
)
|
299 |
|
300 |
tests = get_test_by_student_class_book(student_name, class_name, book)
|
301 |
-
|
302 |
|
303 |
for test in tests:
|
304 |
-
if test.get("model") in
|
305 |
-
|
306 |
|
307 |
-
print("Available models (before update):",
|
308 |
|
309 |
-
if not
|
310 |
return gr.update(choices=[], label="Немає доступних моделей", value=None, visible=True)
|
311 |
|
312 |
models_list = []
|
313 |
|
314 |
-
for model in list(
|
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
|
@@ -329,6 +333,7 @@ def filter_models(student_name, class_name, book):
|
|
329 |
gr.update(visible=False), # submit_feedback_button
|
330 |
)
|
331 |
|
|
|
332 |
def handle_model_change(model):
|
333 |
print(model)
|
334 |
print("handle_model_change")
|
@@ -361,6 +366,7 @@ def handle_model_change(model):
|
|
361 |
gr.update(visible=False), # submit_feedback_button
|
362 |
)
|
363 |
|
|
|
364 |
with gr.Blocks() as demo:
|
365 |
with gr.Column():
|
366 |
gr.Markdown("## Оберіть модель та книгу, щоб завантажити питання")
|
|
|
20 |
current_question_index = 0
|
21 |
answers_log = [] # Log for saving answers
|
22 |
feedback_questions = ""
|
23 |
+
available_models = []
|
24 |
|
25 |
|
26 |
def get_question():
|
|
|
123 |
question_correct,
|
124 |
answers_correct,
|
125 |
interesting_question):
|
126 |
+
global questions_data, answers_log, feedback_questions, available_models
|
127 |
questions = []
|
128 |
|
129 |
if question_correct is None or answers_correct is None or interesting_question is None:
|
|
|
170 |
f"#### Оцінка за 12-бальною шкалою: {grade_12:.2f}.\n\n"
|
171 |
)
|
172 |
|
|
|
173 |
if student_name != "Вчитель":
|
174 |
+
available_models.remove(model)
|
175 |
|
176 |
return (
|
177 |
summary, # question_output
|
|
|
183 |
gr.update(visible=False), # rating_text
|
184 |
gr.update(visible=False, value=""), # feedback_questions_output
|
185 |
gr.update(visible=False), # feedback_not_provided
|
186 |
+
gr.update(choices=available_models, value=None, visible=True), # model_radio
|
187 |
)
|
188 |
|
189 |
|
|
|
264 |
|
265 |
|
266 |
def filter_models(student_name, class_name, book):
|
267 |
+
global available_models
|
268 |
+
|
269 |
print('filter_models')
|
270 |
if not book:
|
271 |
return (
|
|
|
300 |
)
|
301 |
|
302 |
tests = get_test_by_student_class_book(student_name, class_name, book)
|
303 |
+
available_models_names = list(MODELS.values())
|
304 |
|
305 |
for test in tests:
|
306 |
+
if test.get("model") in available_models_names:
|
307 |
+
available_models_names.remove(test.get("model"))
|
308 |
|
309 |
+
print("Available models (before update):", available_models_names)
|
310 |
|
311 |
+
if not available_models_names:
|
312 |
return gr.update(choices=[], label="Немає доступних моделей", value=None, visible=True)
|
313 |
|
314 |
models_list = []
|
315 |
|
316 |
+
for model in list(available_models_names):
|
317 |
models_list.append(MODEL_NAME_TO_CHOICE.get(model))
|
318 |
|
319 |
+
available_models = models_list
|
320 |
+
|
321 |
return (
|
322 |
gr.update(choices=models_list, value=None, visible=True),
|
323 |
gr.update(value=""), # questions_output
|
|
|
333 |
gr.update(visible=False), # submit_feedback_button
|
334 |
)
|
335 |
|
336 |
+
|
337 |
def handle_model_change(model):
|
338 |
print(model)
|
339 |
print("handle_model_change")
|
|
|
366 |
gr.update(visible=False), # submit_feedback_button
|
367 |
)
|
368 |
|
369 |
+
|
370 |
with gr.Blocks() as demo:
|
371 |
with gr.Column():
|
372 |
gr.Markdown("## Оберіть модель та книгу, щоб завантажити питання")
|