#import "@preview/problemst:0.1.0": pset

// Adding scores to the document
#let wrapper(doc) = {
  set rect(stroke: 0.3pt)
  grid(
    columns: (auto, auto, auto, 1fr, auto),
    ..range(4).map(n => rect(width: 80pt, height: 40pt, text([A#(n+1)]))),
    rect(width: 100pt, height: 40pt, text($sum$))
  )
  line(length: 100% )

  // Reset the rect stroke
  set rect(stroke: auto)
  // Doc wrapper
  outline()
  
  doc
}


// Configuration for the Sheets
#let conf(week: "?", doc) = {
  // Global configs
  set enum(numbering: "a)")
  set line(stroke: 1pt)
  set math.equation(numbering: "(1)")

  // Wrap the doc before passing it to the template
  // Addiung score boxes
  let doc = wrapper(doc)

  
  // Setting the references right
  show ref: it => {
  let eq = math.equation
  let el = it.element
  if el != none and el.func() == eq {
    // Override equation references.
    link(el.location(),numbering(
      el.numbering,
      ..counter(eq).at(el.location())
    ))
  } else {
    // Other references as usual.
    it
  }
}

  // Show the template for ease of use
  // Do this at last
  show: pset(
    class: "AGLA",
    student: "Max Offermann, Tom Witjes und Jonas Hahn",
    title: [Woche #week],
    date: datetime.today(),
    doc
  )
}

// Configuration for the Vorlesungen (vl)
#let vl(doc) = {
  // Global settings
  set page(numbering: "1")
  set heading(numbering: "1.1")

  // Add some content to the docs
  outline()

  // Load the document
  doc
}
