icoa-cli 2.14.1 → 2.14.3
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 +21 -1
- package/dist/lib/demo-exam.js +1 -1
- package/dist/lib/exam-state.js +2 -0
- package/package.json +1 -1
package/dist/commands/exam.js
CHANGED
|
@@ -27,7 +27,16 @@ function checkTimeRemaining() {
|
|
|
27
27
|
if (!deadline)
|
|
28
28
|
return true;
|
|
29
29
|
if (new Date() >= deadline) {
|
|
30
|
-
|
|
30
|
+
const state = getExamState();
|
|
31
|
+
if (state && state.session.examId === 'demo-free') {
|
|
32
|
+
// Demo expired — auto-clear
|
|
33
|
+
printWarning('Demo time expired. Starting fresh!');
|
|
34
|
+
printInfo('Type: demo');
|
|
35
|
+
clearExamState();
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
printError('Time expired! Use "exam submit" to submit your answers.');
|
|
39
|
+
}
|
|
31
40
|
return false;
|
|
32
41
|
}
|
|
33
42
|
return true;
|
|
@@ -549,6 +558,17 @@ export function registerExamCommand(program) {
|
|
|
549
558
|
const answered = Object.keys(state.answers).length;
|
|
550
559
|
const total = state.session.questionCount;
|
|
551
560
|
const unanswered = total - answered;
|
|
561
|
+
if (answered === 0) {
|
|
562
|
+
printWarning('No answers to submit.');
|
|
563
|
+
if (state.session.examId === 'demo-free') {
|
|
564
|
+
clearExamState();
|
|
565
|
+
printInfo('Demo cleared. Type: demo to start again.');
|
|
566
|
+
}
|
|
567
|
+
else {
|
|
568
|
+
printInfo('Answer some questions first: exam q 1');
|
|
569
|
+
}
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
552
572
|
let msg = `Submit ${answered}/${total} answers?`;
|
|
553
573
|
if (unanswered > 0) {
|
|
554
574
|
msg += chalk.yellow(` ${unanswered} unanswered.`);
|
package/dist/lib/demo-exam.js
CHANGED
package/dist/lib/exam-state.js
CHANGED
|
@@ -30,6 +30,8 @@ export function getExamDeadline() {
|
|
|
30
30
|
const state = getExamState();
|
|
31
31
|
if (!state)
|
|
32
32
|
return null;
|
|
33
|
+
if (!state.session.durationMinutes)
|
|
34
|
+
return null; // 0 = no time limit
|
|
33
35
|
const start = new Date(state.session.startedAt).getTime();
|
|
34
36
|
return new Date(start + state.session.durationMinutes * 60 * 1000);
|
|
35
37
|
}
|