Skip to content
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ resources/

#hugo
.hugo_build.lock
content/

.DS_Store
1 change: 1 addition & 0 deletions archetypes/final-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ final: true # Indicates that this test is the final exam and must be completed t

questions:
# Multiple Choice Question (Single Answer)
# NOTE: The 'marks' field must be a positive number (greater than 0). Negative or zero values will cause a build error.
- id: "q1"
text: "What keyword is used to define a function in Go?"
type: "multiple_answers"
Expand Down
1 change: 1 addition & 0 deletions archetypes/optional-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ is_optional: true # Indicates that this test is optional and does not need to be

questions:
# Multiple Choice Question (Single Answer)
# NOTE: The 'marks' field must be a positive number (greater than 0). Negative or zero values will cause a build error.
- id: "q1"
text: "What keyword is used to define a function in Go?"
type: "multiple_answers"
Expand Down
2 changes: 1 addition & 1 deletion archetypes/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ questions:
# Multiple Choice Question (Single Answer)
- id: "q1"
text: "What keyword is used to define a function in Go?"
type: "multiple-answers"
type: "multiple_answers"
marks: 2
explanation: "The 'func' keyword is used to declare functions in Go, similar to how 'function' is used in JavaScript."
options:
Expand Down
8 changes: 8 additions & 0 deletions layouts/partials/test/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
{{- $questionIds = $questionIds | append (string $id) -}}
{{- end -}}

<!-- Validate: marks must be positive (greater than 0) -->
{{- range $index, $question := $p.questions -}}
{{- $marks := or $question.marks 0 -}}
{{- if le $marks 0 -}}
{{- errorf "Question %d (id: %s) has invalid marks value '%v'. Marks must be greater than 0. Please update the 'marks' field with a positive number. [ %s ]" (add $index 1) $question.id $marks $.File.Path -}}
{{- end -}}
{{- end -}}

{{- $numberOfQuestionSets := div (len $p.questions) $totalQuestionsPerSet -}}

{{- $total := 0 -}}
Expand Down