File size: 1,148 Bytes
70f23d5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import random
from config import SanatanConfig
from modules.quiz.answer_validator import validate_answer
from modules.quiz.quiz_helper import generate_question


if __name__ == "__main__":
    while True:
        q = generate_question(
            collection=random.choice(
                [
                    s["collection_name"]
                    for s in SanatanConfig.scriptures
                    if s["collection_name"] != "yt_metadata"
                ]
            ),
            complexity=random.choice(["beginner", "intermediate", "advanced"]),
            mode=random.choice(["mcq", "open"]),
            preferred_lamguage="English",
        )
        print(q.model_dump_json(indent=1))

        print("Q:", q.question)
        print("Choices:", q.choices)
        print("Expected:", q.expected_answer)

        # Simulate user input
        user_ans = input("Your Answer: ")

        result = validate_answer(q, user_ans, preferred_language="English")
        print(result.model_dump_json(indent=2))

        want_more = input("Want to keep playing? Y/N: ")
        if want_more == "N":
            break
    print("Game over!")