summary refs log tree commit diff stats
path: root/mysql-php/tpl.typ
diff options
context:
space:
mode:
authorSudipto Mallick <smlckz@termux-alpine>2024-02-08 11:08:33 +0000
committerSudipto Mallick <smlckz@termux-alpine>2024-02-08 11:08:33 +0000
commit02884d29e4f5aea71364a203dcaecd53600d8aa4 (patch)
tree0047b71f3677132fd6319919233e8ce5da43ad6d /mysql-php/tpl.typ
parent0ac38a6f4ce7144635525a5a73bf2946d2909fa6 (diff)
downloadzadania-02884d29e4f5aea71364a203dcaecd53600d8aa4.tar.gz
Complete PHP assignments
Diffstat (limited to 'mysql-php/tpl.typ')
-rw-r--r--mysql-php/tpl.typ103
1 files changed, 76 insertions, 27 deletions
diff --git a/mysql-php/tpl.typ b/mysql-php/tpl.typ
index 28c8343..b645605 100644
--- a/mysql-php/tpl.typ
+++ b/mysql-php/tpl.typ
@@ -1,55 +1,104 @@
 #import "@preview/codelst:1.0.0": sourcefile
-#let hlfile(filename) = sourcefile(read(filename), file: filename)
-#let apply(body) = {
-  let body-font-settings = (font: "Nunito Sans 10pt", size: 12pt, stretch: 75%)
-//  let body-font-settings = (font: "Hanken Grotesk", size: 12pt, stretch: 75%)
-  let page-margin = (left: 0.75in, right: 0.25in, top: 0.5in, bottom: 0.25in)
-  let margin = (left: 0.75in, right: 0.25in, top: 2em, bottom: 2em)
-  let page-frame-thickness = 1.5pt
+
+/* Highlights the source code file. */
+#let highlight-code-file(filename) = sourcefile(read(filename), file: filename)
+
+/* The state variable to indicate whether the end of an assignment is reached. */
+#let eoa = state("is-at-end-of-assignment", false)
+
+/* Updates the state variable to indicate the end of an assignment. */
+#let signature() = {
+  eoa.update(true)
+}
+
+/* Draws the signature construct at the bottom right corner in the footer of the last page of an assignment. */
+#let signature-footer(loc) = {
+  if eoa.at(loc) {
+    align(bottom + right,
+      move(dy: -4em, dx: -1em,
+        block(width: 15em)[
+          #v(3em)
+          #line(length: 100%) \
+          #v(-2.5em)
+          #align(center)[Teacher’s signature]
+        ]))
+    eoa.update(false)
+  }
+}
+
+/* Draws page border around the provided content, taking an optional function to be called at the footer. */
+#let apply-page-borders(body, font-options: (), footer-special-func: none, page-numbering: none) = {
+  let page-margin = (left: 0.75in, right: 0.25in, top: 0.25in, bottom: 0.25in)
+  let margin = (left: 0.65in, right: 0.15in, top: 1.5em, bottom: 1.5em)
+  let page-border-thickness = 1.25pt
   set page(
     margin: (..page-margin, bottom: margin.bottom + 2em),
-    numbering: "1",
-    background: align(top + start, pad(..margin, rect(width: 100%, height: 100%, stroke: page-frame-thickness + gray))),
-    footer: locate(loc => align(center, move(dy: -margin.bottom + 1em, text(..body-font-settings, size: 9pt, counter(page).display(loc.page-numbering())))))
+    numbering: if page-numbering != none { page-numbering } else { "1" },
+    background: align(top + start, pad(..margin, rect(width: 100%, height: 100%, stroke: page-border-thickness + gray, radius: 5pt))),
+    footer: locate(loc => {
+      align(center, move(dy: -margin.bottom + 1em, text(..font-options, size: 9pt, counter(page).display(loc.page-numbering()))))
+      if footer-special-func != none {
+        footer-special-func(loc)
+      }
+    })
   )
-  show: block.with(breakable: true, width: 100%, inset: page-frame-thickness + 1em)
-  
-  set text(..body-font-settings)
+  show: block.with(breakable: true, width: 100%, inset: page-border-thickness + 1em) 
+  body
+}
 
-  let code-color = rgb("#f4f4f4")
-//  show raw: set text(font: "CommitMono", size: 1.1em)
-//  show raw: set text(font: "Source Code Pro", size: 1.1em)
+#let apply(body, page-numbering: none) = {
+  let body-font-settings = (font: "Nunito Sans 10pt", size: 12pt, stretch: 75%)
+  set text(..body-font-settings)
   show raw: set text(font: "Iosevka Fixed", size: 1.1em)
   show raw.where(block: false): box.with(
-    fill: code-color,
     inset: (x: 3pt, y: 0pt),
     outset: (y: 3pt),
     radius: 2pt,
   )
   show raw.where(block: true): block.with(
-    fill: code-color,
     inset: 10pt,
     radius: 4pt,
     width: 100%,
   )
   show raw.where(block: true): it => align(left, it)
   set raw(theme: "vendor/gr.tmTheme")
-  set list(marker: ([--]))
-  set par(leading: 0.6em)
-  body
+  set list(marker: ([$square.filled.tiny$], [--]))
+  set par(leading: 0.5em)
+  apply-page-borders(body, font-options: body-font-settings, footer-special-func: signature-footer, page-numbering: page-numbering)
 }
 
-#let assignment(number, description) = align(center, [
+
+#let alist = state("assignment-list", ())
+
+#let list-of-assignments(contents) = locate(loc => {
+  let assignment-list = alist.final(loc)
+  let last-page-number = counter(page).final(loc).first()
+  contents(assignment-list, last-page-number)
+})
+
+#let list-of-dates = ([11/09/2023], [16/09/2023], [26/09/2023], [04/10/2023], [09/10/2023], [10/10/2023], [13/10/2023], [16/10/2023], [21/11/2023], [28/11/2023], [02/12/2023], [04/12/2023], [04/12/2023], [05/12/2023], [19/12/2023], [02/01/2024], [08/01/2024], [09/01/2024], [15/01/2024], [18/01/2024])
+#let assignment-dates-indices = (15, 16, 17, 18, 19)
+
+#let assignment(number, description, reduce-gap: false, pad: false) = align(center, [
 = #text(weight: 600, [Assignment #number])
-== #text(weight: 500, [Program description:]) #text(weight: 400, description)
+  #{
+    let date = list-of-dates.at(assignment-dates-indices.at(number - 1) - 1)
+    v(-1.65em)
+    align(right, [Date: #date])
+    if reduce-gap { v(-0.75em) }
+    align(left)[
+      #set par(justify: true)
+== #text(weight: 500, [Program statement:]) #text(weight: 400, description)
+    ]
+    locate(loc => alist.update(lst => (..lst, (number: number, description: description, page-number: counter(page).at(loc).first(), date: date))))
+  }
 ])
-#let objective(body) = align(center, [*Objective*: #body])
-#let oset(kind) = block(spacing: 0.6em, [===== #h(1em) #kind])
 
-#let scos(n, obody) = [
+#let scos(n, obody, cont: false) = [
   === Source Code
   #show raw: set text(size: 10pt)
-  #hlfile("/code/a" + str(n) + ".php")
+  #highlight-code-file("/code/a" + str(n) + ".php")
+  #if cont == true [ #colbreak() ]
   === Output
   #obody
 ]