AutoProctor Events

Most of AutoProctor’s functionality is internally driven by JavaScript’s Events. As you integrate the SDK with your website, you will use events to manage the user flow as well. On this page, we look at two types of events

  • Regular events: The most important events are emitted directly to the Window target
  • Custom events: The less important events are emitted as a Custom Event. The specific event (for example, ML Model is loaded) is added to the detail property of the event.

Regular events

Let's say you want to show a quiz's <div> once AutoProctor's monitoring has begun. For that, you'd write code like this Let's say you want to enable a button when AutoProctor is ready. For that, you'd write code like this

window.addEventListener('apMonitoringStarted', () => {
  div.style.visibility = 'visible'
})

Following are the events AutoProctor emits:

EventEmitted When
apSetupComplete.setup() completes successfully. You can now call the .start() method
apMonitoringStarted.start() executes successfully, and events are being tracked. We set the test start time now. If you want to hide a test's questions until the proctoring is ready, you can load the questions after this event
apMonitoringStopped.stop() executes successfully. The last set of violations are sent to the server, the test finish time is set and Trust Score calculated. If you want to redirect the user to a different page after the test, etc you should do it after this event

Custom Events

An AutoProctor custom event can be one of: apSuccessEvent, apErrorEvent or apEvidenceEvent. Let's say you want to enable a button when ML models are loaded. You would then write something like

window.addEventListener('apSuccessEvent', (e) => {
  const { successCode } = e.detail
  if (successCode === 2001) {
    btn.disabled = false
  }
})

apSuccessEvent - Success Events

CodeEmitted When
2001Browser and Permission check completed and Permission granted
2002HTML Elements created. Ready to async load video and ML model
2003Video and ML model loaded. Ready to start face detection

apErrorEvent - Error Events

CodeEmitted When
4001Incompatible Browser. Doesn't pass checkBrowserCompatiblity().
4002From permissions API, user has already blocked access to camera.
4003From permissions API, user has already blocked access to microphone.
4004User has proactively declined access to camera/microphone. Or, the page is being loaded within an insecure context.
4005Hardware error, insecure context, or some other error.
4006From permissions API, user has already blocked access to camera and mic.
4007Audio Not Readable Error in getUserMedia.
4008Video Not Readable Error in getUserMedia.
4007Mic Not Found in getUserMedia.
4008Camera Not Found in getUserMedia.
4009We weren't able to find a microphone on your device. You need to enable your microphone, or use another device that has a microphone to take this test.
4010We weren't able to find a camera (or webcam) on your device. You need to enable your camera, or use another device that has a camera to take this test.
4011Permission to access a screen area was denied by the user, or the current browsing instance is not permitted access to screen sharing. Please reload the page to provide the access.
4012The user selected a screen, window, tab, or other source of screen data, but a hardware or operating system level error or lockout occurred, preventing the sharing of the selected source.
4013No sources of screen video are available for capture.
4014You must share your entire screen in order to proceed with the test. Please reload the page to select again.
4015We have detected multiple monitors. Please disconnect the extra monitor (or displays like Chromecast). If you continue without disconnecting, your teacher will be informed of multiple monitors.
4016Use latest version of Safari on iPhone or iPad. Else, use Chrome.
4017Please use Chrome or Firefox, if you want to proceed with the test. (if forceCaptureSwitchedTab is true)
4018There was some error while loading the libraries.

apEvidenceEvent - Evidence Events

CodeEmitted When
5001No one looking at camera
5002More than 1 Person in Video
5003Random photo taken
5004Audio above background levels
5005Document page hidden or focus lost
5006Document page became visible or focus was gained
5007Multiple monitors detected
5008Multiple monitors suspected (not a violation)