Hi there @posedge_clk and welcome to the forum!
Thanks for sharing your code and providing an example that compiles.
Here is a more-MWE like version of your code showing the issue:
#let exercise-counter = counter("exercise")
#let total-points = state("total-points", 0)
#let current-exercise-points = state("current-exercise-points", 0)
#let strings-de = (
task: "Task",
points: "Points",
point: "Point",
)
#let exercise(title, body) = context {
let strings = strings-de
set enum(numbering: "a)")
// Increment exercise counter
exercise-counter.step()
let ex-num = exercise-counter.get().first()
// Reset and calculate points by processing body
current-exercise-points.update(0)
// Process body to count points
let _ = body
// Get the points that were accumulated
let ex-points = current-exercise-points.get()
// Add to total points
total-points.update(t => t + ex-points)
let ex-display-num = ex-num + 1
// Exercise header
[
#text(size: 14pt, weight: "bold")[
#ex-display-num. #strings.task: #title (#ex-points #if ex-points == 1 { strings.point } else { strings.points })
]
]
body
}
#let points(n) = {
let strings = strings-de
// Add to current exercise points
current-exercise-points.update(p => p + n)
[(#n #if n == 1 { strings.point } else { strings.points })]
}
#let point-summary() = context {
let strings = strings-de
let total = total-points.final()
text(weight: "bold")[
Total *#total #if total == 1 { strings.point } else { strings.points }*
]
}
#text(red)[Should show 10 points #sym.arrow ]
#point-summary()
#exercise(
text(red)[Should show 3 points],
)[+ Should show 3 points? #points(3)]
#exercise(
text(red)[Should show 7 points],
)[+ Should show 7 points? #points(7)]
Without any doubt, the solution resides in this forum post:
and has to do with your usage of context, state and update.
You will have to make a few modifications in your exercise and point-summary functions.
As a side note, you can always inspire yourself from existing exam packages that show the same kind of output.