TestWith Guide
-
HTML<script src = "https://www.testwith.io/static/js/testwith_api.js"></script>
-
JavaScriptconst serviceId = "string";
const tw = new Testwith(serviceId);
-
JavaScripttw.loadTestwith().then(() => {
}).catch(err => {
console.error('자원 로드 중 오류 발생:', err);
});
Important
serviceId | string |
Python
def
get_token():
headers = {
"Content-Type": 'application/json; charset=utf-8' ,
}
body = {
"apiKey": {apiKey}, # api key (from TestWith)
"apiSecret": {apiSecret}, # api secret (from TestWith)
"serviceId": {serviceId} # service id (from TestWith)
}
URL = f'https://www.testwith.io/services/token'
response = requests.post(URL, headers=headers, json=body)
if response.status_code == 200:
return response.json()
else:
return response.json()
headers = {
"Content-Type": 'application/json; charset=utf-8' ,
}
body = {
"apiKey": {apiKey}, # api key (from TestWith)
"apiSecret": {apiSecret}, # api secret (from TestWith)
"serviceId": {serviceId} # service id (from TestWith)
}
URL = f'https://www.testwith.io/services/token'
response = requests.post(URL, headers=headers, json=body)
if response.status_code == 200:
return response.json()
else:
return response.json()
Info
API URL
HTTP
https://www.testwith.io/services/token
API Header
Mandatory | Description | |
---|---|---|
Content-Type | Mandatory |
JSON
{
"apiKey": "string",
"apiSecret": "string",
"serviceId": "string"
}
"apiKey": "string",
"apiSecret": "string",
"serviceId": "string"
}
apiKey | string | ||
apiSceret | string | ||
serviceId | string |
JSON
{
"access": "string",
"exp": "int",
"now": "int",
"resultCode": "int",
"resultMsg": "string"
}
"access": "string",
"exp": "int",
"now": "int",
"resultCode": "int",
"resultMsg": "string"
}
access | string | ||
exp | int | timestamp | |
now | int | timestamp | |
resultCode | int | ||
resultMsg | string |
JavaScript
tw.getTestCenterList(parameter)
Info
Object
{
"token": "string"
}
"token": "string"
}
token | string | Y |
JSON
{
"resultCode": "int",
"resultMsg": "string",
"resultData":
[{
"id": "string",
"testId": "string",
"title": "string"
}, ...]
}
"resultCode": "int",
"resultMsg": "string",
"resultData":
[{
"id": "string",
"testId": "string",
"title": "string"
}, ...]
}
resultCode | int | ||
resultMsg | string | ||
resultData | Array | ||
id | string | ||
testId | string | ||
title | string |
JavaScript
tw.getTestCenter(parameter)
Info
Object
{
"token": "string",
"testId": "string"
}
"token": "string",
"testId": "string"
}
token | string | Y | ||
testId | string | Y |
JSON
{
"resultCode": "int",
"resultMsg": "string",
"resultData":
[{
"id": "string",
"testId":"string",
"title":"string",
}, ...]
}
"resultCode": "int",
"resultMsg": "string",
"resultData":
[{
"id": "string",
"testId":"string",
"title":"string",
}, ...]
}
resultCode | int | ||
resultMsg | string | ||
resultData | Array | ||
id | string | ||
testId | string | ||
title | string |
JavaScript
tw.createTestCenter(parameter)
Info
Object
{
"token": "string",
"title": "string"
}
"token": "string",
"title": "string"
}
token | string | Y | ||
title | string | Y |
JSON
{
"resultCode": "int",
"resultMsg": "string",
"resultData":
{
"testId": "string"
}
}
"resultCode": "int",
"resultMsg": "string",
"resultData":
{
"testId": "string"
}
}
resultCode | int | ||
resultMsg | string | ||
resultData | Array | ||
testId | string |
JavaScript
tw.updateTestCenter(parameter)
Info
Object
{
"token": "string",
"testId": "string",
"title": "string"
}
"token": "string",
"testId": "string",
"title": "string"
}
token | string | Y | ||
testId | string | Y | ||
title | string | Y |
JSON
{
"resultCode": "int",
"resultMsg": "string"
}
"resultCode": "int",
"resultMsg": "string"
}
resultCode | int | ||
resultMsg | string |
JavaScript
tw.getStudentList(parameter)
Info
요청 파라미터
Object
{
"token":"string",
"testId":"string"
}
"token":"string",
"testId":"string"
}
token | string | Y | ||
testId | string | Y |
JSON
{
"resultCode":"int",
"resultMsg":"string",
"resultData":
[{
"userId": "int",
"testId": "string",
"userNum": "string",
"name": "string",
"email": "string",
"face": "string",
"assist": "int",
"confirmed": "string",
"audioId": "string",
"deviceId": "string",
"stream": "string",
"screen": "string",
"mstream": "string"
}, ...]
}
"resultCode":"int",
"resultMsg":"string",
"resultData":
[{
"userId": "int",
"testId": "string",
"userNum": "string",
"name": "string",
"email": "string",
"face": "string",
"assist": "int",
"confirmed": "string",
"audioId": "string",
"deviceId": "string",
"stream": "string",
"screen": "string",
"mstream": "string"
}, ...]
}
resultCode | int | ||
resultMsg | string | ||
resultData | Array | ||
userId | int | ||
testId | string | ||
userNum | string | ||
name | string | ||
string | |||
face | string | ||
assist | int | ||
confirmed | string | ||
audioId | string | ||
deviceId | string | ||
stream | string | ||
screen | string | ||
mstream | string |
JavaScript
tw.getStudent(parameter)
Info
Object
{
"token":"string",
"testId":"string",
"userId":"int"
}
"token":"string",
"testId":"string",
"userId":"int"
}
token | string | Y | ||
testId | string | Y | ||
userId | int | Y |
JSON
{
"resultCode":"int",
"resultMsg":"string",
"resultData":
[{
"userId": "int",
"testId": "string",
"userNum": "string",
"name": "string",
"email": "string",
"face": "string",
"assist": "int",
"audioId": "string",
"deviceId": "string",
"stream": "string",
"screen": "string",
"mstream": "string"
}, ...]
}
"resultCode":"int",
"resultMsg":"string",
"resultData":
[{
"userId": "int",
"testId": "string",
"userNum": "string",
"name": "string",
"email": "string",
"face": "string",
"assist": "int",
"audioId": "string",
"deviceId": "string",
"stream": "string",
"screen": "string",
"mstream": "string"
}, ...]
}
resultCode | int | ||
resultMsg | string | ||
resultData | array | ||
userId | int | ||
testId | string | ||
userNum | string | ||
name | string | ||
string | |||
face | string | ||
assist | int | ||
audioId | string | ||
deviceId | string | ||
stream | string | ||
screen | string | ||
mstream | string |
JavaScript
tw.registerStudent(parameter)
Info
Object
{
"token": "string",
"testId": "string",
"userNums": [],
"names": []
}
"token": "string",
"testId": "string",
"userNums": [],
"names": []
}
token | string | Y | ||
testId | string | Y | ||
userNums | array | Y | ||
names | array | Y |
JSON
{
"resultCode": "int",
"resultMsg": "string",
"resultData": []
}
"resultCode": "int",
"resultMsg": "string",
"resultData": []
}
resultCode | int | ||
resultMsg | string | ||
resultData | array |
JavaScript
tw.updateStudent(parameter)
Info
Object
{
"token": "string",
"testId": "string",
"userId": "int",
"userNum": "string",
"name": "string"
}
"token": "string",
"testId": "string",
"userId": "int",
"userNum": "string",
"name": "string"
}
token | string | Y | ||
testId | string | Y | ||
userId | int | Y | ||
userNum | string | Y | ||
name | string | Y |
JSON
{
"resultCode": "int",
"resultMsg": "string"
}
"resultCode": "int",
"resultMsg": "string"
}
resultCode | int | ||
resultMsg | string |
JavaScript
tw.createWebcam(parameter)
Info
Object
{
"langKey": "",
"elementId": "",
"userId": "0000"
}
"langKey": "",
"elementId": "",
"userId": "0000"
}
langKey | string | N | ||
elementId | string | N | ||
userId | string | Y |
Important
tw.onSuccessStream() =>
{
console.log();
}
console.log();
}
tw.onFailStream() => {
console.log();
}
console.log();
}
Info
JavaScript
tw.createScreen(parameter)
Object
{
"langKey": "",
"elementId": "",
"userId": "0000"
}
"langKey": "",
"elementId": "",
"userId": "0000"
}
langKey | string | N | ||
elementId | string | N | ||
userId | string | Y |
Important
tw.onSuccessScreen() => {
console.log();
}
console.log();
}
tw.onFailScreen() => {
console.log();
}
console.log();
}
Info
JavaScript
tw.createQR_code(parameter)
Info
Object
{
"langKey": "",
"elementId": "",
"userId": "0000",
"width": "",
"height": ""
}
"langKey": "",
"elementId": "",
"userId": "0000",
"width": "",
"height": ""
}
langKey | string | N | ||
elementId | string | N | ||
userId | string | Y | ||
width | int | N | ||
height | int | N |
JavaScript
tw.stream_start(parameter)
Info
Object
{
"userId": "0000",
"videoSource": "",
"audioSource": "",
"type": "",
"elementId": ""
}
"userId": "0000",
"videoSource": "",
"audioSource": "",
"type": "",
"elementId": ""
}
userId | string | Y | ||
videoSource | string | N | ||
audioSource | string | N | ||
type | string | N | ||
elementId | string | N |
JavaScript
tw.connectAI(parameter)
Info
Object
{
"deviceId": "0000000"
}
"deviceId": "0000000"
}
deviceId | string | Y |
JavaScript
tw.createRegister(parameter)
Info
Object
{
"langKey": "",
"elementId": ""
}
"langKey": "",
"elementId": ""
}
langKey | string | N | ||
elementId | string | N |
Important
JavaScript
tw.registFace(parameter).then(data => {
console.log(data);
});
console.log(data);
});
Info
Object
{
"testId": "1234",
"userId": "0000",
"videoId": "",
"valid": ""
}
"testId": "1234",
"userId": "0000",
"videoId": "",
"valid": ""
}
testId | string | Y | ||
userId | string | Y | ||
videoId | string | N | ||
valid | string | N |
JSON
{
"message": "string",
"result": "int"
}
"message": "string",
"result": "int"
}
message | string | ||
result | int |
JavaScript
tw.setScreenAI(parameter)
Info
Object
{
"testId": "1234",
"userId": "0000",
"detectOption" = {
"screenLeave": true,
"rightClick": true,
"specialKey": true,
},
"recordOption": true
}
"testId": "1234",
"userId": "0000",
"detectOption" = {
"screenLeave": true,
"rightClick": true,
"specialKey": true,
},
"recordOption": true
}
testId | string | Y | ||
userId | string | Y | ||
detectOption | object | Y | ||
screenLeave | boolean | N | ||
rightClick | boolean | N | ||
specialKey | boolean | N | ||
recordOption | boolean | N |
{
"message": "string",
"result": "int"
}
"message": "string",
"result": "int"
}
message | string | ||
result | int |
JavaScript
tw.screenDetectOption = {
"screenLeave": true,
"rightClick": true,
"specialKey": true
}
"screenLeave": true,
"rightClick": true,
"specialKey": true
}
screenLeave | boolean | N | ||
rightClick | boolean | N | ||
specialKey | boolean | N |
Info
JavaScript
tw.screenRecordOption =
true // 화면 녹화 설정 => false: 비활성(기본값), true: 활성
Info
JavaScript
tw.setFaceAI(parameter)
Info
Object
{
"testId": "1234",
"userId": "0000",
"detectOption" = {
"existFace": true,
"multiFace": true,
"validFace": true,
"gaze": true,
},
"recordOption": true
}
"testId": "1234",
"userId": "0000",
"detectOption" = {
"existFace": true,
"multiFace": true,
"validFace": true,
"gaze": true,
},
"recordOption": true
}
testId | string | Y | ||
userId | string | Y | ||
detectOption | object | Y | ||
existFace | boolean | N | ||
multiFace | boolean | N | ||
validFace | boolean | N | ||
gaze | boolean | N | ||
recordOption | boolean | N |
{
"message": "string",
"result": "int"
}
"message": "string",
"result": "int"
}
message | string | ||
result | int |
JavaScript
tw.faceDetectOption = {
"existFace": true,
"multiFace": true,
"validFace": true
"gaze": true
}
"existFace": true,
"multiFace": true,
"validFace": true
"gaze": true
}
existFace | boolean | N | ||
multiFace | boolean | N | ||
validFace | boolean | N | ||
gaze | boolean | N |
Info
JavaScript
tw.faceRecordOption =
true;
Info
JavaScript
tw.createGazeOptimize(parameter)
Object
{
"langKey": "",
"testId": "1234",
"userId": "0000",
"optimizeTime": ""
}
"langKey": "",
"testId": "1234",
"userId": "0000",
"optimizeTime": ""
}
langKey | string | N | ||
testId | string | Y | ||
userId | string | Y | ||
optimizeTime | string | N |
JavaScript
tw.gazeOptimize(parameter)
Info
Object
{
"langKey": "",
"testId": "1234",
"userId": "0000",
"optimizeTime": ""
}
"langKey": "",
"testId": "1234",
"userId": "0000",
"optimizeTime": ""
}
langKey | string | N | ||
testId | string | Y | ||
userId | string | Y | ||
optimizeTime | string | N |
JavaScript
tw.connectSignal(parameter).then(data => {
console.log(data);
});
console.log(data);
});
Info
Object
{
"langKey": "",
"testId": "1234",
"userId": "0000",
"chatOpen": ""
}
"langKey": "",
"testId": "1234",
"userId": "0000",
"chatOpen": ""
}
langKey | string | N | ||
testId | string | Y | ||
userId | string | Y | ||
chatOpen | string | N |
{
"message": "string",
"result": "int"
}
"message": "string",
"result": "int"
}
message | string | ||
result | int |
JavaScript
tw.callbackSignal_getout() =>
{
console.log('signal getout');
}
console.log('signal getout');
}
Info
JavaScript
tw.callbackSignal_cheater() =>
{
console.log('signal cheater');
}
console.log('signal cheater');
}
Info
JavaScript
tw.callbackSignal_caution(count) =>
{
console.log('signal caution', count);
}
console.log('signal caution', count);
}
Info
JavaScript
tw.callbackSignal_webcam() =>
{
console.log('signal webcam reconnect');
}
console.log('signal webcam reconnect');
}
Info
JavaScript
tw.callbackSignal_mobile() =>
{
console.log('signal mobile reconnect');
}
console.log('signal mobile reconnect');
}
Info
JavaScript
tw.callbackSignal_screen() =>
{
console.log('signal screen reconnect');
}
console.log('signal screen reconnect');
}
Info
Error Code | Message | Desc |
---|---|---|
1001 | TooManyRequests | |
1002 | InvalidParams | |
1003 | TestwithScriptRequired | |
1004 | ParamsBindingError | |
1005 | UserNumsNamesLengthDoNotMatch | |
1006 | NoScreenStreaming | |
1007 | CameraDisconnected | |
2001 | TimestampExpired | |
2002 | TestCenterNotFound | |
2003 | TestCenterCreationFail | |
2004 | TestCenterUpdateFail | |
2005 | UserRegistrationFail | |
2006 | UserNumTaken | |
2007 | UserUpdateFail | |
2008 | UserNotFound | |
3001 | InvalidImageFormat | |
3002 | FileUploadFail | |
3003 | FileNotFound | |
3004 | FaceDetection | |
3005 | MultipleFaceDetection | |
3006 | NoStoredPhoto | |
3007 | NoFaceInStoredFile | |
3008 | VerificationMismatch | |
3009 | InvalidFileName | |
3010 | TokenExpired | |
3011 | InvalidToken | |
3012 | Unauthorized | |
3013 | ServiceIdNotFound | |
3014 | InvalidTagName | |
3015 | InvalidVideoRatio | |
3016 | VideoElementNotFound |
Important
HTML
<script src
=
"https://www.testwith.io/static/js/testwith_api.js"></script>
JavaScript
const serviceId = "YOUR_SERVICE_ID_HERE";
const tw = new Testwith(serviceId);
const token = 'YOUR_TOKEN_HERE';
async function registerAndVerifyFace() {
try {
await tw.loadTestwith();
const testCenterResult = await tw.getTestCenterList({ "token": token });
const testCenterList = testCenterResult.resultData;
if (testCenterList.length === 0) {
console.log('testCenterList is empty');
return;
}
const testId = testCenterList[0].testId;
const studentResult = await tw.getStudentList({ "token": token, "testId": testId });
const studentList = studentResult.resultData;
if (studentList.length === 0) {
console.log('studentList is empty');
return;
}
const numberToFind = '';
const foundStudentData = studentList.find((data)=> data.userNum === numberToFind);
if (foundStudentData) {
const userId = foundStudentData.userId;
tw.createRegister();
const registerButton = document.createElement('button');
registerButton.textContent = 'Register Face';
document.body.appendChild(registerButton);
registerButton.style = 'position: absolute; left: 50%; transform: translate(-50%, 0%);';
registerButton.addEventListener('click', () => {
tw.registFace({ "testId": testId, "userId": userId }).then((registerFaceResult) => {
console.log(registerFaceResult);
if (registerFaceResult.resultCode == '200') {
registerButton.remove();
const verifyButton = document.createElement('button');
verifyButton.textContent = 'Verify Face';
document.body.appendChild(verifyButton);
verifyButton.style = 'position: absolute; left: 50%; transform: translate(-50%, 0%);';
verifyButton.addEventListener('click', () => {
tw.registFace({ "testId": testId, "userId": userId, "valid": true }).then((verifyFaceResult) => {
console.log(verifyFaceResult);
}).catch((error) => {
console.error(error);
});
});
}
}).catch ((error) => {
console.error(error);
});
});
} else {
console.log(`No student found with the examinee's number "${numberToFind}"`);
}
} catch (error) {
console.error(error);
}
}
registerAndVerifyFace();
const tw = new Testwith(serviceId);
const token = 'YOUR_TOKEN_HERE';
async function registerAndVerifyFace() {
try {
await tw.loadTestwith();
const testCenterResult = await tw.getTestCenterList({ "token": token });
const testCenterList = testCenterResult.resultData;
if (testCenterList.length === 0) {
console.log('testCenterList is empty');
return;
}
const testId = testCenterList[0].testId;
const studentResult = await tw.getStudentList({ "token": token, "testId": testId });
const studentList = studentResult.resultData;
if (studentList.length === 0) {
console.log('studentList is empty');
return;
}
const numberToFind = '';
const foundStudentData = studentList.find((data)=> data.userNum === numberToFind);
if (foundStudentData) {
const userId = foundStudentData.userId;
tw.createRegister();
const registerButton = document.createElement('button');
registerButton.textContent = 'Register Face';
document.body.appendChild(registerButton);
registerButton.style = 'position: absolute; left: 50%; transform: translate(-50%, 0%);';
registerButton.addEventListener('click', () => {
tw.registFace({ "testId": testId, "userId": userId }).then((registerFaceResult) => {
console.log(registerFaceResult);
if (registerFaceResult.resultCode == '200') {
registerButton.remove();
const verifyButton = document.createElement('button');
verifyButton.textContent = 'Verify Face';
document.body.appendChild(verifyButton);
verifyButton.style = 'position: absolute; left: 50%; transform: translate(-50%, 0%);';
verifyButton.addEventListener('click', () => {
tw.registFace({ "testId": testId, "userId": userId, "valid": true }).then((verifyFaceResult) => {
console.log(verifyFaceResult);
}).catch((error) => {
console.error(error);
});
});
}
}).catch ((error) => {
console.error(error);
});
});
} else {
console.log(`No student found with the examinee's number "${numberToFind}"`);
}
} catch (error) {
console.error(error);
}
}
registerAndVerifyFace();
Info
Important
JavaScript
const serviceId = "YOUR_SERVICE_ID_HERE";
const tw = new Testwith(serviceId);
const token = 'YOUR_TOKEN_HERE';
async function gazeOptimize() {
try {
await tw.loadTestwith();
const testCenterResult = await tw.getTestCenterList({ "token": token });
const testCenterList = testCenterResult.resultData;
if (testCenterList.length === 0) {
console.log('testCenterList is empty');
return;
}
const testId = testCenterList[0].testId;
const studentResult = await tw.getStudentList({ "token": token, "testId": testId });
const studentList = studentResult.resultData;
if (studentList.length === 0) {
console.log('studentList is empty');
return;
}
const numberToFind = '';
const foundStudentData = studentList.find((data)=> data.userNum === numberToFind);
if (foundStudentData) {
const userId = foundStudentData.userId;
try {
await tw.createRegister();
await tw.connectAI();
tw.createGazeOptimize({ "testId": testId, "userId": userId });
} catch (error) {
console.error(error);
}
} else {
console.log(`No student found with the examinee's number "${numberToFind}"`);
}
} catch (error) {
console.error(error);
}
}
gazeOptimize();
const tw = new Testwith(serviceId);
const token = 'YOUR_TOKEN_HERE';
async function gazeOptimize() {
try {
await tw.loadTestwith();
const testCenterResult = await tw.getTestCenterList({ "token": token });
const testCenterList = testCenterResult.resultData;
if (testCenterList.length === 0) {
console.log('testCenterList is empty');
return;
}
const testId = testCenterList[0].testId;
const studentResult = await tw.getStudentList({ "token": token, "testId": testId });
const studentList = studentResult.resultData;
if (studentList.length === 0) {
console.log('studentList is empty');
return;
}
const numberToFind = '';
const foundStudentData = studentList.find((data)=> data.userNum === numberToFind);
if (foundStudentData) {
const userId = foundStudentData.userId;
try {
await tw.createRegister();
await tw.connectAI();
tw.createGazeOptimize({ "testId": testId, "userId": userId });
} catch (error) {
console.error(error);
}
} else {
console.log(`No student found with the examinee's number "${numberToFind}"`);
}
} catch (error) {
console.error(error);
}
}
gazeOptimize();
Info
JavaScript
const serviceId = "YOUR_SERVICE_ID_HERE";
const tw = new Testwith(serviceId);
const token = 'YOUR_TOKEN_HERE';
async function faceAI() {
try {
await tw.loadTestwith();
const testCenterResult = await tw.getTestCenterList({ "token": token });
const testCenterList = testCenterResult.resultData;
if (testCenterList.length === 0) {
console.log('testCenterList is empty');
return;
}
const testId = testCenterList[0].testId;
const studentResult = await tw.getStudentList({ "token": token, "testId": testId });
const studentList = studentResult.resultData;
if (studentList.length === 0) {
console.log('studentList is empty');
return;
}
const numberToFind = '';
const foundStudentData = studentList.find((data)=> data.userNum === numberToFind);
if (foundStudentData) {
const userId = foundStudentData.userId;
tw.onSuccessStream = () => {
tw.setFaceAI({
"testId": testId,
"userId": userId,
"detectOption": {
"existFace": true,
"multiFace": true,
"validFace": true,
"gaze": true,
},
"recordOption": true
});
}
tw.createWebcam({ "userId": userId });
} else {
console.log(`No student found with the examinee's number "${numberToFind}"`);
}
} catch (error) {
console.error(error);
}
}
faceAI();
const tw = new Testwith(serviceId);
const token = 'YOUR_TOKEN_HERE';
async function faceAI() {
try {
await tw.loadTestwith();
const testCenterResult = await tw.getTestCenterList({ "token": token });
const testCenterList = testCenterResult.resultData;
if (testCenterList.length === 0) {
console.log('testCenterList is empty');
return;
}
const testId = testCenterList[0].testId;
const studentResult = await tw.getStudentList({ "token": token, "testId": testId });
const studentList = studentResult.resultData;
if (studentList.length === 0) {
console.log('studentList is empty');
return;
}
const numberToFind = '';
const foundStudentData = studentList.find((data)=> data.userNum === numberToFind);
if (foundStudentData) {
const userId = foundStudentData.userId;
tw.onSuccessStream = () => {
tw.setFaceAI({
"testId": testId,
"userId": userId,
"detectOption": {
"existFace": true,
"multiFace": true,
"validFace": true,
"gaze": true,
},
"recordOption": true
});
}
tw.createWebcam({ "userId": userId });
} else {
console.log(`No student found with the examinee's number "${numberToFind}"`);
}
} catch (error) {
console.error(error);
}
}
faceAI();
Info
JavaScript
const serviceId = "YOUR_SERVICE_ID_HERE";
const tw = new Testwith(serviceId);
const token = 'YOUR_TOKEN_HERE';
async function screenAI() {
try {
await tw.loadTestwith();
const testCenterResult = await tw.getTestCenterList({ "token": token });
const testCenterList = testCenterResult.resultData;
if (testCenterList.length === 0) {
console.log('testCenterList is empty');
return;
}
const testId = testCenterList[0].testId;
const studentResult = await tw.getStudentList({ "token": token, "testId": testId });
const studentList = studentResult.resultData;
if (studentList.length === 0) {
console.log('studentList is empty');
return;
}
const numberToFind = '';
const foundStudentData = studentList.find((data)=> data.userNum === numberToFind);
if (foundStudentData) {
const userId = foundStudentData.userId;
tw.onSuccessScreen = () => {
tw.setScreenAI({
"testId": testId,
"userId": userId,
"detectOption": {
"screenLeave": true,
"rightClick": true,
"specialKey": true,
},
"recordOption": true
});
}
tw.createScreen({ "userId": userId });
} else {
console.log(`No student found with the examinee's number "${numberToFind}"`);
}
} catch (error) {
console.error(error);
}
}
screenAI();
const tw = new Testwith(serviceId);
const token = 'YOUR_TOKEN_HERE';
async function screenAI() {
try {
await tw.loadTestwith();
const testCenterResult = await tw.getTestCenterList({ "token": token });
const testCenterList = testCenterResult.resultData;
if (testCenterList.length === 0) {
console.log('testCenterList is empty');
return;
}
const testId = testCenterList[0].testId;
const studentResult = await tw.getStudentList({ "token": token, "testId": testId });
const studentList = studentResult.resultData;
if (studentList.length === 0) {
console.log('studentList is empty');
return;
}
const numberToFind = '';
const foundStudentData = studentList.find((data)=> data.userNum === numberToFind);
if (foundStudentData) {
const userId = foundStudentData.userId;
tw.onSuccessScreen = () => {
tw.setScreenAI({
"testId": testId,
"userId": userId,
"detectOption": {
"screenLeave": true,
"rightClick": true,
"specialKey": true,
},
"recordOption": true
});
}
tw.createScreen({ "userId": userId });
} else {
console.log(`No student found with the examinee's number "${numberToFind}"`);
}
} catch (error) {
console.error(error);
}
}
screenAI();
Info
JavaScript
const serviceId = "YOUR_SERVICE_ID_HERE";
const tw = new Testwith(serviceId);
const token = 'YOUR_TOKEN_HERE';
async function createQR() {
try {
await tw.loadTestwith();
const testCenterResult = await tw.getTestCenterList({ "token": token });
const testCenterList = testCenterResult.resultData;
if (testCenterList.length === 0) {
console.log('testCenterList is empty');
return;
}
const testId = testCenterList[0].testId;
const studentResult = await tw.getStudentList({ "token": token, "testId": testId });
const studentList = studentResult.resultData;
if (studentList.length === 0) {
console.log('studentList is empty');
return;
}
const numberToFind = '';
const foundStudentData = studentList.find((data)=> data.userNum === numberToFind);
if (foundStudentData) {
const userId = foundStudentData.userId;
tw.createQR_code({ "userId" : userId });
} else {
console.log(`No student found with the examinee's number "${numberToFind}"`);
}
} catch (error) {
console.error(error);
}
}
createQR();
const tw = new Testwith(serviceId);
const token = 'YOUR_TOKEN_HERE';
async function createQR() {
try {
await tw.loadTestwith();
const testCenterResult = await tw.getTestCenterList({ "token": token });
const testCenterList = testCenterResult.resultData;
if (testCenterList.length === 0) {
console.log('testCenterList is empty');
return;
}
const testId = testCenterList[0].testId;
const studentResult = await tw.getStudentList({ "token": token, "testId": testId });
const studentList = studentResult.resultData;
if (studentList.length === 0) {
console.log('studentList is empty');
return;
}
const numberToFind = '';
const foundStudentData = studentList.find((data)=> data.userNum === numberToFind);
if (foundStudentData) {
const userId = foundStudentData.userId;
tw.createQR_code({ "userId" : userId });
} else {
console.log(`No student found with the examinee's number "${numberToFind}"`);
}
} catch (error) {
console.error(error);
}
}
createQR();
Info