Skip to content

Commit e053003

Browse files
Add datetime/uuid stamp at bottom on completion
Add stamp on completion. This is useful if the lab is being used in a class, to provide evidence if people simply copy the same file to show they did the work. Signed-off-by: David A. Wheeler <[email protected]>
1 parent fb53e92 commit e053003

File tree

5 files changed

+14
-0
lines changed

5 files changed

+14
-0
lines changed

docs/labs/checker.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,16 @@ function runCheck() {
216216

217217
if (isCorrect && (oldGrade !== newGrade)) {
218218
// Hooray! User has a newly-correct answer!
219+
220+
// Set `correctStamp` id (if present) with timestamp and UUID
221+
// This makes it easy to detect someone simply copying a final result.
222+
correctStamp = document.getElementById('correctStamp');
223+
if (correctStamp) {
224+
let timeStamp = (new Date()).toISOString();
225+
let uuid = crypto.randomUUID();
226+
correctStamp.innerHTML = `${timeStamp} ${uuid}`;
227+
}
228+
219229
// Use a timeout so the underlying page will *re-render* before the
220230
// alert shows. If we don't do this, the alert would be confusing
221231
// because the underlying page would show that it wasn't completed.

docs/labs/csp1.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ <h2>Interactive Lab (<span id="grade"></span>)</h2>
408408
<button type="button" id="resetButton">Reset</button>
409409
<button type="button" id="giveUpButton">Give up</button>
410410
<br><br>
411+
<pre id="correctStamp"></pre>
411412
<textarea id="debugData" rows="20" cols="70" readonly style="display: none;">
412413
</textarea>
413414
</form>

docs/labs/hello.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ <h2>Interactive Lab (<span id="grade"></span>)</h2>
169169
<button type="button" id="resetButton">Reset</button>
170170
<button type="button" id="giveUpButton">Give up</button>
171171
<br><br>
172+
<pre id="correctStamp"></pre>
172173
<textarea id="debugData" rows="20" cols="70" readonly style="display: none;">
173174
</textarea>
174175
</form>

docs/labs/input1.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ <h2>Interactive Lab (<span id="grade"></span>)</h2>
225225
<button type="button" id="resetButton">Reset</button>
226226
<button type="button" id="giveUpButton">Give up</button>
227227
<br><br>
228+
<pre id="correctStamp"></pre>
228229
<textarea id="debugData" rows="20" cols="70" readonly style="display: none;">
229230
</textarea>
230231
</form>

docs/labs/input2.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ <h2>Interactive Lab (<span id="grade"></span>)</h2>
216216
<button type="button" id="resetButton">Reset</button>
217217
<button type="button" id="giveUpButton">Give up</button>
218218
<br><br>
219+
<pre id="correctStamp"></pre>
219220
<textarea id="debugData" rows="20" cols="70" readonly style="display: none;">
220221
</textarea>
221222
</form>

0 commit comments

Comments
 (0)