Skip to content

Proctoring‐Engine

Veerendra Kumar edited this page Jun 5, 2026 · 1 revision

Proctoring Engine & Anti-Cheat Logic

The proctoring system monitors client behavior during mock test assessments to ensure exam integrity.


1. Screen Focus / Tab Switch Detection

The client-side proctoring engine monitors page visibility using HTML5 event listeners:

useEffect(() => {
  const handleBlur = async () => {
    if (!mockTest || mockTest.status !== 'active') return;
    try {
      const res = await mockTestService.recordMockTestViolation(mockTest._id);
      setWarningCount(res.tabSwitchesCount);
      if (res.autoSubmitted) {
        alert('Test auto-submitted. Focus proctor constraint violation limit reached (3 shifts).');
        navigate(`/mocktest/result/${mockTest._id}`);
      } else {
        setShowWarningModal(true); // Show warning modal block overlay
      }
    } catch (err) {
      console.error(err);
    }
  };

  window.addEventListener('blur', handleBlur);
  return () => window.removeEventListener('blur', handleBlur);
}, [mockTest]);

Clone this wiki locally