Spaces:
Runtime error
Runtime error
dongwook-chan
commited on
Commit
β’
7ff0925
1
Parent(s):
d8529e7
Update
Browse files
ice_breaking_challenge/background_task.py
CHANGED
@@ -27,11 +27,15 @@ def generate_quiz(data):
|
|
27 |
input_text = template_input.format(question=question, answer=answer)
|
28 |
|
29 |
response = model.generate(input_text, max_length=512)
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
32 |
|
33 |
-
generated_quizzes.append(
|
34 |
|
35 |
return generated_quizzes
|
36 |
|
37 |
-
|
|
|
27 |
input_text = template_input.format(question=question, answer=answer)
|
28 |
|
29 |
response = model.generate(input_text, max_length=512)
|
30 |
+
|
31 |
+
lines = response.split('\n')
|
32 |
+
index = lines.index('<response>')
|
33 |
+
question_generated = lines[index+1]
|
34 |
+
multiple_choice_generated = lines[index + 2]
|
35 |
+
answer_generated = lines[index + 3]
|
36 |
|
37 |
+
generated_quizzes.append([question_generated, multiple_choice_generated, answer_generated])
|
38 |
|
39 |
return generated_quizzes
|
40 |
|
41 |
+
|
ice_breaking_challenge/google_sheets.py
CHANGED
@@ -73,9 +73,11 @@ def get_questions_and_answers() -> list[list[str]]:
|
|
73 |
|
74 |
answers_values = get_range(f"Responses!B2:F{MAX_ROW}")
|
75 |
|
|
|
|
|
76 |
questions_and_answers: list[list[str]] = []
|
77 |
-
for answers in answers_values:
|
78 |
-
for question, answer in zip(questions, answers):
|
79 |
-
questions_and_answers.append([question, answer])
|
80 |
|
81 |
return questions_and_answers
|
|
|
73 |
|
74 |
answers_values = get_range(f"Responses!B2:F{MAX_ROW}")
|
75 |
|
76 |
+
name_values = get_range(f"Responses!K2:K{MAX_ROW}")
|
77 |
+
|
78 |
questions_and_answers: list[list[str]] = []
|
79 |
+
for answers, names in zip(answers_values, name_values):
|
80 |
+
for question, answer, name in zip(questions, answers, names):
|
81 |
+
questions_and_answers.append([question, answer, name])
|
82 |
|
83 |
return questions_and_answers
|
ice_breaking_challenge/introduction.py
CHANGED
@@ -12,7 +12,7 @@ from threading import Thread
|
|
12 |
from .auth import login_required
|
13 |
from .db import get_db
|
14 |
|
15 |
-
bp = Blueprint("introduction", __name__, url_prefix="introduction")
|
16 |
|
17 |
|
18 |
@bp.route("/", methods=["GET", "POST"])
|
|
|
12 |
from .auth import login_required
|
13 |
from .db import get_db
|
14 |
|
15 |
+
bp = Blueprint("introduction", __name__, url_prefix="/introduction")
|
16 |
|
17 |
|
18 |
@bp.route("/", methods=["GET", "POST"])
|
ice_breaking_challenge/qr.py
CHANGED
@@ -16,7 +16,7 @@ from .auth import login_required
|
|
16 |
from .db import get_db
|
17 |
from ice_breaking_challenge.google_sheets import get_team_numbers, get_questions_and_answers
|
18 |
|
19 |
-
from
|
20 |
|
21 |
|
22 |
bp = Blueprint("qr", __name__, url_prefix="/qr")
|
@@ -33,10 +33,12 @@ def qr() -> None:
|
|
33 |
if session.get("team_number") not in counter:
|
34 |
flash("ν΄λΉ ν λ²νΈκ° μ‘΄μ¬νμ§ μμ΅λλ€.")
|
35 |
return render_template("index.html")
|
36 |
-
if counter[session.get("team_number")] == session["team_size"]:
|
37 |
qna = get_questions_and_answers()
|
38 |
Thread(target=background_task, args=(session.sid, qna)).start()
|
|
|
|
|
39 |
return render_template("introduction.html")
|
40 |
else:
|
41 |
flash("μ€λ¬Έμ μλ£νμ§ μμ νμμ΄ μμ΅λλ€.")
|
42 |
-
return render_template("qr.html")
|
|
|
16 |
from .db import get_db
|
17 |
from ice_breaking_challenge.google_sheets import get_team_numbers, get_questions_and_answers
|
18 |
|
19 |
+
from ice_breaking_challenge import background_task
|
20 |
|
21 |
|
22 |
bp = Blueprint("qr", __name__, url_prefix="/qr")
|
|
|
33 |
if session.get("team_number") not in counter:
|
34 |
flash("ν΄λΉ ν λ²νΈκ° μ‘΄μ¬νμ§ μμ΅λλ€.")
|
35 |
return render_template("index.html")
|
36 |
+
if counter[session.get("team_number")] == int(session["team_size"]):
|
37 |
qna = get_questions_and_answers()
|
38 |
Thread(target=background_task, args=(session.sid, qna)).start()
|
39 |
+
import time
|
40 |
+
time.sleep(100)
|
41 |
return render_template("introduction.html")
|
42 |
else:
|
43 |
flash("μ€λ¬Έμ μλ£νμ§ μμ νμμ΄ μμ΅λλ€.")
|
44 |
+
return render_template("qr.html")
|