icoa-cli 2.19.72 → 2.19.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/exam.js +17 -3
- package/package.json +1 -1
package/dist/commands/exam.js
CHANGED
|
@@ -342,10 +342,10 @@ function printQuestionProgress(current, total, answered) {
|
|
|
342
342
|
console.log(` ${chalk.gray('⏱ Time remaining:')} ${color(timeStr)} ${chalk.gray('(server-authoritative)')}`);
|
|
343
343
|
}
|
|
344
344
|
}
|
|
345
|
-
// Help budget per exam.md §3:
|
|
345
|
+
// Help budget per exam.md §3: 20 base + 10 hidden bonus (unlocked via `more help`).
|
|
346
346
|
// Demo still uses the lighter 5 + 3 set via _helpMax overrides at demo start.
|
|
347
|
-
const HELP_BASE =
|
|
348
|
-
const HELP_WITH_BONUS =
|
|
347
|
+
const HELP_BASE = 20;
|
|
348
|
+
const HELP_WITH_BONUS = 30;
|
|
349
349
|
function getHelpState(state) {
|
|
350
350
|
return {
|
|
351
351
|
used: state._helpUsed || 0,
|
|
@@ -1040,6 +1040,20 @@ export function registerExamCommand(program) {
|
|
|
1040
1040
|
state.answers[num] = c;
|
|
1041
1041
|
state._lastQ = num;
|
|
1042
1042
|
saveExamState(state);
|
|
1043
|
+
// Per-question sync to server (real exam only). Best-effort, fire-and-forget.
|
|
1044
|
+
// If timer expires or network drops before final submit, the server still
|
|
1045
|
+
// has the answer. Final submit is authoritative and overwrites this.
|
|
1046
|
+
const tokenForSync = state.session.token;
|
|
1047
|
+
if (tokenForSync && state.session.examId !== 'demo-free') {
|
|
1048
|
+
const cfg = getConfig();
|
|
1049
|
+
const url = `${cfg.ctfdUrl || 'https://practice.icoa2026.au'}/api/icoa/exams/${state.session.examId}/answer`;
|
|
1050
|
+
fetch(url, {
|
|
1051
|
+
method: 'POST',
|
|
1052
|
+
headers: { 'Content-Type': 'application/json' },
|
|
1053
|
+
body: JSON.stringify({ token: tokenForSync, question: num, answer: c }),
|
|
1054
|
+
signal: AbortSignal.timeout(5000),
|
|
1055
|
+
}).catch(() => { }); // silent failure — local state still saved
|
|
1056
|
+
}
|
|
1043
1057
|
const answered = Object.keys(state.answers).length;
|
|
1044
1058
|
const total = state.session.questionCount;
|
|
1045
1059
|
printSuccess(`Q${num}: ${c} ✓ (${answered}/${total} answered)`);
|