File size: 15,298 Bytes
f51c1fd
 
78f883e
f51c1fd
 
 
 
 
 
 
1bf4da3
f612514
f51c1fd
 
 
13aeb09
f51c1fd
f612514
42c4f80
f51c1fd
 
 
 
d0f716d
 
c0f084a
d0f716d
 
 
aa2aec1
f51c1fd
 
 
aa6222e
 
42c4f80
 
f612514
 
 
42c4f80
 
 
 
 
 
c0f084a
d0f716d
 
aa2aec1
1bf4da3
 
aa2aec1
 
0e30f40
 
 
 
 
 
c0f084a
 
 
 
 
 
 
 
 
d0f716d
 
 
aa2aec1
 
b0f25b3
 
1bf4da3
 
 
78f883e
aa2aec1
78f883e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d0f716d
1bf4da3
 
 
b4828f0
78f883e
 
1bf4da3
f51c1fd
 
1bf4da3
 
f612514
 
 
 
 
 
 
 
 
 
aa6222e
 
 
 
 
 
 
 
 
 
f612514
 
13aeb09
 
 
 
 
52d84c5
 
 
f612514
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
aa6222e
1bf4da3
 
f51c1fd
 
d6b712b
f51c1fd
 
 
 
 
13aeb09
 
 
 
 
 
 
f51c1fd
 
 
f612514
 
 
 
 
 
 
f51c1fd
 
 
f612514
b0f25b3
 
 
 
c0f084a
b0f25b3
 
 
 
aa2aec1
1bf4da3
 
aa2aec1
 
0e30f40
 
 
 
 
 
c0f084a
 
 
 
 
 
 
 
 
b0f25b3
aa2aec1
 
b0f25b3
 
1bf4da3
 
 
78f883e
aa2aec1
78f883e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b0f25b3
 
42c4f80
 
 
 
f612514
42c4f80
f612514
42c4f80
f612514
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42c4f80
f51c1fd
 
 
 
f612514
f51c1fd
 
 
f612514
f51c1fd
 
 
 
42c4f80
c0f084a
d0f716d
 
 
 
aa2aec1
1bf4da3
 
aa2aec1
 
0e30f40
 
 
 
 
 
c0f084a
 
 
 
 
 
 
 
 
aa2aec1
 
b0f25b3
 
1bf4da3
 
 
78f883e
aa2aec1
78f883e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d0f716d
 
 
 
 
 
f612514
d0f716d
 
 
 
 
 
aa2aec1
 
 
1bf4da3
 
aa2aec1
 
0e30f40
 
 
 
 
 
c0f084a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
aa2aec1
d0f716d
 
 
 
aa2aec1
f612514
aa2aec1
f612514
aa2aec1
 
1bf4da3
 
aa2aec1
 
0e30f40
 
 
 
 
 
c0f084a
 
 
 
 
 
 
 
aa2aec1
d0f716d
aa2aec1
 
b0f25b3
 
1bf4da3
 
 
78f883e
aa2aec1
78f883e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d0f716d
f51c1fd
 
 
aa2aec1
 
 
78f883e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
aa2aec1
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
"""
File: event_handlers.py
Author: Elena Ryumina and Dmitry Ryumin
Description: File containing functions for configuring event handlers for Gradio components.
License: MIT License
"""

import gradio as gr

# Importing necessary components for the Gradio app
from app.event_handlers.languages import event_handler_languages
from app.event_handlers.switching_modes import event_handler_switching_modes
from app.event_handlers.files import (
    event_handler_files,
    event_handler_files_select,
    event_handler_files_delete,
)
from app.event_handlers.webcam import event_handler_webcam
from app.event_handlers.examples_blocks import event_handler_examples_blocks
from app.event_handlers.clear_blocks import event_handler_clear_blocks
from app.event_handlers.calculate_pt_scores_blocks import (
    event_handler_calculate_pt_scores_blocks,
)
from app.event_handlers.practical_tasks import event_handler_practical_tasks
from app.event_handlers.practical_subtasks import event_handler_practical_subtasks
from app.event_handlers.dropdown_candidates import event_handler_dropdown_candidates
from app.event_handlers.calculate_practical_tasks import (
    event_handler_calculate_practical_task_blocks,
)
from app.event_handlers.practical_task_sorted import event_handler_practical_task_sorted


