Spaces:
Sleeping
Sleeping
arxivgpt kim
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,58 +1,57 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
# 예시
|
4 |
questions = [
|
5 |
"1. 당신의 좋아하는 색은 무엇인가요?",
|
6 |
"2. 주말에 가장 하고 싶은 활동은?",
|
7 |
-
"3. 선호하는
|
8 |
-
"4.
|
9 |
-
"5.
|
10 |
-
"6.
|
11 |
]
|
12 |
|
13 |
-
|
14 |
["빨강", "파랑", "초록"],
|
15 |
["산책", "독서", "영화 감상"],
|
16 |
-
["산", "바다", "도시"],
|
17 |
["한식", "중식", "양식"],
|
18 |
-
["
|
19 |
-
["
|
|
|
20 |
]
|
21 |
|
22 |
scores = [
|
23 |
[1, 2, 3],
|
24 |
-
[
|
25 |
-
[
|
26 |
-
[
|
27 |
-
[
|
28 |
-
[
|
29 |
]
|
30 |
|
31 |
def calculate_score(answers):
|
32 |
-
total_score =
|
33 |
-
|
|
|
|
|
34 |
|
35 |
-
with gr.Blocks() as
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
next_page=page.next_page
|
49 |
-
)
|
50 |
-
else:
|
51 |
-
gr.Button("제출").click(
|
52 |
-
calculate_score,
|
53 |
-
inputs=[answers],
|
54 |
-
outputs=gr.Textbox()
|
55 |
-
)
|
56 |
-
pages.append(page)
|
57 |
-
|
58 |
-
app.launch()
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
# 예시 문제, 옵션, 스코어 설정
|
4 |
questions = [
|
5 |
"1. 당신의 좋아하는 색은 무엇인가요?",
|
6 |
"2. 주말에 가장 하고 싶은 활동은?",
|
7 |
+
"3. 선호하는 음식은 무엇인가요?",
|
8 |
+
"4. 여행을 가고 싶은 나라는 어디인가요?",
|
9 |
+
"5. 좋아하는 계절은 무엇인가요?",
|
10 |
+
"6. 읽고 싶은 책의 장르는?"
|
11 |
]
|
12 |
|
13 |
+
options = [
|
14 |
["빨강", "파랑", "초록"],
|
15 |
["산책", "독서", "영화 감상"],
|
|
|
16 |
["한식", "중식", "양식"],
|
17 |
+
["한국", "일본", "미국"],
|
18 |
+
["봄", "여름", "가을", "겨울"],
|
19 |
+
["소설", "자기계발", "역사"]
|
20 |
]
|
21 |
|
22 |
scores = [
|
23 |
[1, 2, 3],
|
24 |
+
[2, 3, 4],
|
25 |
+
[3, 4, 5],
|
26 |
+
[4, 5, 6],
|
27 |
+
[5, 6, 7, 8],
|
28 |
+
[6, 7, 8]
|
29 |
]
|
30 |
|
31 |
def calculate_score(answers):
|
32 |
+
total_score = 0
|
33 |
+
for i, ans in enumerate(answers):
|
34 |
+
total_score += scores[i][options[i].index(ans)]
|
35 |
+
return total_score
|
36 |
|
37 |
+
with gr.Blocks() as demo:
|
38 |
+
with gr.Tab("퀴즈 1"):
|
39 |
+
answer1 = gr.Radio(choices=options[0], label=questions[0])
|
40 |
+
answer2 = gr.Radio(choices=options[1], label=questions[1])
|
41 |
+
with gr.Tab("퀴즈 2"):
|
42 |
+
answer3 = gr.Radio(choices=options[2], label=questions[2])
|
43 |
+
answer4 = gr.Radio(choices=options[3], label=questions[3])
|
44 |
+
with gr.Tab("퀴즈 3"):
|
45 |
+
answer5 = gr.Radio(choices=options[4], label=questions[4])
|
46 |
+
answer6 = gr.Radio(choices=options[5], label=questions[5])
|
47 |
+
submit_btn = gr.Button("제출")
|
48 |
|
49 |
+
result = gr.Textbox(label="총점")
|
50 |
+
|
51 |
+
submit_btn.click(
|
52 |
+
fn=calculate_score,
|
53 |
+
inputs=[answer1, answer2, answer3, answer4, answer5, answer6],
|
54 |
+
outputs=result
|
55 |
+
)
|
56 |
+
|
57 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|