-
Notifications
You must be signed in to change notification settings - Fork 1
/
exam.py
37 lines (24 loc) · 1019 Bytes
/
exam.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
37
from maths.questions import relationships
from maths.latex import latex
from maths.api import api
import os
def generate_exam():
"""Generate an exam with multiple questions, with solutions for each question!
It's quite simple for now.
"""
cur_dir = os.path.split(__file__)[0]
questions_dir = os.path.join(cur_dir, 'maths', 'questions')
question_paths = api.get_question_paths(questions_dir)
question_modules = api.import_question_modules(question_paths)
with open('exam.tex', 'w') as exam_file:
latex.begin_tex_document(exam_file)
for question in question_modules:
possible_questions = relationships.parse_structure(question)
for i in possible_questions:
i.write_question(exam_file)
latex.decrement_question_counter(exam_file)
i.write_solution(exam_file)
latex.new_page(exam_file)
latex.end_tex_document(exam_file)
if __name__ == '__main__':
generate_exam()