Skip to content

Commit

Permalink
Fix sutde-data configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
andres-gimenez committed Nov 14, 2024
1 parent 6a56175 commit f75eb5d
Show file tree
Hide file tree
Showing 7 changed files with 179 additions and 5 deletions.
46 changes: 45 additions & 1 deletion docs-shiroa/g-exam-doc/configuration/student-data.typ
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ template by means of the "show-studen-data" property indicating how you want thi
Values can be:

- first-page: It will only appear on the first page.
- all-pages: The header will be displayed on all pages.
- odd-pages: It will appear on odd-numbered pages.
- none: The user information box will not appear.

Expand All @@ -21,4 +22,47 @@ The following example will display student information on the first page.
)
```
```

To display it on all pages

```typst
#show: exam.with(
show-studen-data: "all-page",
)
```

If we want it to be displayed in all odd numbers. This is useful if we print the exam double-sided, as the header will appear on the first page of each sheet.

```typst
#show: exam.with(
show-studen-data: "odd-page",
)
```

== Configuration

To configure each field of the student information separately, we must configure it in the form of a collection as follows.

```typst
#show: exam.with(
show-student-data:
(
given-name: "odd-page",
family-name: "odd-page",
group: false,
date: "first-page"
),
)
```

With this example, the name and family name will appear on the odd and date pages only on the first page and the group does not appear.
18 changes: 14 additions & 4 deletions src/auxiliary.typ
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
show-student-number: 1,
) = {

// [#page \ ]
// [#show-student-data \ ]
// [#type(show-student-data) \ ]

let family-label = [
#context __g-localization.final().family-name: #box(width: 2fr, repeat[.])
]
Expand Down Expand Up @@ -60,19 +56,33 @@
let group-value = show-student-data.at("group", default: "first-page")
let date-value = show-student-data.at("date", default: "first-page")

assert(family-name-value in (none, true, false, "first-page", "all-pages", "odd-pages"), message: "Invalid family-name value in show-student-data")
assert(give-name-value in (none, true, false, "first-page", "all-pages", "odd-pages"), message: "Invalid give-name-value value in show-student-data")
assert(group-value in (none, true, false, "first-page", "all-pages", "odd-pages"), message: "Invalid group-value value in show-student-data")
assert(date-value in (none, true, false, "first-page", "all-pages", "odd-pages"), message: "Invalid date-value value in show-student-data")

// [#family-name-value - #page \ ]
// if page == "first" or page == "pair" {
// [si \ ]
// }

if family-name-value == false or (family-name-value == "first-page" and page != "first") or (family-name-value == "odd-pages" and not(page == "first" or page == "odd")) {
// [2-a #family-name-value - #page \ ]
family-label = []
}

if give-name-value == false or (give-name-value == "first-page" and page != "first") or (give-name-value == "odd-pages" and not(page == "first" or page == "odd")) {
// [2-b #give-name-value - #page \ ]
give-label = []
}

if group-value == false or (group-value == "first-page" and page != "first") or (group-value == "odd-pages" and not(page == "first" or page == "odd")) {
// [2-c #group-value - #page \ ]
group-label = []
}

if date-value == false or (date-value == "first-page" and page != "first") or (date-value == "odd-pages" and not(page == "first" or page == "odd")) {
// [2-d #date-value - #page \ ]
date-label = []
}
}
Expand Down
27 changes: 27 additions & 0 deletions test/student-data/test-001-show(none).typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#import "../../src/lib.typ": *

#show: exam.with(
show-student-data: false,
show-grade-table: false,
)

Hello, how are you doing?
#pagebreak()

Page 2
#pagebreak()

Page 3
#pagebreak()

Page 4
#pagebreak()

Page 5
#pagebreak()

Page 6
#pagebreak()

Page 7
#pagebreak()
27 changes: 27 additions & 0 deletions test/student-data/test-005-not-show.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#import "../../src/lib.typ": *

#show: exam.with(
show-student-data: none,
show-grade-table: false,
)

Hello, how are you doing?
#pagebreak()

Page 2
#pagebreak()

Page 3
#pagebreak()

Page 4
#pagebreak()

Page 5
#pagebreak()

Page 6
#pagebreak()

Page 7
#pagebreak()
33 changes: 33 additions & 0 deletions test/student-data/test-009-Configuration1.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#import "../../src/lib.typ": *

#show: exam.with(
show-student-data:
(
given-name: "odd-pages",
family-name: "odd-pages",
group: false,
date: "first-page"
),
show-grade-table: false,
)

Hello, how are you doing?
#pagebreak()

Page 2
#pagebreak()

Page 3
#pagebreak()

Page 4
#pagebreak()

Page 5
#pagebreak()

Page 6
#pagebreak()

Page 7
#pagebreak()
33 changes: 33 additions & 0 deletions test/student-data/test-009-Configuration2.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#import "../../src/lib.typ": *

#show: exam.with(
show-student-data:
(
given-name: "odd-pages",
family-name: "all-pages",
group: "first-page",
date: false
),
show-grade-table: false,
)

Hello, how are you doing?
#pagebreak()

Page 2
#pagebreak()

Page 3
#pagebreak()

Page 4
#pagebreak()

Page 5
#pagebreak()

Page 6
#pagebreak()

Page 7
#pagebreak()

0 comments on commit f75eb5d

Please sign in to comment.