yunzi7 commited on
Commit
53ce00a
โ€ข
1 Parent(s): 658dbbd
ice_breaking_challenge/background_task.py CHANGED
@@ -29,11 +29,13 @@ def generate_quiz(data):
29
  Using the text: {question} {answer}, create a new multiple-choice question with 4 answer options.
30
  """
31
  for row in selected_data:
32
- question, answer = row
33
 
34
  input_text = template_input.format(question=question, answer=answer)
35
 
36
  response = model.generate(input_text, max_length=512)
 
 
37
 
38
  generated_quizzes.append(response)
39
 
 
29
  Using the text: {question} {answer}, create a new multiple-choice question with 4 answer options.
30
  """
31
  for row in selected_data:
32
+ question, answer, name = row
33
 
34
  input_text = template_input.format(question=question, answer=answer)
35
 
36
  response = model.generate(input_text, max_length=512)
37
+ # parsing response
38
+ # name + parsed response
39
 
40
  generated_quizzes.append(response)
41
 
ice_breaking_challenge/quiz.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Blueprint, render_template, session
2
+
3
+ bp = Blueprint("quiz", __name__, url_prefix="/quiz")
4
+
5
+ @bp.route("/", methods=["GET"])
6
+ def quiz():
7
+ """quiz"""
8
+ quizzes = session.get("generated_quizzes", [])
9
+ return render_template("quiz.html", quizzes=quizzes, length=len(quizzes))
10
+
11
+ @bp.route("/finish", methods=["GET"])
12
+ def finish():
13
+ return render_template("finish.html")
ice_breaking_challenge/templates/finish.html ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {% extends 'base.html' %}
2
+
3
+ {% block content %}
4
+ <h1>ํ€ด์ฆˆ๊ฐ€ ๋๋‚ฌ์Šต๋‹ˆ๋‹ค!</h1>
5
+ <p>์ฆ๊ฑฐ์šฐ์…จ๋‚˜์š”? ๋งŽ์ด ์นœํ•ด์ง€์…จ๋‚˜์š”? ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค!</p>
6
+ <p>์ฐธ์—ฌํ•ด์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. ์•ž์œผ๋กœ๋„ ์ข‹์€ ์‹œ๊ฐ„ ๋˜์„ธ์š”!</p>
7
+ {% endblock %}
ice_breaking_challenge/templates/quiz.html ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% extends 'base.html' %}
2
+
3
+ {% block content %}
4
+ <h1>ํ€ด์ฆˆ ์ƒ์„ฑ ๊ฒฐ๊ณผ</h1>
5
+
6
+ {% if quizzes %}
7
+ <ul>
8
+ {% for quiz in quizzes %}
9
+ <li>
10
+ <h2>๋ฌธ์ œ ์ฃผ์ธ: {{ quiz[0] }}</h2> <!-- ์ด๋ฆ„ ๋ถ€๋ถ„ -->
11
+ <h3>์งˆ๋ฌธ: {{ quiz[1] }}</h3> <!-- ์งˆ๋ฌธ ๋ถ€๋ถ„ -->
12
+ <ul>
13
+ {% for option in quiz[2] %} <!-- 4์ง€์„ ๋‹ค ๋ณด๊ธฐ -->
14
+ <li>{{ option }}</li>
15
+ {% endfor %}
16
+ </ul>
17
+ <button onclick="showAnswer('{{ loop.index0 }}')">์ •๋‹ต ๋ณด๊ธฐ</button>
18
+ <p id="answer-{{ loop.index0 }}" style="display: none;">์ •๋‹ต: {{ quiz[3] }}</p> <!-- ์ •๋‹ต -->
19
+ </li>
20
+ {% endfor %}
21
+ </ul>
22
+ {% else %}
23
+ <p>ํ€ด์ฆˆ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. ๋‹ค์‹œ ์‹œ๋„ํ•ด ์ฃผ์„ธ์š”.</p>
24
+ {% endif %}
25
+
26
+ <script>
27
+ let currentQuizIndex = 0;
28
+
29
+ function showAnswer(index) {
30
+ const answer = document.getElementById(`answer-${index}`);
31
+ if (answer.style.display === "none") {
32
+ answer.style.display = "block";
33
+ } else {
34
+ answer.style.display = "none";
35
+ }
36
+ currentQuizIndex++;
37
+
38
+ // ํ€ด์ฆˆ๋ฅผ ๋ชจ๋‘ ํ’€๊ณ  ๋‚˜๋ฉด ๋งˆ๋ฌด๋ฆฌ ํŽ˜์ด์ง€๋กœ ์ด๋™
39
+ if (currentQuizIndex === { length }) {
40
+ setTimeout(() => {
41
+ window.location.href = "{{ url_for('quiz.finish') }}";
42
+ }, 3000); // 3์ดˆ ํ›„ ์ž๋™ ์ด๋™
43
+ }
44
+ }
45
+ </script>
46
+ {% endblock %}
ice_breaking_challenge/templates/topic.html CHANGED
@@ -1,43 +1,23 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
- <title>Random Topic Recommendation</title>
8
- <style>
9
- body {
10
- display: flex;
11
- justify-content: center;
12
- align-items: center;
13
- height: 100vh;
14
- font-family: Arial, sans-serif;
15
- }
16
- h1 {
17
- font-size: 2em;
18
- color: #333;
19
- }
20
- </style>
21
- </head>
22
- <body>
23
- <h1 id="topic">์ฃผ์ œ๊ฐ€ ์—ฌ๊ธฐ์— ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค</h1>
24
 
