Skip to content

Commit dc1d764

Browse files
authored
Merge pull request #139 from layer5io/fix-and-enhance-test-states
Fix and enhance test states
2 parents b6db9b0 + 0154650 commit dc1d764

File tree

6 files changed

+267
-56
lines changed

6 files changed

+267
-56
lines changed

archetypes/certification.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
type: "certification"
3+
title: '{{ replace .File.ContentBaseName `-` ` ` | title }}'
4+
id: "id-from-cloud-content-wizard"
5+
description: "This is a sample certification description. It provides an overview of what the certification covers and its objectives."
6+
banner: "image.png"
7+
weight: 1
8+
draft: true
9+
tags: [cloud, infrastructure]
10+
level: "beginner"
11+
categories: "platform"
12+
13+
14+
# Table of content covered in the test
15+
# Each domain can have a weightage (percentage) and subdomains (items)
16+
# Weightage should sum up to 100 across all domains ( not strictly enforced, but recommended )
17+
competencies:
18+
- title: "Domain 1"
19+
percentage: 10 # Weightage of this domain in the test
20+
items:
21+
- "Subdomain 1"
22+
- "Subdomain 2"
23+
24+
- title: "Domain 2"
25+
percentage: 30
26+
items:
27+
- "Subdomain 1"
28+
- "Subdomain 2"
29+
30+
- title: "Domain 3"
31+
percentage: 60
32+
items:
33+
- "Subdomain 1"
34+
- "Subdomain 2"
35+
36+
37+
38+
# List of resource that are recommended to complete before taking the test
39+
# Not strictly enforced, but recommended
40+
prerequisite_knowledge:
41+
- title: "Learning Path: Cloud Computing Basics"
42+
link: "https://academy-domain.com/learning-paths/cloud-computing-basics"
43+
- title: "Basic Certification: Networking Basics"
44+
link: "https://academy-domain.com/certifications/networking-basics"
45+
- title: "Basic knowledge of Linux command line"
46+
link: "https://linuxcommand.org/"
47+
48+
# List of additional resources for further reading
49+
related_resources:
50+
- title: "Documentation"
51+
link: "https://docs.example.com/"
52+
- title: "Instructions"
53+
link: "https://instructions.example.com/"
54+
- title: "YouTube Channel"
55+
link: "https://www.youtube.com/c/example"
56+
57+
# Additional attributes about the test
58+
additional_attributes:
59+
- title: "Retake Policy"
60+
description: "One Retake allowed after 30 days"
61+
- title: "Labs"
62+
description: "Hands-on labs included"
63+
64+
65+
---

archetypes/challenge.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
type: 'challenge'
3+
title: '{{ replace .File.ContentBaseName `-` ` ` | title }}'
4+
id: "id-from-cloud-content-wizard"
5+
description: "provide an overview of what the challenge covers and its objectives."
6+
banner: "image.png"
7+
weight: 1
8+
draft: true
9+
tags: [cloud, infrastructure]
10+
level: "beginner"
11+
categories: "platform"
12+
13+
14+
# Table of content covered in the test
15+
# Each domain can have a weightage (percentage) and subdomains (items)
16+
# Weightage should sum up to 100 across all domains ( not strictly enforced, but recommended )
17+
competencies:
18+
- title: "Domain 1"
19+
percentage: 10 # Weightage of this domain in the test
20+
items:
21+
- "Subdomain 1"
22+
- "Subdomain 2"
23+
24+
- title: "Domain 2"
25+
percentage: 30
26+
items:
27+
- "Subdomain 1"
28+
- "Subdomain 2"
29+
30+
- title: "Domain 3"
31+
percentage: 60
32+
items:
33+
- "Subdomain 1"
34+
- "Subdomain 2"
35+
36+
37+
38+
# List of resource that are recommended to complete before taking the test
39+
# Not strictly enforced, but recommended
40+
prerequisite_knowledge:
41+
- title: "Learning Path: Cloud Computing Basics"
42+
link: "https://academy-domain.com/learning-paths/cloud-computing-basics"
43+
- title: "Basic Certification: Networking Basics"
44+
link: "https://academy-domain.com/certifications/networking-basics"
45+
- title: "Basic knowledge of Linux command line"
46+
link: "https://linuxcommand.org/"
47+
48+
# List of additional resources for further reading
49+
related_resources:
50+
- title: "Documentation"
51+
link: "https://docs.example.com/"
52+
- title: "Instructions"
53+
link: "https://instructions.example.com/"
54+
- title: "YouTube Channel"
55+
link: "https://www.youtube.com/c/example"
56+
57+
# Additional attributes about the test
58+
additional_attributes:
59+
- title: "Retake Policy"
60+
description: "One Retake allowed after 30 days"
61+
- title: "Labs"
62+
description: "Hands-on labs included"
63+
64+
65+
---

