Skip to content

Commit

Permalink
point-position in question.
Browse files Browse the repository at this point in the history
  • Loading branch information
andres-gimenez committed Mar 1, 2024
1 parent dc14f55 commit 80606b8
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Compile Typst to PDF
uses: mkpoli/compile-typst-action@main
with:
source_paths: "examples/exam-localization.typ examples/exam-minimal.typ"
source_paths: "examples/exam-localization.typ examples/exam-minimal.typ examples/exam-points-position.typ"
root_path: '.'

- name: Upload PDF file
Expand Down
Binary file added examples/exam-points-position.pdf
Binary file not shown.
102 changes: 102 additions & 0 deletions examples/exam-points-position.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#import "../g-exam.typ": g-exam, g-question, g-subquestion
#import "@preview/cetz:0.2.1"

#show: g-exam.with()

#g-question(point: 2, point-position: right)[Question 1]

#v(5cm)

#g-question[
Given the graphs of the following systems of linear equations,
Determines by the position of the lines the type of system according to the number of solutions. \

#columns(2, gutter: 2cm)[
#g-subquestion(point: 0.5, point-position: left)[
#align(center,
cetz.canvas(length: 0.7cm, {
cetz.plot.plot(
size: (10, 10),
axis-style: "school-book",
fill: "o" ,
fill-below: true,
x-domain: (-5.2, 5.2),
y-domain: (-5.2, 5.2),
x-max: 5.2,
x-min:-5.2,
y-max: 5.2,
y-min:-5.2,
x-grid: "both",
y-grid: "both",
x-tick-step: 1,
y-tick-step: 1,
{
cetz.plot.add(((0,0),), mark-size: 0,)

cetz.plot.add(
style: (stroke: blue + 2pt),
domain: (-5.2, 5.2),
x=>x + 3
)

cetz.plot.add(
style: (stroke: olive + 2pt),
domain: (-5.2, 5.2),
x=>x
)
}
)
}
)
)
]
#colbreak()

#g-subquestion(point: 0.5, point-position: right)[
#align(center,
cetz.canvas(length: 0.7cm, {
cetz.plot.plot(
size: (10, 10),
axis-style: "school-book",
fill: "o" ,
fill-below: true,
x-domain: (-5.2, 5.2),
y-domain: (-5.2, 5.2),
x-max: 5.2,
x-min:-5.2,
y-max: 5.2,
y-min:-5.2,
x-grid: "both",
y-grid: "both",
x-tick-step: 1,
y-tick-step: 1,
{
cetz.plot.add(((0,0),), mark-size: 0,)

cetz.plot.add(
style: (stroke: blue + 2pt),
domain: (-5.2, 5.2),
x=>-x - 4
)

cetz.plot.add(
style: (stroke: olive + 2pt),
domain: (-5.2, 5.2),
x=>3
)
}
)
}
)
)
]
]
]

#pagebreak()

#g-question(point: 1)[Question 2]

#g-question(point: 1.5, point-position: left)[Question 3]

#g-question()[Question 4]
48 changes: 40 additions & 8 deletions g-exam.typ
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,14 @@
}
}

#let g-question(point: none, body) = {
#let g-question(
point: none,
point-position: none,
body) = {
assert(point-position in (none, left, right),
message: "Invalid point position")
let __g-question-point-position = state("__g-question-point-position", none)

__g-question-number.step(level: 1)

[#hide[]<end-g-question-localization>]
Expand All @@ -130,9 +137,19 @@
})

locate(loc => {
let __g-question-point-position = __g-question-point-position-state.final(loc)
if __g-question-point-position == none {
__g-question-point-position.push(__g-question-point-position-state.final(loc))
}
if point != 0 and __g-question-point-position == none {
__g-question-point-position.push(left)

[kddffddekk #__g-question-point-position -----]
}

[kkk #__g-question-point-position -----]

if __g-question-point-position == left {
[bb]
v(0.1em)
{
__g-question-number.display(__g-question-numbering)
Expand All @@ -155,24 +172,39 @@
body
}
else {
v(0.1em)
[ccc]
v(0.1em)
__g-question-number.display(__g-question-numbering)
body
}
})
}

#let g-subquestion(point: none, body) = {
#let g-subquestion(
point: none,
point-position: none,
body) = {

assert(point-position in (none, left, right),
message: "Invalid point position")
let __g-question-point-position = point-position

__g-question-number.step(level: 2)

let subg-question-point = 0
if point != none { subg-question-point = point }
__g-question-point.update(p => p + subg-question-point )


locate(loc => {
let g-question-point-position = __g-question-point-position-state.final(loc)

if g-question-point-position == left {
if __g-question-point-position == none {
let __g-question-point-position = __g-question-point-position-state.final(loc)
}
if point != 0 and __g-question-point-position == none {
let __g-question-point-position = left
}

if __g-question-point-position == left {
v(0.1em)
{
h(0.7em)
Expand All @@ -184,7 +216,7 @@
}
body
}
else if g-question-point-position == right {
else if __g-question-point-position == right {
v(0.1em)
if(point != none) {
place(right,
Expand Down

0 comments on commit 80606b8

Please sign in to comment.