@@ -203,11 +203,10 @@ <h1 id="quiz-title">Simple Quiz</h1>
203
203
const radioButtons = document . querySelectorAll ( 'input[name="question1"]' ) ;
204
204
205
205
document . querySelector ( '.container-wrapper' ) . addEventListener ( 'mouseout' , function ( e ) {
206
- // Check if the mouse has actually left the container-wrapper, not just moved between elements inside it
207
- if ( ! e . currentTarget . contains ( e . relatedTarget ) ) {
208
- logViolation ( "Mouse left the quiz container" , "red" ) ;
209
- }
210
- } ) ;
206
+ if ( ! e . currentTarget . contains ( e . relatedTarget ) ) {
207
+ logViolation ( "Mouse left the quiz container" , "red" ) ;
208
+ }
209
+ } ) ;
211
210
212
211
function addEvent ( obj , evt , fn ) {
213
212
if ( obj . addEventListener ) {
@@ -299,24 +298,20 @@ <h1 id="quiz-title">Simple Quiz</h1>
299
298
addEvent ( document , "contextmenu" , handleContextMenu ) ;
300
299
addEvent ( document , "selectionchange" , debounceSelectionChange ) ;
301
300
addEvent ( document , "visibilitychange" , handleVisibilityChange ) ;
302
- addEvent ( document , "'DOMContentLoaded'" , ( ) => logViolation ( "Session started" , "green" ) ;
303
301
window . onblur = ( ) => logViolation ( "Window focus lost" , "yellow" ) ;
304
302
window . onfocus = ( ) => logViolation ( "Window focus regained" , "blue" ) ;
305
303
} ) ;
306
304
}
307
305
308
306
setupEventListeners ( ) ;
309
307
310
-
311
-
312
- radioButtons . forEach ( radio => {
308
+ radioButtons . forEach ( radio => {
313
309
radio . addEventListener ( 'change' , ( ) => {
314
- logViolation ( `Selected answer: ${ button . value } ` , "yellow" ) ;
310
+ logViolation ( `Selected answer: ${ radio . value } ` , "yellow" ) ;
315
311
submitButton . disabled = ! document . querySelector ( 'input[name="question1"]:checked' ) ;
316
312
} ) ;
317
313
} ) ;
318
314
319
-
320
315
submitButton . addEventListener ( 'click' , function ( ) {
321
316
const selectedAnswer = document . querySelector ( 'input[name="question1"]:checked' ) ;
322
317
logViolation ( "Session ended" , "purple" ) ; // Log session end in purple
@@ -341,8 +336,6 @@ <h1 id="quiz-title">Simple Quiz</h1>
341
336
// Stop all tracking after submit
342
337
removeEventListeners ( ) ;
343
338
} ) ;
344
-
345
-
346
339
</ script >
347
340
</ body >
348
341
</ html >
0 commit comments