Parser of berki style problems and generator of latex file
Samo Penic
2018-11-21 7ec3a648501d965ce8f6cc342595abc289f85134
commit | author | age
c9c8d5 1 from aoi_gen.BerkiParse import BerkiParse
SP 2 from aoi_gen.Problem import ProblemSource, Problem
3 from aoi_gen.Exam import Exam
64376f 4 import pkg_resources
SP 5 import os
5aa5bb 6
64376f 7 if pkg_resources.resource_dir is not None:
SP 8     template_path = os.path.join(pkg_resources.resource_dir, "/textemplates")
9 else:
10     template_path = "aoi_gen/textemplates"
7c2a8f 11
SP 12 if __name__ == "__main__":
5aa5bb 13     settings = {
64376f 14         "exam_title": "Naslov izpita",
SP 15         "date": "27.10.2018",
16         "faculty_name": "Fakulteta test",
17         "faculty_id": 0,
18         "exam_id": 0,
19         "last_line": "Empty line",
20         "start_number": 100,
21         "sid_prefill": "11x0xxxx",
22     }
993a25 23
64376f 24     student_list = [("64990162", "Samo Penic")]
5aa5bb 25
64376f 26     exam = Exam(settings=settings, student_list=student_list, number_of_papers=5, template=template_path)
7224af 27     exam.loadProblemsFromDirectory("testcases/*.txt")
SP 28     exam.generatePapers()
64376f 29     text = exam.exam_to_template()
SP 30     # print(text)
31     exam_matrix = exam.get_answers()
7224af 32     print(exam_matrix)
64376f 33     with open("preverjanje.tex", "w") as problem_fd:
993a25 34         problem_fd.write(text)