diff --git a/examples/exam-006.pdf b/examples/exam-006.pdf new file mode 100644 index 0000000..8fdf6e3 Binary files /dev/null and b/examples/exam-006.pdf differ diff --git a/examples/exam-006.typ b/examples/exam-006.typ new file mode 100644 index 0000000..d4cface --- /dev/null +++ b/examples/exam-006.typ @@ -0,0 +1,69 @@ +#import "../g-exam.typ": g-exam, g-question, g-subquestion, g-solution + +#show: g-exam.with( + author: ( + name: "Andrés Jorge Giménez Muñoz", + email: "matheschool@outlook.es", + watermark: "Teacher: andres", + ), + school: ( + name: "Sunrise Secondary School", + logo: read("./logo.png", encoding: none), + ), + exam-info: ( + academic-period: "Academic year 2023/2024", + academic-level: "1º Secondary Education", + academic-subject: "Mathematics", + number: "2nd Assessment 1st Exam", + content: "Radicals and fractions", + model: "Model A" + ), + + languaje: "en", + decimal-separator: ",", + date: "November 21, 2023", + show-studen-data: "first-page", + show-grade-table: false, + question-point-position: right, + show-solution: true, + clarifications: "Answer the questions in the spaces provided. If you run out of room for an answer, continue on the back of the page." +) + +#g-question[Given the equation $x^n + y^n = z^n$ for $(x,y,z)$ and $n$ positive integers.] +#g-subquestion(point: 10)[For what values of $n$ is the statement in the previous question true?] + +#g-solution[ + I know the demostration, but there's no room on the margin. For any clarification ask Andrew Whilst. + #v(1fr) +] + +#g-subquestion(point: 10)[For $n=2$ there's a theorem with a special name. What's that name? + + #g-solution[ + Pythagorean theorem. + ] +#v(1fr) +] + + +#g-subquestion(point: 10)[What famous mathematician had an elegant proof for this theorem but +there was not enough space in the margin to write it down?]. +#v(1fr) + +#g-question(point: 20)[Prove that the real part of all non-trivial zeros of the function $zeta(z) "is" 1/2$]. + +#g-solution(show-solution: true, + alternative-content: [#v(1fr)] + )[ + I'm working on it. When I have the solution, I'll let you know.... \ + + #v(5pt) + ] + +#g-solution(show-solution: false, + alternative-content: [#v(1fr)] + )[ + I'm working on it. When I have the solution, I'll let you know.... \ + + #v(5pt) + ] diff --git a/g-exam.typ b/g-exam.typ index c1850d2..be2f85c 100644 --- a/g-exam.typ +++ b/g-exam.typ @@ -4,8 +4,8 @@ #let __g-question-point = state("g-question-point", 0) #let __g-question-point-position-state = state("g-question-point-position", left) - #let __g-localization = state("localization") +#let __g-show-solution = state("g-show-solution", false) #let __g-default-localization = ( grade-table-queston: "Question", @@ -229,6 +229,29 @@ ) } +#let g-solution( + alternative-content: none, + show-solution: none, + body) = { + assert(alternative-content == none or type(alternative-content) == "content", + message: "Invalid alternative-content value") + + assert(show-solution in (none, true, false), + message: "Invalid show-solution solution value") + + locate(loc => { + let show-solution = if show-solution == none { __g-show-solution.final(loc) } else { show-solution } + + if show-solution == true { + body + } + else { + alternative-content + } + } + ) +} + #let __g-show_clarifications = (clarifications: none) => { if clarifications != none { let clarifications-content = [] @@ -302,6 +325,7 @@ show-grade-table: true, decimal-separator: ".", question-point-position: left, + show-solution: false, body, ) = { @@ -314,6 +338,9 @@ assert(decimal-separator in (".", ","), message: "Invalid decimal separator") + assert(show-solution in (true, false), + message: "Invalid show solution value") + let __show-watermark = ( author: ( name: "", @@ -585,6 +612,8 @@ ) v(10pt) } + + __g-show-solution.update(show-solution) // show heading.where(level: 1): it => { // set block(above: 1.2em, below: 1em)