Muthuraja18 commited on
Commit
809a66a
·
verified ·
1 Parent(s): 913e5f1
Files changed (1) hide show
  1. app.py +13 -10
app.py CHANGED
@@ -620,9 +620,6 @@ def create_game_page():
620
  st.info(f"AI questions will be generated for: {ai_topic}")
621
  # Here you can call your AI question generator function if you have one
622
 
623
-
624
- LEADERBOARD_FILE = "leaderboard.csv"
625
-
626
  def save_score_to_csv(
627
  name,
628
  score,
@@ -633,9 +630,14 @@ def save_score_to_csv(
633
  answers=None,
634
  correct_flags=None
635
  ):
636
- file_exists = os.path.exists(LEADERBOARD_FILE)
637
-
638
- with open(LEADERBOARD_FILE, "a", newline="", encoding="utf-8") as f:
 
 
 
 
 
639
  writer = csv.writer(f)
640
 
641
  # Write header only once
@@ -656,15 +658,16 @@ def save_score_to_csv(
656
  name,
657
  score,
658
  game_id,
659
- ",".join(topics) if isinstance(topics, list) else topics,
660
  datetime.now().isoformat(),
661
  avatar,
662
- str(questions),
663
- str(answers),
664
- str(correct_flags)
665
  ])
666
 
667
 
 
668
  # 1️⃣ Define join_game first
669
  def join_game(game_id, username, avatar):
670
  games = unified_get("games") or {}
 
620
  st.info(f"AI questions will be generated for: {ai_topic}")
621
  # Here you can call your AI question generator function if you have one
622
 
 
 
 
623
  def save_score_to_csv(
624
  name,
625
  score,
 
630
  answers=None,
631
  correct_flags=None
632
  ):
633
+ file_exists = os.path.isfile(LEADERBOARD_FILE)
634
+
635
+ with open(
636
+ LEADERBOARD_FILE,
637
+ "a",
638
+ newline="",
639
+ encoding="utf-8"
640
+ ) as f:
641
  writer = csv.writer(f)
642
 
643
  # Write header only once
 
658
  name,
659
  score,
660
  game_id,
661
+ ", ".join(topics) if isinstance(topics, list) else topics,
662
  datetime.now().isoformat(),
663
  avatar,
664
+ questions,
665
+ answers,
666
+ correct_flags
667
  ])
668
 
669
 
670
+
671
  # 1️⃣ Define join_game first
672
  def join_game(game_id, username, avatar):
673
  games = unified_get("games") or {}