Skip to content

Commit 662a139

Browse files
Merge pull request #436 from ossf/addCompletionStamp
Add datetime/uuid stamp at bottom on completion
2 parents 1cc7b0d + e053003 commit 662a139

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
@@ -219,6 +219,16 @@ function runCheck() {
219219

220220
if (isCorrect && (oldGrade !== newGrade)) {
221221
// Hooray! User has a newly-correct answer!
222+
223+
// Set `correctStamp` id (if present) with timestamp and UUID
224+
// This makes it easy to detect someone simply copying a final result.
225+
correctStamp = document.getElementById('correctStamp');
226+
if (correctStamp) {
227+
let timeStamp = (new Date()).toISOString();
228+
let uuid = crypto.randomUUID();
229+
correctStamp.innerHTML = `${timeStamp} ${uuid}`;
230+
}
231+
222232
// Use a timeout so the underlying page will *re-render* before the
223233
// alert shows. If we don't do this, the alert would be confusing
224234
// 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)