-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexam.html
More file actions
159 lines (153 loc) · 7.54 KB
/
exam.html
File metadata and controls
159 lines (153 loc) · 7.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Hamlearn exam</title>
<link rel="preconnect" href="https://cdnjs.cloudflare.com" crossorigin>
<style>
:root { --bg:#0b1320; --card:#111a2c; --ink:#e8eefc; --muted:#98a3b8; --accent:#6aa8ff; --good:#1fbf75; --bad:#ff6b6b; }
*{box-sizing:border-box}
html,body{height:100%}
body{margin:0;background:linear-gradient(180deg,#0b1320,#0a1020);color:var(--ink);font:16px/1.5 system-ui,Segoe UI,Roboto,Helvetica,Arial,sans-serif;display:flex;align-items:center;justify-content:center}
.container{width:clamp(320px, 92vw, 900px);}
.card{background:var(--card);border:1px solid #1f2b46;box-shadow:0 10px 35px rgba(0,0,0,.35);border-radius:20px;padding:28px}
h1{margin:0 0 12px;font-weight:800;letter-spacing:.3px}
p.sub{margin-top:4px;color:var(--muted)}
button, .btn{cursor:pointer;border:0;border-radius:14px;padding:14px 18px;font-weight:700;letter-spacing:.3px}
.btn-primary{background:var(--accent);color:#06102b}
.btn-muted{background:#1a2540;color:var(--ink)}
.stack{display:flex;gap:12px;flex-wrap:wrap}
label.toggle{display:flex;align-items:center;justify-content:center;gap:10px;font-size:.95rem;color:var(--muted)}
label.toggle input{width:18px;height:18px}
.center{display:flex;align-items:center;justify-content:center;}
.hidden{display:none !important}
.row{display:flex;gap:24px;align-items:center}
.grow{flex:1}
.progress{height:8px;background:#1c2642;border-radius:999px;overflow:hidden}
.progress > div{height:8px;background:var(--accent);width:0}
.question{font-size:1.1rem;margin:10px 0 8px}
.question-figure{margin:16px 0;display:flex;justify-content:center;gap:16px}
.question-figure img{max-width:100%;border:1px solid #1f2b46;border-radius:12px}
.answers{display:grid;gap:10px;margin:18px 0}
label.option{display:flex;gap:10px;align-items:flex-start;background:#101a30;border:1px solid #1e2b49;padding:14px;border-radius:12px;}
label.option:hover{border-color:#2b3e6a}
.foot{display:flex;gap:10px;justify-content:space-between;align-items:center}
.notice{font-size:.95rem;color:var(--muted)}
.result{font-size:1.6rem;font-weight:800;margin:6px 0 10px}
.pass{color:var(--good)} .fail{color:var(--bad)}
input[type=file]{display:block;width:100%;padding:12px;background:#0e172c;border:1px dashed #2a3a64;border-radius:12px;color:var(--muted)}
.kbd{font:600 12px/1.2 ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;background:#0e172a;border:1px solid #213055;border-radius:6px;padding:3px 6px;color:#bcd3ff}
#score-report{margin:28px auto 0;max-width:100%;text-align:left}
#score-report table{width:100%;border-collapse:collapse;font-size:.95rem}
#score-report th,#score-report td{padding:10px 12px;border-bottom:1px solid #1f2b46;vertical-align:top}
#score-report th{text-transform:uppercase;font-size:.8rem;letter-spacing:.5px;color:var(--muted);font-weight:700}
#score-report tbody tr:last-child td{border-bottom:0}
#score-report .q-label{font-weight:700;font-size:.9rem;margin-bottom:4px;color:var(--ink)}
#score-report .q-text{color:var(--muted);font-size:.85rem}
#score-report .ans{display:block}
#score-report .status{font-weight:700}
#score-report .status.correct{color:var(--good)}
#score-report .status.incorrect{color:var(--bad)}
#score-report .status.not-answered{color:var(--muted)}
</style>
</head>
<body>
<div class="container">
<!-- LANDING -->
<section id="screen-landing" class="card center" aria-live="polite">
<div class="grow center" style="flex-direction:column;gap:16px;text-align:center">
<h1 id="landing-title"></h1>
<div class="grow"></div>
<label for="toggle-figures" class="toggle">
<input type="checkbox" id="toggle-figures" />
<span>remove image questions</span>
</label>
<div class="stack center">
<button id="btn-start" class="btn-primary">Start</button>
</div>
</div>
</section>
<!-- TEST UI -->
<section id="screen-test" class="card hidden" aria-live="polite">
<div class="row">
<h1 id="title-run" class="grow" style="margin-bottom:2px">Practice Test</h1>
<div style="text-align:right">
<div style="font-weight:700">Question <span id="q-num">1</span> / <span id="q-total"></span></div>
<div class="progress" aria-hidden="true"><div id="bar"></div></div>
</div>
</div>
<p id="q-text" class="question"></p>
<div id="figure-display" class="question-figure hidden"></div>
<fieldset id="answers" class="answers"></fieldset>
<div class="foot">
<div class="stack">
<button id="btn-prev" class="btn-muted">Previous</button>
<button id="btn-next" class="btn-muted">Next</button>
</div>
<button id="btn-submit" class="btn-primary">Submit</button>
</div>
<p class="notice" id="figure-hint" style="margin-top:8px;display:none">Figure reference shown below.</p>
</section>
<!-- RESULT -->
<section id="screen-result" class="card hidden center" aria-live="polite">
<div class="grow" style="text-align:center">
<div id="result-banner" class="result"></div>
<p id="score-line" class="sub"></p>
<div id="score-report"></div>
<div class="stack center" style="margin-top:10px">
<button id="btn-restart" class="btn-muted">Generate another test</button>
</div>
<div class="center" style="margin-top:8px">
<label for="toggle-figures-result" class="toggle">
<input type="checkbox" id="toggle-figures-result" />
<span>remove image questions</span>
</label>
</div>
</div>
</section>
</div>
<script src="app-utils.js"></script>
<script src="pool.js"></script>
<script src="exam-app.js"></script>
<script src="exams.js"></script>
<script>
(function(){
const global = window;
const registry = global.HAMLEARN_EXAMS;
if (!registry || typeof registry.init !== 'function') {
console.error('Exam registry unavailable.');
return;
}
const getExamId = () => {
const params = new URLSearchParams(global.location ? global.location.search : '');
const queryType = (params.get('type') || params.get('exam') || params.get('license') || '').toLowerCase();
if (queryType && registry.resolve(queryType)) return queryType;
const bodyAttr = (document.body && document.body.dataset && document.body.dataset.exam) || '';
if (bodyAttr && registry.resolve(bodyAttr)) return bodyAttr;
const available = registry.list();
return available.includes('technician') ? 'technician' : available[0];
};
const examId = getExamId();
try {
const instance = registry.init(examId);
if (instance && typeof instance === 'object') {
global.HAMLEARN_ACTIVE_EXAM = instance;
// Set the question total dynamically from config
const config = registry.resolve(examId);
if (config && config.totalQuestions) {
const totalElement = document.getElementById('q-total');
if (totalElement) {
totalElement.textContent = config.totalQuestions;
}
}
}
} catch (err) {
const message = err && err.message ? err.message : 'Unable to start the exam.';
global.alert(message);
console.error(err);
}
})();
</script>
</body>
</html>