archetypes/learning-path.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
type: "learning-path"
3+
title: '{{ replace .File.ContentBaseName `-` ` ` | title }}'
4+
id: "id-from-cloud-content-wizard"
5+
description: "Provide an overview of what the learning path covers and its objectives."
6+
banner: "image.png"
7+
weight: 1
8+
draft: true
9+
tags: [cloud, infrastructure]
10+
level: "beginner"
11+
categories: "platform"
12+
13+
14+
# Table of content covered in the test
15+
# Each domain can have a weightage (percentage) and subdomains (items)
16+
# Weightage should sum up to 100 across all domains ( not strictly enforced, but recommended )
17+
competencies:
18+
- title: "Domain 1"
19+
percentage: 10 # Weightage of this domain in the test
20+
items:
21+
- "Subdomain 1"
22+
- "Subdomain 2"
23+
24+
- title: "Domain 2"
25+
percentage: 30
26+
items:
27+
- "Subdomain 1"
28+
- "Subdomain 2"
29+
30+
- title: "Domain 3"
31+
percentage: 60
32+
items:
33+
- "Subdomain 1"
34+
- "Subdomain 2"
35+
36+
37+
38+
# List of resource that are recommended to complete before taking the test
39+
# Not strictly enforced, but recommended
40+
prerequisite_knowledge:
41+
- title: "Learning Path: Cloud Computing Basics"
42+
link: "https://academy-domain.com/learning-paths/cloud-computing-basics"
43+
- title: "Basic Certification: Networking Basics"
44+
link: "https://academy-domain.com/certifications/networking-basics"
45+
- title: "Basic knowledge of Linux command line"
46+
link: "https://linuxcommand.org/"
47+
48+
# List of additional resources for further reading
49+
related_resources:
50+
- title: "Documentation"
51+
link: "https://docs.example.com/"
52+
- title: "Instructions"
53+
link: "https://instructions.example.com/"
54+
- title: "YouTube Channel"
55+
link: "https://www.youtube.com/c/example"
56+
57+
# Additional attributes about the test
58+
additional_attributes:
59+
- title: "Retake Policy"
60+
description: "One Retake allowed after 30 days"
61+
- title: "Labs"
62+
description: "Hands-on labs included"
63+
64+
65+
---

archetypes/test.md

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,64 +2,12 @@
22
title: 'test'
33
pass_percentage: 70 # Minimum percentage required to pass the test
44
time_limit: 15 # Duration of the test in minutes
5-
max_attempts: 3 # Maximum number of attempts allowed for the test
5+
max_attempts: 3 # Maximum number of attempts allowed
66
difficulty: "beginner" # Difficulty level of the test
77
category: "Programming Languages" # Category of the test
88
tags: ["golang", "basics", "syntax", "fundamentals"] # Tags for the test, useful for search and categorization
99
type: "test" # Type of the content, in this case, a test ( required for the test to be recognized by the system )
1010

11-
12-
# Table of content covered in the test
13-
# Each domain can have a weightage (percentage) and subdomains (items)
14-
# Weightage should sum up to 100 across all domains ( not strictly enforced, but recommended )
15-
competencies:
16-
- title: "Domain 1"
17-
percentage: 10 # Weightage of this domain in the test
18-
items:
19-
- "Subdomain 1"
20-
- "Subdomain 2"
21-
22-
- title: "Domain 2"
23-
percentage: 30
24-
items:
25-
- "Subdomain 1"
26-
- "Subdomain 2"
27-
28-
- title: "Domain 3"
29-
percentage: 60
30-
items:
31-
- "Subdomain 1"
32-
- "Subdomain 2"
33-
34-
35-
36-
# List of resource that are recommended to complete before taking the test
37-
# Not strictly enforced, but recommended
38-
prerequisite_knowledge:
39-
- title: "Learning Path: Cloud Computing Basics"
40-
link: "https://academy-domain.com/learning-paths/cloud-computing-basics"
41-
- title: "Basic Certification: Networking Basics"
42-
link: "https://academy-domain.com/certifications/networking-basics"
43-
- title: "Basic knowledge of Linux command line"
44-
link: "https://linuxcommand.org/"
45-
46-
# List of additional resources for further reading
47-
related_resources:
48-
- title: "Documentation"
49-
link: "https://docs.example.com/"
50-
- title: "Instructions"
51-
link: "https://instructions.example.com/"
52-
- title: "YouTube Channel"
53-
link: "https://www.youtube.com/c/example"
54-
55-
# Additional attributes about the test will be displayed in the test details page
56-
additional_attributes:
57-
- title: "Retake Policy"
58-
description: "One Retake allowed after 30 days"
59-
- title: "Labs"
60-
description: "Hands-on labs included"
61-
62-
6311
questions:
6412
# Multiple Choice Question (Single Answer)
6513
- id: "q1"