def setup_app_event_handlers(
    description,
    step_1,
    notifications,
    files,
    webcam,
    switching_modes,
    type_modes,
    video,
    examples,
    calculate_pt_scores,
    clear_app,
    pt_scores,
    csv_pt_scores,
    step_2,
    practical_tasks,
    practical_subtasks,
    settings_practical_tasks,
    dropdown_mbti,
    threshold_mbti,
    threshold_professional_skills,
    dropdown_professional_skills,
    target_score_ope,
    target_score_con,
    target_score_ext,
    target_score_agr,
    target_score_nneu,
    equal_coefficient,
    number_priority,
    number_importance_traits,
    threshold_consumer_preferences,
    dropdown_candidates,
    number_openness,
    number_conscientiousness,
    number_extraversion,
    number_agreeableness,
    number_non_neuroticism,
    calculate_practical_task,
    practical_subtasks_selected,
    practical_tasks_column,
    sorted_videos,
    sorted_videos_column,
    practical_task_sorted,
    csv_practical_task_sorted,
    mbti_accordion,
    mbti_description,
    mbti_description_data,
    video_sorted_column,
    video_sorted,
    metadata,
    metadata_1,
    name_row,
    name_logo,
    name,
    surname_row,
    surname_logo,
    surname,
    metadata_2,
    email_row,
    email_logo,
    email,
    phone_row,
    phone_logo,
    phone,
    in_development,
    tab1,
    tab2,
    tab3,
    tab4,
    languages_row,
    country_flags,
    languages,
):
    # Events
    languages.select(
        fn=event_handler_languages,
        inputs=[
            languages,
            files,
            video,
            type_modes,
            pt_scores,
            csv_pt_scores,
            practical_tasks,
            practical_subtasks,
        ],
        outputs=[
            description,
            step_1,
            country_flags,
            languages,
            tab1,
            tab2,
            tab3,
            tab4,
            files,
            webcam,
            switching_modes,
            video,
            examples,
            calculate_pt_scores,
            clear_app,
            notifications,
            pt_scores,
            csv_pt_scores,
            step_2,
            practical_tasks_column,
            practical_tasks,
            practical_subtasks,
        ],
        queue=True,
    )
    switching_modes.click(
        fn=event_handler_switching_modes,
        inputs=[languages, type_modes],
        outputs=[
            notifications,
            files,
            webcam,
            switching_modes,
            type_modes,
            video,
            calculate_pt_scores,
            clear_app,
            pt_scores,
            csv_pt_scores,
            step_2,
            practical_tasks_column,
            practical_tasks,
            practical_subtasks,
            practical_subtasks_selected,
            settings_practical_tasks,
            dropdown_mbti,
            threshold_mbti,
            threshold_professional_skills,
            dropdown_professional_skills,
            target_score_ope,
            target_score_con,
            target_score_ext,
            target_score_agr,
            target_score_nneu,
            equal_coefficient,
            number_priority,
            number_importance_traits,
            threshold_consumer_preferences,
            dropdown_candidates,
            number_openness,
            number_conscientiousness,
            number_extraversion,
            number_agreeableness,
            number_non_neuroticism,
            sorted_videos,
            sorted_videos_column,
            practical_task_sorted,
            csv_practical_task_sorted,
            mbti_accordion,
            mbti_description,
            mbti_description_data,
            video_sorted_column,
            video_sorted,
            metadata,
            metadata_1,
            name_row,
            name_logo,
            name,
            surname_row,
            surname_logo,
            surname,
            metadata_2,
            email_row,
            email_logo,
            email,
            phone_row,
            phone_logo,
            phone,
            in_development,
        ],
        queue=True,
    )
    files.change(
        event_handler_files,
        [languages, files, video, pt_scores],
        [notifications, video, calculate_pt_scores, clear_app],
        queue=True,
    )
    files.select(
        event_handler_files_select,
        [languages, files],
        [video],
        queue=True,
    )
    files.delete(
        event_handler_files_delete,
        [languages, files, video],
        [video],
        queue=True,
    )
    gr.on(
        triggers=[webcam.upload, webcam.stop_recording],
        fn=event_handler_webcam,
        inputs=[languages, webcam, pt_scores],
        outputs=[notifications, video, webcam, calculate_pt_scores, clear_app],
        queue=True,
    )
    gr.on(
        triggers=[calculate_pt_scores.click],
        fn=event_handler_calculate_pt_scores_blocks,
        inputs=[languages, type_modes, files, video],
        outputs=[
            notifications,
            pt_scores,
            csv_pt_scores,
            step_2,
            practical_tasks_column,
            practical_tasks,
            practical_subtasks,
            practical_subtasks_selected,
            settings_practical_tasks,
            dropdown_mbti,
            threshold_mbti,
            threshold_professional_skills,
            dropdown_professional_skills,
            target_score_ope,
            target_score_con,
            target_score_ext,
            target_score_agr,
            target_score_nneu,
            equal_coefficient,
            number_priority,
            number_importance_traits,
            threshold_consumer_preferences,
            dropdown_candidates,
            number_openness,
            number_conscientiousness,
            number_extraversion,
            number_agreeableness,
            number_non_neuroticism,
            calculate_practical_task,
            sorted_videos,
            sorted_videos_column,
            practical_task_sorted,
            csv_practical_task_sorted,
            mbti_accordion,
            mbti_description,
            mbti_description_data,
            video_sorted_column,
            video_sorted,
            metadata,
            metadata_1,
            name_row,
            name_logo,
            name,
            surname_row,
            surname_logo,
            surname,
            metadata_2,
            email_row,
            email_logo,
            email,
            phone_row,
            phone_logo,
            phone,
            in_development,
        ],
        queue=True,
    )
    examples.click(
        fn=event_handler_examples_blocks,
        inputs=[languages],
        outputs=[
            notifications,
            files,
            webcam,
            switching_modes,
            type_modes,
            video,
            calculate_pt_scores,
            clear_app,
            pt_scores,
            csv_pt_scores,
            step_2,
            practical_tasks_column,
            practical_tasks,
            practical_subtasks,
            practical_subtasks_selected,
            settings_practical_tasks,
            dropdown_mbti,
            threshold_mbti,
            threshold_professional_skills,
            dropdown_professional_skills,
            target_score_ope,
            target_score_con,
            target_score_ext,
            target_score_agr,
            target_score_nneu,
            equal_coefficient,
            number_priority,
            number_importance_traits,
            threshold_consumer_preferences,
            dropdown_candidates,
            number_openness,
            number_conscientiousness,
            number_extraversion,
            number_agreeableness,
            number_non_neuroticism,
            sorted_videos,
            sorted_videos_column,
            practical_task_sorted,
            csv_practical_task_sorted,
            mbti_accordion,
            mbti_description,
            mbti_description_data,
            video_sorted_column,
            video_sorted,
            metadata,
            metadata_1,
            name_row,
            name_logo,
            name,
            surname_row,
            surname_logo,
            surname,
            metadata_2,
            email_row,
            email_logo,
            email,
            phone_row,
            phone_logo,
            phone,
            in_development,
        ],
        queue=True,
    )
    clear_app.click(
        fn=event_handler_clear_blocks,
        inputs=[languages, type_modes],
        outputs=[
            notifications,
            files,
            webcam,
            video,
            calculate_pt_scores,
            clear_app,
            pt_scores,
            csv_pt_scores,
            step_2,
            practical_tasks_column,
            practical_tasks,
            practical_subtasks,
            practical_subtasks_selected,
            settings_practical_tasks,
            dropdown_mbti,
            threshold_mbti,
            threshold_professional_skills,
            dropdown_professional_skills,
            target_score_ope,
            target_score_con,
            target_score_ext,
            target_score_agr,
            target_score_nneu,
            equal_coefficient,
            number_priority,
            number_importance_traits,
            threshold_consumer_preferences,
            dropdown_candidates,
            number_openness,
            number_conscientiousness,
            number_extraversion,
            number_agreeableness,
            number_non_neuroticism,
            sorted_videos,
            sorted_videos_column,
            practical_task_sorted,
            csv_practical_task_sorted,
            mbti_accordion,
            mbti_description,
            mbti_description_data,
            video_sorted_column,
            video_sorted,
            metadata,
            metadata_1,
            name_row,
            name_logo,
            name,
            surname_row,
            surname_logo,
            surname,
            metadata_2,
            email_row,
            email_logo,
            email,
            phone_row,
            phone_logo,
            phone,
            in_development,
        ],
        queue=True,
    )
    practical_tasks.change(
        event_handler_practical_tasks,
        [languages, practical_tasks, practical_subtasks_selected],
        [practical_subtasks],
        queue=True,
    )
    practical_subtasks.change(
        event_handler_practical_subtasks,
        [practical_tasks, practical_subtasks, practical_subtasks_selected],
        [
            practical_subtasks_selected,
            settings_practical_tasks,
            dropdown_mbti,
            threshold_mbti,
            threshold_professional_skills,
            dropdown_professional_skills,
            target_score_ope,
            target_score_con,
            target_score_ext,
            target_score_agr,
            target_score_nneu,
            equal_coefficient,
            number_priority,
            number_importance_traits,
            threshold_consumer_preferences,
            dropdown_candidates,
            number_openness,
            number_conscientiousness,
            number_extraversion,
            number_agreeableness,
            number_non_neuroticism,
        ],
        queue=True,
    )
    dropdown_candidates.change(
        fn=event_handler_dropdown_candidates,
        inputs=[practical_subtasks, dropdown_candidates],
        outputs=[
            number_openness,
            number_conscientiousness,
            number_extraversion,
            number_agreeableness,
            number_non_neuroticism,
        ],
        queue=True,
    )
    calculate_practical_task.click(
        fn=event_handler_calculate_practical_task_blocks,
        inputs=[
            type_modes,
            files,
            video,
            practical_subtasks,
            pt_scores,
            dropdown_mbti,
            threshold_mbti,
            threshold_professional_skills,
            dropdown_professional_skills,
            target_score_ope,
            target_score_con,
            target_score_ext,
            target_score_agr,
            target_score_nneu,
            equal_coefficient,
            number_priority,
            number_importance_traits,
            threshold_consumer_preferences,
            number_openness,
            number_conscientiousness,
            number_extraversion,
            number_agreeableness,
            number_non_neuroticism,
        ],
        outputs=[
            sorted_videos,
            sorted_videos_column,
            practical_task_sorted,
            csv_practical_task_sorted,
            mbti_accordion,
            mbti_description,
            mbti_description_data,
            video_sorted_column,
            video_sorted,
            metadata,
            metadata_1,
            name_row,
            name_logo,
            name,
            surname_row,
            surname_logo,
            surname,
            metadata_2,
            email_row,
            email_logo,
            email,
            phone_row,
            phone_logo,
            phone,
            in_development,
        ],
        queue=True,
    )
    practical_task_sorted.select(
        event_handler_practical_task_sorted,
        [files, practical_task_sorted],
        [
            video_sorted_column,
            video_sorted,
            metadata,
            metadata_1,
            name_row,
            name_logo,
            name,
            surname_row,
            surname_logo,
            surname,
            metadata_2,
            email_row,
            email_logo,
            email,
            phone_row,
            phone_logo,
            phone,
        ],
        queue=True,
    )