### Initialize and start or resume the session Source: https://proctor-test1.youtestme.com/sdk/doc/Supervisor.html Examples of starting a session, either by starting an already initialized session or in self-registration mode, or by initializing and starting with specific parameters like provider and token. ```javascript // start the already initialized session or self-registration mode supervisor.start(); // initialize and start the session with parameters supervisor.start({ provider: 'jwt', token: '...' }); ``` -------------------------------- ### Supervisor On Method Examples Source: https://proctor-test1.youtestme.com/sdk/doc/Supervisor.html Examples showing how to add event handlers for single or multiple events. ```javascript // event handler var handler = function() { supervisor.logout({ redirect: true }); }; // subscribe to a single event supervisor.on('stop', handler); // subscribe to multiple events supervisor.on(['stop', 'fail'], handler); ``` -------------------------------- ### Supervisor Constructor Example Source: https://proctor-test1.youtestme.com/sdk/doc/Supervisor.html Example of how to instantiate the Supervisor class with a server URL. ```javascript var supervisor = new Supervisor({ url: 'https://your-proctoring-server' }); ``` -------------------------------- ### Self-registration with Supervisor SDK Source: https://proctor-test1.youtestme.com/sdk/doc/index.html This example demonstrates how to initialize and start a proctoring session using the Supervisor SDK with self-registration. It includes setting up event handlers for 'stop' and 'fail' events, and logging out with redirection. ```html ``` -------------------------------- ### Initialize and start the session Source: https://proctor-test1.youtestme.com/sdk/doc/tutorial-jwt-payload.html This snippet demonstrates how to initialize and start a session with a provider and token. ```javascript var provider = ""; var token = ""; supervisor.start({ provider, token }); ``` -------------------------------- ### Integration Provider Setup Source: https://proctor-test1.youtestme.com/sdk/doc/tutorial-tracking-metrics.html Configuration for setting up an integration provider using webhooks, specifying strategy, profile, and registration details including metrics and weights. ```json { "strategy": "plain", "profile": { "username": "payload.username" }, "register": { "identifier": "payload.identifier", "subject": "payload.subject", "timeout": "payload.timeout", "metrics": "payload.metrics", "addons": "payload.addons", "weights": "payload.weights", "threshold": "payload.threshold" } } ``` -------------------------------- ### JWT payload authorization with Supervisor SDK Source: https://proctor-test1.youtestme.com/sdk/doc/index.html This example shows how to use the Supervisor SDK with JWT authorization. It includes creating a Supervisor instance, setting up event handlers for 'start', 'stop', and 'fail', and initiating the session with a JWT token obtained from a backend API. ```html ``` -------------------------------- ### Supervisor Init Method Example Source: https://proctor-test1.youtestme.com/sdk/doc/Supervisor.html Example of initializing a session using a JWT token obtained from a server. ```javascript supervisor.init({ // set your provider name provider: 'jwt', // get JWT string from your server token: fetch('/api/token').then(function (response) { if (response.ok) return response.text(); else throw Error('Failed to get JWT'); }) }); ``` -------------------------------- ### Supervisor Once Method Example Source: https://proctor-test1.youtestme.com/sdk/doc/Supervisor.html Example of adding an event handler that will be executed only once. ```javascript // event handler var handler = function() { // event occurred }; // subscribe to an event supervisor.once('start', handler); ``` -------------------------------- ### Supervisor Logout Method Example Source: https://proctor-test1.youtestme.com/sdk/doc/Supervisor.html Example of logging out from the session, with an option to redirect afterwards. ```javascript supervisor.logout({ redirect: true }); ``` -------------------------------- ### Supervisor Off Method Examples Source: https://proctor-test1.youtestme.com/sdk/doc/Supervisor.html Examples demonstrating how to remove event handlers for single or multiple events. ```javascript // unsubscribe from a single event supervisor.off('stop', handler); // unsubscribe from multiple events supervisor.off(['stop', 'fail'], handler); ``` -------------------------------- ### Supervisor Check Method Examples Source: https://proctor-test1.youtestme.com/sdk/doc/Supervisor.html Examples demonstrating how to use the check method to verify equipment, with options to check specific components. ```javascript // check all equipment supervisor.check(); // check only the camera supervisor.check({ camera: true }); // check the camera and microphone supervisor.check({ camera: true, microphone: true }); ``` -------------------------------- ### Supervisor Lookup Method Example Source: https://proctor-test1.youtestme.com/sdk/doc/Supervisor.html Example of using the lookup method to retrieve specific session fields. ```javascript supervisor.lookup('identifier', 'username', 'subject', 'duration'); ``` -------------------------------- ### Supervisor Close Method Example Source: https://proctor-test1.youtestme.com/sdk/doc/Supervisor.html Example of how to close the current session without logging out, allowing for continuation later. ```javascript supervisor.close(); ``` -------------------------------- ### Synchronize the session state by token Source: https://proctor-test1.youtestme.com/sdk/doc/Supervisor.html Example of synchronizing the session state using a provided session token. ```javascript supervisor.sync({ token: 'SESSION_TOKEN' }); ``` -------------------------------- ### Update user profile and upload face photo Source: https://proctor-test1.youtestme.com/sdk/doc/Supervisor.html Examples of updating a user's profile, including changing their nickname and UI language, and uploading a face photo using a local path or a fetch blob. ```javascript // change user's full name and UI language supervisor.profile({ nickname: 'John Doe', lang: 'en' }); // upload user's face photo supervisor.profile({ face: '/path/to/face.jpg' }); // or the same using fetch() supervisor.profile({ face: fetch('/path/to/face.jpg').then(res => res.blob()) }); ``` -------------------------------- ### Create Supervisor instance Source: https://proctor-test1.youtestme.com/sdk/doc/tutorial-jwt-payload.html This snippet shows how to create a Supervisor instance with a given URL. ```javascript var url = ""; var supervisor = new Supervisor({ url }); ``` -------------------------------- ### Self-registration with data-attributes Source: https://proctor-test1.youtestme.com/sdk/doc/index.html An alternative method for self-registration using data-attributes directly on the script tag to initialize the Supervisor SDK. ```html ``` -------------------------------- ### Stop the session and log out Source: https://proctor-test1.youtestme.com/sdk/doc/tutorial-jwt-payload.html This snippet shows how to stop the session and log out. ```javascript supervisor.stop(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.