Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 48 additions & 9 deletions examples/exam_example.typ
Original file line number Diff line number Diff line change
Expand Up @@ -432,15 +432,6 @@ Use the code block to answer the following questions:
[```java ArrayList```s are faster than ```java LinkedList```s at retrieval operations], // T
)

#e.tf-block([Mark the following statements as either True (T) of False (F):], points: 5,
[```java LinkedList``` utilizes nodes and next pointers to store information], // T
[```java ArrayList``` is always faster than ```java LinkedList```], // F
[```java ArrayList``` has more flexible memory usage than ```java LinkedList```], // F
[```java ArrayList``` and ```java LinkedList``` implement the same ADT], // T
[```java ArrayList```s are faster than ```java LinkedList```s at retrieval operations], // T
)



Fill in some code below:
#code-block(
Expand All @@ -454,3 +445,51 @@ Fill in some code below:

)
```, width: 100%)



#pagebreak()
#e.tf-block([Mark the following statements as either True (T) of False (F):], points: 5,
[```java LinkedList``` utilizes nodes and next pointers to store information], // T
[```java ArrayList``` is always faster than ```java LinkedList```], // F
[```java ArrayList``` has more flexible memory usage than ```java LinkedList```], // F
[```java ArrayList``` and ```java LinkedList``` implement the same ADT], // T
[```java ArrayList```s are faster than ```java LinkedList```s at retrieval operations], // T
)




#e.question-block([Use the block to answer the following questions:],
() => e.short-answer(
"What is the time complexity of the method shown above?",
lines: 2,
points: 2
),
() => e.multiple-choice(
"Which data structure would optimize this code?",
points: 1,
cols: 2,
[Array List],
[Hash Map],
[Linked List],
[Binary Tree]
)
)

#e.tf-block([Mark the following statements as either True (T) of False (F):], points: 5,
[```java LinkedList``` utilizes nodes and next pointers to store information], // T
[```java ArrayList``` is always faster than ```java LinkedList```], // F
[```java ArrayList``` has more flexible memory usage than ```java LinkedList```], // F
[```java ArrayList``` and ```java LinkedList``` implement the same ADT], // T
[```java ArrayList```s are faster than ```java LinkedList```s at retrieval operations], // T
)
#e.tf-block([Mark the following statements as either True (T) of False (F):], points: 5,
[```java LinkedList``` utilizes nodes and next pointers to store information], // T
[```java ArrayList``` is always faster than ```java LinkedList```], // F
[```java ArrayList``` has more flexible memory usage than ```java LinkedList```], // F
[```java ArrayList``` and ```java LinkedList``` implement the same ADT], // T
[```java ArrayList```s are faster than ```java LinkedList```s at retrieval operations], // T
)

#e.question("Please write your favorite algorithm below:", points: 4)
46 changes: 42 additions & 4 deletions src/exams.typ
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@
"num-qs", 1
)

#let cur-sub-question = counter(
"sub-question-n"
)


/// question: Create a generic question
/// - body (content, str): Question Body
Expand All @@ -121,15 +125,31 @@
message: "Expected points to be int, but received" + str(type(points))
)

cur-question.update(n => n + 1)
total-points.update(p => p + points)
let qnum = cur-question.get()

let q-num = cur-question.get()

// counters return an array, despite only having 1 value
// this relies that is set in question-block
let sub-val = cur-sub-question.get().at(0)
let has-sub = sub-val != 0

let sub-label = if has-sub {
[#cur-sub-question.display("A")]
} else {
none
}

// only update the q num if the question has NO sub questions
if not has-sub {
cur-question.update(n => n + 1)
}

block(width: 100%, breakable: true, inset: (bottom: 0.5em))[
#grid(
columns: (20pt, 1fr),
column-gutter: 8pt,
text(weight: "bold")[#qnum.],
// TIL ~ is a non-breaking space
text(weight: "bold")[#q-num~#sub-label.],
[#body #h(5pt) (#points pts)]
)
]
Expand Down Expand Up @@ -499,3 +519,21 @@
}



#let question-block(q-body, ..questions) = {
// basically just a wrapper, that manages some state for the question() function
cur-sub-question.update(1)

for q in questions.pos() {
q()
cur-sub-question.step()
}

// disable sub-question state
// and keep the cur-question moving
cur-question.update(n => n + 1)
cur-sub-question.update(0)


}

Loading