| | |
| | | "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 = {} |
| | |
| | | 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( |
| | | { |
| | |
| | | ) |
| | | 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( |