Proctoring a Test

The JS snippet below corresponds to Lines 36-38 in the Playground. These are the critical lines that proctor a test. This page explains what happens in these lines.

let apInst = new AutoProctor(credentials)
await apInst.setup(proctoringOptions)
apInst.start()

Line 1

The first line initialises an AutoProctor instance with the credentials object we discussed in the previous section. This method:

  • Loads credentials into apInst, so you can access apInst.hashedTestAttemptId, etc
  • Sets the setupState attribute of apInst to null

Line 2

On the second line, we use proctoringOptions to prepare the browser for proctoring. Depending on exactly what is being tracked, this involves

  • Downloading static JS and ML model files
  • Checking device compatibility
  • Seeking camera, mic and other such permissions

Calling this method returns a Promise that resolves to one of two states:

  • If there are hardware issues like, say, a camera error, etc:

    • An error event with the corresponding code is emitted
    • The setupState attribute of apInst is set to error
  • If there are no errors and the browser is ready:

    • A success event with code = 2100 is emitted and message AP Setup Successfully
    • The setupState attribute of apInst is set to ready

Line 3

The third line actually starts the proctoring. It internally checks that apInst.setupState = ready. In the code here, we are calling the .start() method on await. But, you can equivalently do it by using .then() on the apInst.setup() or by adding an event listener to code 2100.

Resuming a Test

You may want to resume a proctoring session for a few reasons

  • Your test taker accidentally reloads the webpage
  • Your test taker closes the tab/browser and restarts the test
  • Your test consists of different sections and you want to use the same proctoring session for the different sections

In our SDK, tests are resumed using the .start() method itself. If a Test Attempt has not been marked as finished (that is, the .stop() method has not been called), you can resume it by just calling the .start() method. The table below summarizes what the .start() method does

.start() called previously for same testAttemptID?.stop() has been called?What happens
NoN/ANew Test Attempt is created
YesNoTest Attempt resumes (you will see previous and future violations in the report)
YesYesError is thrown