feat: add task bonus and challenge labels
This commit is contained in:
1 file changed
+42
-6
@@ -2,7 +2,6 @@
|
||||
|
||||
#let default-theme = (
|
||||
primary: rgb("#0E7C7B"),
|
||||
secondary: rgb("#D4F4ED"),
|
||||
accent: rgb("#FFC857"),
|
||||
warning: rgb("#E9724C"),
|
||||
error: rgb("#C5283D"),
|
||||
@@ -24,14 +23,26 @@
|
||||
#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,))
|
||||
|
||||
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 border-color = theme.primary
|
||||
let background-color = theme.primary.transparentize(95%)
|
||||
let border-color = col
|
||||
let background-color = col.transparentize(95%)
|
||||
let task-label = if label == none { task-label-state.get() } else { label }
|
||||
|
||||
let subtask-points = query(
|
||||
@@ -43,6 +54,10 @@
|
||||
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 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)
|
||||
|
||||
task-active.update(true)
|
||||
@@ -70,6 +85,8 @@
|
||||
#if title != none and title != [] {
|
||||
[ — #title]
|
||||
}
|
||||
#if bonus { [ (Bonus)] }
|
||||
#if challenge { [ (Herausforderung)] }
|
||||
]
|
||||
}
|
||||
|
||||
@@ -78,8 +95,26 @@
|
||||
[*#task-label #task-counter.display()*]
|
||||
|
||||
if title != none and title != [] { [ --- #title] }
|
||||
|
||||
if bonus {
|
||||
h(1.2em)
|
||||
tag([BONUS])
|
||||
}
|
||||
|
||||
if challenge {
|
||||
h(1.2em)
|
||||
tag([HERAUSFORDERUNG])
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
|
||||
// deprecated, use #task instead
|
||||
#let exercise = task
|
||||
|
||||
|
||||
Reference in new issue
Block a user