Cl_QuizMaster / analytics.py
H3y-sam's picture
Upload 10 files
d5fa022 verified
Raw History Blame Contribute Delete
923 Bytes
import logging
import db
logger = logging.getLogger(__name__)
def get_weekly_report_text(chat_id: int):
"""
Generate a formatted performance report for a group.
"""
stats = db.get_weekly_stats(chat_id)
total = stats["total"]
correct = stats["correct"]
if total == 0:
return "πŸ“Š *Weekly Performance Report*\\n\\nNo participation data recorded for this week yet. Start voting to see stats!"
accuracy = (correct / total * 100) if total > 0 else 0
report = (
f"πŸ“Š *Weekly Performance Report*\\n\\n"
f"βœ… Total Questions Answered: *{total}*\\n"
f"🎯 Correct Answers: *{correct}*\\n"
f"πŸ“ˆ Overall Accuracy: *{accuracy:.1f}%*\\n\\n"
f"πŸ”₯ *Engagement Insights:*\\n"
f"Your community is actively learning! Keep practicing to improve these stats.\\n\\n"
f"_CLQuizMaster AI Analytics_"
)
return report