Parser of berki style problems and generator of latex file
Samo Penic
2018-10-28 a21943f4b50ddd8d3e216f1a9f4a45ed0ba0f0a8
Full tex template adapted for python.
2 files modified
1 files renamed
37 ■■■■■ changed files
GenerateTests.py 3 ●●●●● patch | view | raw | blame | history
tools/Template.py 34 ●●●●● patch | view | raw | blame | history
tools/textemplates/newpaperwithNAMEtemplate.tpl patch | view | raw | blame | history
GenerateTests.py
@@ -23,4 +23,7 @@
        p= Problem(n)
        pprint.pprint(p.problem)
    print(t.head(exam_title="Naslov izpita", date="27.10.2018", faculty_name="Fakulteta test", sid_prefill="11x0xxxx"))
    print(t.start_paper())
    print(t.put_problem_into_template(p.problem))
    print(t.tail())
tools/Template.py
@@ -10,7 +10,7 @@
        self.template_filenames = {
            "head": os.path.join(path, "headtemplate.tpl"),
            "paper": os.path.join(path, "newpolatemplate.tpl"),
            "paper": os.path.join(path, "newpaperwithNAMEtemplate.tpl"),
            "paper_sid": os.path.join(path, "newpaperwithSIDtemplate.tpl"),
            "problem": os.path.join(path, "problemtemplate.tpl"),
            "problem_intro": os.path.join(path, "problemintrotemplate.tpl"),
@@ -56,3 +56,35 @@
                }
            )
        return retstr
    def head(
        self,
        faculty_id=0,
        faculty_name="",
        exam_id=0,
        exam_title="Exam",
        date="",
        last_line="",
        sid_prefill="11x0xxxx",
        start_number=0,
    ):
        return Template(self.template["head"]).substitute({
            "faculty_id": faculty_id,
            "exam_id": exam_id,
            "faculty_name": faculty_name,
            "exam_title": exam_title,
            "date": date,
            "last_line": last_line,
            "sid_prefill": sid_prefill,
            "start_number": start_number
        })
    def tail(self):
        return ("""\end{document}""")
    def start_paper(self, student_id=None, student_name=None):
        if student_id is not None:
            return Template(self.template["paper"]).substitute(student_id, student_name)
        else:
            return Template(self.template["paper_sid"]).substitute()
tools/textemplates/newpaperwithNAMEtemplate.tpl