25
- <script>
26
- // ์ฃผ์ œ ์—…๋ฐ์ดํŠธ ํ•จ์ˆ˜
27
- function updateTopic() {
28
- fetch('/get_topic')
29
- .then(response => response.json())
30
- .then(data => {
31
- document.getElementById('topic').textContent = data.topic;
32
- })
33
- .catch(error => console.error('Error fetching topic:', error));
34
- }
35
 
36
- // ํŽ˜์ด์ง€๊ฐ€ ๋กœ๋“œ๋  ๋•Œ ์ฃผ์ œ ์—…๋ฐ์ดํŠธ
37
- updateTopic();
 
 
 
 
 
 
 
 
38
 
39
- // 20์ดˆ๋งˆ๋‹ค ์ฃผ์ œ ์—…๋ฐ์ดํŠธ
40
- setInterval(updateTopic, 20000);
41
- </script>
42
- </body>
43
- </html>
 
 
 
1
+ {% extends 'base.html' %}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
+ {% block content %}
4
+ <h1 id="topic">์ฃผ์ œ๊ฐ€ ์—ฌ๊ธฐ์— ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค</h1>
 
 
 
 
 
 
 
 
5
 
6
+ <script>
7
+ // ์ฃผ์ œ ์—…๋ฐ์ดํŠธ ํ•จ์ˆ˜
8
+ function updateTopic() {
9
+ fetch('/get_topic')
10
+ .then(response => response.json())
11
+ .then(data => {
12
+ document.getElementById('topic').textContent = data.topic;
13
+ })
14
+ .catch(error => console.error('Error fetching topic:', error));
15
+ }
16
 
17
+ // ํŽ˜์ด์ง€๊ฐ€ ๋กœ๋“œ๋  ๋•Œ ์ฃผ์ œ ์—…๋ฐ์ดํŠธ
18
+ updateTopic();
19
+
20
+ // 20์ดˆ๋งˆ๋‹ค ์ฃผ์ œ ์—…๋ฐ์ดํŠธ
21
+ setInterval(updateTopic, 20000);
22
+ </script>
23
+ {% endblock %}
ice_breaking_challenge/topic.py CHANGED
@@ -5,12 +5,14 @@ import random
5
  import time
6
 
7
  bp = Blueprint("topic", __name__, url_prefix="topic")
8
- topics = ["MBTI", "์ง์—…"]
 
 
9
 
10
  @bp.route("/", methods=["GET"])
11
  def topic() -> None:
12
  if session.get("quiz_generated"):
13
- return redirect(url_for("quiz.show_quiz"))
14
  else:
15
  selected_topic = random.choice(topics)
16
  time.sleep(20) # 20์ดˆ ๋Œ€๊ธฐ ํ›„ ๋‹ค์Œ ์ฃผ์ œ๋กœ
 
5
  import time
6
 
7
  bp = Blueprint("topic", __name__, url_prefix="topic")
8
+ topics = ["๋ฐ˜๋ง ๋ชจ๋“œ๋ฅผ ํ•ด๋ณด์‹œ๋Š” ๊ฑด ์–ด๋– ์„ธ์š”?", "์˜ค๋Š˜ ๋‚ฎ์— ํ•œ ์ผ์„ ๊ณต์œ ํ•ด๋ณด์„ธ์š”!", "์•„์นจํ˜• ์ธ๊ฐ„์ธ๊ฐ€์š”, ์ €๋…ํ˜• ์ธ๊ฐ„์ธ๊ฐ€์š”?",
9
+ "MBTI๊ฐ€ ๋ฌด์—‡์ธ๊ฐ€์š”? ๋Œ€ํ™”ํ•ด๋ณด๋ฉฐ ๋งž์ถฐ๋ณด์„ธ์š”!", "์„œ๋กœ์˜ ์ทจ๋ฏธ๋ฅผ ํ•œ ๊ฐ€์ง€์”ฉ ๊ณต์œ ํ•ด๋ณผ๊นŒ์š”?", "๋‚˜์ด๋Œ€๊ฐ€ ์–ด๋–ป๊ฒŒ ๋˜์„ธ์š”? ๋™๊ฐ‘์ด ์žˆ๋Š”์ง€ ์ฐพ์•„๋ณผ๊นŒ์š”?",
10
+ "์„œ๋กœ ์ด๋ฆ„ ๋Œ€์‹  ๋‹‰๋„ค์ž„์„ ํ•˜๋‚˜ ์ •ํ•ด์„œ ๋ถˆ๋Ÿฌ๋ณผ๊นŒ์š”?"]
11
 
12
  @bp.route("/", methods=["GET"])
13
  def topic() -> None:
14
  if session.get("quiz_generated"):
15
+ return redirect(url_for("quiz.quiz"))
16
  else:
17
  selected_topic = random.choice(topics)
18
  time.sleep(20) # 20์ดˆ ๋Œ€๊ธฐ ํ›„ ๋‹ค์Œ ์ฃผ์ œ๋กœ