|
import os |
|
import json |
|
|
|
|
|
def load_question_sets(directory='questions'): |
|
question_sets = [] |
|
for root, dirs, files in os.walk(directory): |
|
for file in files: |
|
if file.endswith(".json"): |
|
question_sets.append(file[:-5]) |
|
return question_sets |
|
|
|
|
|
def select_exam(exam_name): |
|
file_path = os.path.join('questions', f'{exam_name}.json') |
|
try: |
|
with open(file_path, 'r') as f: |
|
questions = json.load(f) |
|
print(f"Loaded {len(questions)} questions from {exam_name}") |
|
return questions |
|
except FileNotFoundError: |
|
print(f"File {file_path} not found.") |
|
return [] |