feat: add task bonus and challenge labels
This commit is contained in:
1 file changed
+42
-6
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#let default-theme = (
|
#let default-theme = (
|
||||||
primary: rgb("#0E7C7B"),
|
primary: rgb("#0E7C7B"),
|
||||||
secondary: rgb("#D4F4ED"),
|
|
||||||
accent: rgb("#FFC857"),
|
accent: rgb("#FFC857"),
|
||||||
warning: rgb("#E9724C"),
|
warning: rgb("#E9724C"),
|
||||||
error: rgb("#C5283D"),
|
error: rgb("#C5283D"),
|
||||||
@@ -24,14 +23,26 @@
|
|||||||
#let doc-id = sys.inputs.at("doc-id", default: none)
|
#let doc-id = sys.inputs.at("doc-id", default: none)
|
||||||
|
|
||||||
|
|
||||||
#let task(points: none, title, body, col: none, label: none) = context {
|
|
||||||
|
#let task(
|
||||||
|
points: none,
|
||||||
|
title,
|
||||||
|
body,
|
||||||
|
col: none,
|
||||||
|
label: none,
|
||||||
|
bonus: false,
|
||||||
|
challenge: false,
|
||||||
|
) = context {
|
||||||
subtask-indent.update((0,))
|
subtask-indent.update((0,))
|
||||||
|
|
||||||
let theme = theme-state.get()
|
let theme = theme-state.get()
|
||||||
let text-color = theme.primary
|
|
||||||
|
let col = if col == none { theme.primary } else { col }
|
||||||
|
|
||||||
|
let text-color = col
|
||||||
let header-font = theme.sans-font
|
let header-font = theme.sans-font
|
||||||
let border-color = theme.primary
|
let border-color = col
|
||||||
let background-color = theme.primary.transparentize(95%)
|
let background-color = col.transparentize(95%)
|
||||||
let task-label = if label == none { task-label-state.get() } else { label }
|
let task-label = if label == none { task-label-state.get() } else { label }
|
||||||
|
|
||||||
let subtask-points = query(
|
let subtask-points = query(
|
||||||
@@ -43,6 +54,10 @@
|
|||||||
let calculated-points = subtask-points.map(e => e.value.points).sum(default: 0)
|
let calculated-points = subtask-points.map(e => e.value.points).sum(default: 0)
|
||||||
let shown-points = if points != none { points } else if subtask-points.len() > 0 { calculated-points }
|
let shown-points = if points != none { points } else if subtask-points.len() > 0 { calculated-points }
|
||||||
|
|
||||||
|
let tag = content => box(stroke: (paint: text-color, thickness: 0.6pt), radius: 0.3em, inset: (x: 0.45em, y: 0.17em))[
|
||||||
|
#text(fill: text-color, size: 0.75em, weight: "bold")[#content]
|
||||||
|
]
|
||||||
|
|
||||||
v(1.5em)
|
v(1.5em)
|
||||||
|
|
||||||
task-active.update(true)
|
task-active.update(true)
|
||||||
@@ -70,6 +85,8 @@
|
|||||||
#if title != none and title != [] {
|
#if title != none and title != [] {
|
||||||
[ — #title]
|
[ — #title]
|
||||||
}
|
}
|
||||||
|
#if bonus { [ (Bonus)] }
|
||||||
|
#if challenge { [ (Herausforderung)] }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,8 +95,26 @@
|
|||||||
[*#task-label #task-counter.display()*]
|
[*#task-label #task-counter.display()*]
|
||||||
|
|
||||||
if title != none and title != [] { [ --- #title] }
|
if title != none and title != [] { [ --- #title] }
|
||||||
|
|
||||||
|
if bonus {
|
||||||
|
h(1.2em)
|
||||||
|
tag([BONUS])
|
||||||
|
}
|
||||||
|
|
||||||
|
if challenge {
|
||||||
|
h(1.2em)
|
||||||
|
tag([HERAUSFORDERUNG])
|
||||||
|
}
|
||||||
|
|
||||||
h(1fr)
|
h(1fr)
|
||||||
if shown-points != none and shown-points > 0 { [#shown-points P.] }
|
|
||||||
|
if shown-points != none and shown-points > 0 {
|
||||||
|
if bonus {
|
||||||
|
[+#shown-points P.]
|
||||||
|
} else {
|
||||||
|
[#shown-points P.]
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -98,6 +133,7 @@
|
|||||||
task-counter.step()
|
task-counter.step()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// deprecated, use #task instead
|
// deprecated, use #task instead
|
||||||
#let exercise = task
|
#let exercise = task
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user