diff --git a/assets/style-course.css b/assets/style-course.css index 846f5e4..03b1830 100644 --- a/assets/style-course.css +++ b/assets/style-course.css @@ -19,11 +19,12 @@ font-style: italic; } -.question { +.question:not(.for-solution) { padding: 1ex; background: #ddd; margin-top: 2em; margin-bottom: 2em; + position: relative; } .question p { padding: 0; @@ -34,6 +35,20 @@ font-weight: 600; margin: 1ex 1em 1.5ex 1em; } + +.solution { + margin-top: -1.5em; + margin-bottom: 1em; + text-align: end; +} + +.solution .solution-icon { + width: 1em; + height: 1em; + display: block; + margin-right: 0.35em; +} + .question .question-picture { max-width: 100%; margin-bottom: 1em; @@ -171,7 +186,7 @@ td { } ul { - list-style-type: square; + list-style-type: square; } ul li::marker { @@ -419,15 +434,15 @@ span.formula { /* Enable Line Breaks in Equations ... */ .course .katex-display > .katex { - white-space: normal + white-space: normal; } /* Add space between broken lines: */ .course .katex-display .base { - margin: 0.5em 0em + margin: 0.5em 0em; } /* Compensate by reducing space around display math */ .course .katex-display { - margin: 1em 0em; -} \ No newline at end of file + margin: 1em 0em; +} diff --git a/build.py b/build.py index b913c57..5caae9f 100644 --- a/build.py +++ b/build.py @@ -13,3 +13,4 @@ bd.build_edition("NE") bd.build_edition("EA") bd.build_edition("NEA") bd.build_assets() +bd.build_solutions() diff --git a/src/build.py b/src/build.py index 93eaf1c..2cfef74 100644 --- a/src/build.py +++ b/src/build.py @@ -104,6 +104,8 @@ class Build: picture_question = "" alt_text_question = "" + solution_file = self.config.p_data_solutions / f"{number}.md" + return question_template.render( question=question["question"], number=number, @@ -113,6 +115,7 @@ class Build: answer_pictures=answer_pictures, alt_text_answers=alt_text_answers, alt_text_question=alt_text_question, + has_solution=solution_file.exists(), ) def __build_question_slide(self, input): @@ -458,3 +461,23 @@ class Build: self.__build_course_page(snippets, "patenkarte", "patenkarte") self.__build_html_page(contents, "pruefung") self.__build_html_page(contents, "infos") + + def build_solutions(self): + for solution_file in self.config.p_data_solutions.glob("*.md"): + with solution_file.open() as file: + content = file.read() + with (self.config.p_build / f"{solution_file.stem}.html").open("w") as file: + with FiftyOhmHtmlRenderer( + question_renderer=self.__build_question, + picture_handler=self.__picture_handler, + photo_handler=self.__photo_handler, + include_handler=self.__include_handler, + ) as renderer: + question = self.__build_question( + solution_file.stem, template_file="html/solution_question.html" + ) + solution_template = self.env.get_template("html/solution.html") + solution = renderer.render(Document(content)) + page = solution_template.render(question=question, solution=solution, number=solution_file.stem) + page = self.__build_page(page, course_wrapper=False) + file.write(page) diff --git a/src/config.py b/src/config.py index a87869c..81433f3 100644 --- a/src/config.py +++ b/src/config.py @@ -26,6 +26,7 @@ class Config: self.p_data_slides = self.p_data_contents / "slides" self.p_data_snippets = self.p_data_contents / "snippets" self.p_data_static = self.p_data_contents / "static" + self.p_data_solutions = self.p_data_contents / "solutions" self.p_data_fragenkatalog = self.p_data_questions / "fragenkatalog3b.json" self.p_data_metadata = self.p_data_questions / "metadata3b.json" diff --git a/templates/html/question.html b/templates/html/question.html index a95851c..bb613b8 100644 --- a/templates/html/question.html +++ b/templates/html/question.html @@ -1,25 +1,37 @@
-
{{ number }}: {{ question }}
- {% if picture_question %} -
{{ alt_text_question }}
- {% endif %} -
- {% for i in range(4) %} - - {% endfor %} -
+
+ {{ number }}: {{ question }}
- + {% if picture_question %} +
{{ alt_text_question }}
+ {% endif %} +
+ {% for i in range(4) %} + + {% endfor %} +
+
+
+ {% if has_solution %} + + + Lösungsweg anzeigen + + {% endif %} +
+ \ No newline at end of file diff --git a/templates/html/solution.html b/templates/html/solution.html new file mode 100644 index 0000000..aecae60 --- /dev/null +++ b/templates/html/solution.html @@ -0,0 +1,16 @@ + diff --git a/templates/html/solution_question.html b/templates/html/solution_question.html new file mode 100644 index 0000000..409d67c --- /dev/null +++ b/templates/html/solution_question.html @@ -0,0 +1,21 @@ +
+
Frage: {{ question }}
+ {% if picture_question %} +
{{ alt_text_question }}
+ {% endif %} +
+ {% for i in range(1) %} +
+ {{ 'Lösung:' if i == 0 else 'Falsch:' }} + {% if answers[i] %} + {{ answers[i] }} + {% endif %} + {% if answer_pictures[i] %} +
{{ alt_text_answers[i] }}
+ {% endif %} +
+ {% endfor %} +
+
+ + \ No newline at end of file