Real-time Simulation Logic
The ProctorAI prototype uses a sophisticated simulation engine to demonstrate how a real-time proctoring environment behaves during a live examination. This simulation mimics student activity, risk fluctuations, and automated violation detection without requiring a live backend or real student participants.
Dashboard Simulation
The Proctor Dashboard uses periodic polling and randomized data generators to create a "living" monitoring environment.
Live Student Metrics
Student data is updated every 5 seconds to reflect the dynamic nature of an exam session.
- Risk Score Volatility: Student risk scores fluctuate by ±5 points based on a randomized algorithm, bounded between 0 and 100.
- Session Progress: The
timeElapsedmetric increments automatically, ensuring the proctor sees active progress for all simulated candidates.
Automated Alert Generation
The system generates a new proctoring alert every 12 seconds to simulate real-world monitoring events. These alerts are randomly assigned to students in the session and categorized into four primary types:
| Alert Type | Severity | Description |
| :--- | :--- | :--- |
| gaze_deviation | Low | Sustained eye movement away from the primary screen area. |
| tab_switch | Medium | Browser-level detection of the student navigating away from the exam tab. |
| audio_anomaly | Medium | Detection of background voices or suspicious ambient noise. |
| head_movement | Low | Unusual patterns in head positioning or frequent looking off-camera. |
Exam-Side Monitoring Logic
The exam flow (/exam) simulates the student experience, including the "anti-cheat" guardrails that trigger the alerts seen on the dashboard.
System Integrity Checks
Before an exam begins, the simulation runs a series of sequential checks to verify the testing environment:
- WebRTC Compatibility: Validates browser support for real-time communication.
- Network Latency: Simulates a ping test to determine connection stability (RTT).
- Media Permissions: Requests and verifies access to the webcam and microphone.
- Identity Verification: A simulated biometric check using the webcam feed.
Behavioral Tracking
During the exam, the client-side logic monitors for several violation categories:
- Tab Visibility: Uses the
visibilitychangeAPI to detect when a student switches tabs or minimizes the window. This triggers an immediate "Tab Switch" warning toast. - Environment Constraints:
- Right-Click/Context Menu: Blocked to prevent external search tool usage.
- Clipboard Actions: Copy, Paste, and Cut operations are intercepted and logged as "Copy Attempts."
- Keyboard Shortcuts: Common shortcuts (e.g.,
Ctrl+C,Ctrl+V) are neutralized.
- Audio Visualizer: A real-time
AnalyserNodeprocesses the microphone input to provide a visual representation of the student's environment volume, simulating noise-level monitoring.
Customizing the Simulation
While the simulation is designed to run automatically, the behavior is governed by the mock data structures located in src/lib/mockData.ts.
To adjust the frequency of the dashboard updates, you can modify the intervals within the DashboardPage component:
// Adjusting the risk update frequency (src/app/dashboard/page.tsx)
useEffect(() => {
const interval = setInterval(() => {
// Logic for updating scores...
}, 5000); // Change 5000 to your desired millisecond interval
return () => clearInterval(interval);
}, []);
Visualizing Trends
The simulation data feeds directly into the Analytics surface. The metrics shown in the dashboard (Risk Score Over Time, Violation Types, and Peak Violation Times) are derived from the same mock engine, providing a cohesive story from a single live session to institutional-level oversight.