-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
36 lines (29 loc) · 1.15 KB
/
main.py
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
# LICENSE: https://github.com/DaijobuDes/testpaper-generator/blob/main/LICENSE
import json
data = {}
def main():
limit = int(input("Enter number of questions: "))
school = str(input("Enter school name: "))
subject = str(input("Enter subject: "))
directions = str(input("Enter testpaper direction: "))
data["school"] = school
data["subject"] = subject
data["directions"] = directions
data["questions"] = {}
for i in range(0, limit):
question = str(input(f"Enter question number {i+1}: "))
data["questions"][f"{str(i+1)}"] = {}
data["questions"][f"{str(i+1)}"]["ask"] = question
data["questions"][f"{str(i+1)}"]["choices"] = {}
for j in range(0, 4):
choice = str(input(f"Enter choice {j+1}: "))
data["questions"][f"{str(i+1)}"]["choices"][f"{chr(65+j)}"] = {}
data["questions"][f"{str(i+1)}"]["choices"][f"{chr(65+j)}"] = choice
print(json.dumps(data, indent=4))
subject.lower()
with open(f'./testpaper/{subject}.json', 'w') as f:
json.dump(data, f, indent=4)
try:
main()
except KeyboardInterrupt:
print("User cancelled operation.")