File size: 922 Bytes
05919ff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

import requests

import config


def getQuestions():
    try:
        response = requests.get(config.questionsUrl, timeout=15)
        response.raise_for_status()
        questions_data = response.json()
        if not questions_data:
             print("Fetched questions list is empty.")
             raise Exception("Fetched questions list is empty")
        print(f"Fetched {len(questions_data)} questions.")
        return questions_data
    except Exception as e:
        print(f"An unexpected error occurred fetching questions: {e}")
    return None
    
def getQuestionByPos(i):
    questions = getQuestions()
    return questions[i]

def printQuestions():
    for i,question in enumerate(getQuestions()):
        print(f"{i+1}: {question['question']} {'(File: ' + question['file_name'] + ')' if question['file_name'] else ''}")

if __name__ == "__main__":
    questions = getQuestions()
    printQuestions()