layouts/partials/test/single.html

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,36 @@
22
{{- $prerequisites := partial "test/collect-prerequisites.html" . -}}
33
{{- $ctx := partial "resolve-tenant.html" . -}}
44
{{- $orgId := $ctx.uuid -}}
5+
{{- $id := partial "id.html" . -}}
6+
7+
{{- $totalQuestionsPerSet := $p.number_of_questions | default (len $p.questions) -}}
8+
9+
<!-- Validate: TotalQuestions should be multiple of totalQuestionsPerSet -->
10+
{{- if ne (mod (len $p.questions) $totalQuestionsPerSet) 0 -}}
11+
{{- errorf "Total questions (%d) is not a multiple of total_questions_per_set (%d)" (len $p.questions) $totalQuestionsPerSet -}}
12+
{{- end -}}
13+
14+
<!-- Validate all question ids are unique -->
15+
{{- $questionIds := (slice ) -}}
16+
{{- range $p.questions -}}
17+
{{- if in $questionIds .id -}}
18+
{{- errorf "Duplicate question id found: %s" .id -}}
19+
{{- end -}}
20+
{{- $questionIds = $questionIds | append (string $id) -}}
21+
{{- end -}}
22+
23+
{{- $numberOfQuestionSets := div (len $p.questions) $totalQuestionsPerSet -}}
524

625
{{- $total := 0 -}}
7-
{{- range $p.questions }}
26+
{{- range first $totalQuestionsPerSet $p.questions -}}
827
{{- $total = add $total (or .marks 0) }}
928
{{- end }}
1029

30+
{{- $maxAttempts := or $p.max_attempts 0 -}}
31+
{{- if and (eq $maxAttempts 0) (gt $numberOfQuestionSets 1) -}}
32+
{{ $maxAttempts = $numberOfQuestionSets -}}
33+
{{- end -}}
34+
1135
{{- $parent := (cond (ne .Parent nil) (dict
1236
"id" (partial "id.html" .Parent)
1337
"title" .Parent.Title
@@ -31,11 +55,13 @@
3155
"lastmod" (.Lastmod | time.Format "2006-01-02")
3256
"draft" .Draft
3357
"file_path" .File.Path
34-
"max_attempts" (or $p.max_attempts 0)
58+
"max_attempts" $maxAttempts
59+
"total_question_sets" $numberOfQuestionSets
60+
"total_questions_in_bank" (len $p.questions)
3561
"pass_percentage" (or $p.pass_percentage 70)
3662
"time_limit" (or $p.time_limit 0 | string)
3763
"questions" $p.questions
38-
"total_questions" (len $p.questions)
64+
"total_questions" $totalQuestionsPerSet
3965
"prerequisites" $prerequisites
4066
"total_marks" $total
4167
"parent" $parent

layouts/test/single.html

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,48 @@ <h1>{{ $title }}</h1>
301301
</div>
302302
</div>
303303

304+
{{ else }}
305+
306+
<!-- In production build, show a loader while redirecting to the test page -->
307+
<style>
308+
/* HTML: <div class="loader"></div> */
309+
.loader {
310+
width: 50px;
311+
padding: 8px;
312+
aspect-ratio: 1;
313+
border-radius: 50%;
314+
background: var(--bs-primary);
315+
--_m:
316+
conic-gradient(#0000 10%, #000),
317+
linear-gradient(#000 0 0) content-box;
318+
-webkit-mask: var(--_m);
319+
mask: var(--_m);
320+
-webkit-mask-composite: source-out;
321+
mask-composite: subtract;
322+
animation: l3 1s infinite linear;
323+
}
324+
325+
.loader-container {
326+
display: flex;
327+
flex-direction: column;
328+
justify-content: center;
329+
align-items: center;
330+
height: 90vh;
331+
text-align: center;
332+
}
333+
334+
@keyframes l3 {
335+
to {
336+
transform: rotate(1turn)
337+
}
338+
}
339+
</style>
340+
<div class="loader-container">
341+
<div class="loader">
342+
</div>
343+
<p class="loader-text">Preparing your test...</p>
344+
</div>
345+
304346
{{ end }}
305347

306348
{{ $test := partial "test/single.html" . }}

0 commit comments

Comments
 (0)