Parser of berki style problems and generator of latex file
Samo Penic
2018-11-03 0d81f7820211684993269b78340f4a7c7c729357
A change in template. Problem intro separate template for any type of problem (with subproblems or not).
2 files modified
1 files added
17 ■■■■ changed files
tools/Template.py 12 ●●●●● patch | view | raw | blame | history
tools/textemplates/answerstemplate.tpl 4 ●●●● patch | view | raw | blame | history
tools/textemplates/problemtemplate.tpl 1 ●●●● patch | view | raw | blame | history
tools/Template.py
@@ -16,6 +16,7 @@
            "problem_intro": os.path.join(path, "problemintrotemplate.tpl"),
            "subproblem": os.path.join(path, "subproblemtemplate.tpl"),
            "subproblem_end": os.path.join(path, "subproblemtemplateend.tpl"),
            "answers": os.path.join(path,"answerstemplate.tpl")
        }
        self.template = {}
@@ -28,11 +29,10 @@
        return template
    def put_problem_into_template(self, problem_dict, problem_number=0):
        retstr = ""
        retstr = Template(self.template["problem_intro"]).substitute(
            {"problem_number": problem_number, "text": problem_dict["introduction"]}
        )
        if len(problem_dict["solutions"]) > 1:
            retstr += Template(self.template["problem_intro"]).substitute(
                {"problem_number": problem_number, "text": problem_dict["introduction"]}
            )
            for sp, sol in zip(problem_dict["subproblems"], problem_dict["solutions"]):
                retstr += Template(self.template["subproblem"]).substitute(
                    {
@@ -53,10 +53,8 @@
                )
            retstr += Template(self.template["subproblem_end"]).substitute()
        else:
            retstr += Template(self.template["problem"]).substitute(
            retstr += Template(self.template["answers"]).substitute(
                {
                    "problem_number": problem_number,
                    "text": problem_dict["introduction"],
                    "ans1": problem_dict["solutions"][0]["shuffled"][0][
                        0
                    ].format_as_tex(
tools/textemplates/answerstemplate.tpl
New file
@@ -0,0 +1,4 @@
%this is a template for answers in-line
\vskip\texttoanswerskip
\answersinline{$ans1}{$ans2}{$ans3}{$ans4}
\vskip\answertotextskip
tools/textemplates/problemtemplate.tpl
@@ -4,4 +4,3 @@
%this is a template for answers in-line
\answersinline{$ans1}{$ans2}{$ans3}{$ans4}
\vskip\answertotextskip