@newtonschool/react_proctoring_library 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -66
- package/dist/assets/images/newton-school-logo.png +0 -0
- package/dist/assets/images/url-video-permission-highlight.png +0 -0
- package/dist/assets/images/vid-micro-permissions-given.png +0 -0
- package/dist/assets/images/vid-micro-permissions.png +0 -0
- package/dist/assets/videos/ask-permission.mp4 +0 -0
- package/dist/assets/videos/give-permissions.mp4 +0 -0
- package/dist/components/FullScreenPermission.js +84 -0
- package/dist/components/FullScreenTestInWebcam.js +22 -10
- package/dist/components/ProctorApp.js +92 -0
- package/dist/components/ResponseModal.js +24 -16
- package/dist/components/activity-tracker/index.js +144 -0
- package/dist/components/activity-tracker/index.scss +4 -0
- package/dist/components/full-screen-permission.scss +8 -0
- package/dist/components/index.js +31 -0
- package/dist/components/permissions/audio-video-permission.js +35 -0
- package/dist/components/permissions/audio-video-permission.scss +228 -0
- package/dist/components/permissions/blocked-permission.js +76 -0
- package/dist/components/permissions/full-screen-permission.js +43 -0
- package/dist/components/permissions/full-screen-permission.scss +8 -0
- package/dist/components/permissions/index.js +70 -0
- package/dist/components/permissions/index.scss +6 -0
- package/dist/components/permissions/initial-screen.js +52 -0
- package/dist/components/permissions/permission-body.js +53 -0
- package/dist/constants/defaults.js +38 -0
- package/dist/constants/text.js +56 -0
- package/dist/demo-code/README.md +70 -0
- package/dist/demo-code/package.json +38 -0
- package/dist/demo-code/public/favicon.ico +0 -0
- package/dist/demo-code/public/index.html +43 -0
- package/dist/demo-code/public/logo192.png +0 -0
- package/dist/demo-code/public/logo512.png +0 -0
- package/dist/demo-code/public/manifest.json +25 -0
- package/dist/demo-code/public/robots.txt +3 -0
- package/dist/demo-code/src/App.css +38 -0
- package/dist/demo-code/src/App.js +29 -0
- package/dist/demo-code/src/index.js +11 -0
- package/dist/hooks/index.js +39 -0
- package/dist/hooks/useAudioVideoPermission.js +96 -0
- package/dist/hooks/useAudioVideoPermissions.js +1 -0
- package/dist/hooks/useFullScreenData.js +55 -0
- package/dist/hooks/useFullScreenStatus.js +45 -0
- package/dist/hooks/usePageVisibility.js +31 -0
- package/dist/hooks/useTabSwitchCount.js +25 -0
- package/dist/hooks/useWebcamData.js +91 -0
- package/dist/index.js +5 -3
- package/dist/lib/index.js +19 -0
- package/dist/utils/ValidityChecks.js +1 -19
- package/dist/utils/arrayUtils.js +16 -0
- package/dist/utils/breachUtils.js +69 -0
- package/dist/utils/browserUtils.js +63 -0
- package/dist/utils/{GetBrowserDocumentProp.js → getBrowserDocumentProp.js} +0 -0
- package/dist/utils/getGlancePercentage.js +1 -43
- package/dist/utils/{GetIsDocumentHidden.js → getIsDocumentHidden.js} +2 -2
- package/dist/utils/index.js +49 -29
- package/dist/utils/localStorageUtils.js +33 -0
- package/dist/utils/webcamMicrophoneUtils.js +115 -0
- package/dist/utils/webcamUtils.js +79 -0
- package/package.json +55 -55
- package/dist/ProctorApp.js +0 -186
- package/dist/utils/TabVisibility.js +0 -32
- package/dist/utils/commonUtilConfigs.js +0 -21
- package/dist/utils/initialSetup.js +0 -15
- package/dist/utils/localStorageUtil.js +0 -27
- package/dist/utils/useFullScreenStatus.js +0 -45
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.updateStatistics = exports.isWebcamVideoValid = exports.getVideoPermission = exports.getGlancePercentage = exports.getAudioVideoPermission = exports.getAudioPermission = void 0;
|
|
7
|
+
|
|
8
|
+
var _ = require(".");
|
|
9
|
+
|
|
10
|
+
const isWebcamVideoValid = webcamReference => webcamReference !== null && webcamReference !== undefined && typeof webcamReference.current !== "undefined" && webcamReference.current !== null && webcamReference.current.video.readyState === 4;
|
|
11
|
+
|
|
12
|
+
exports.isWebcamVideoValid = isWebcamVideoValid;
|
|
13
|
+
|
|
14
|
+
const updateStatistics = (statistics, tabSwitchCount, fullScreenExitCount, lookedAwayCount, userCount) => {
|
|
15
|
+
statistics.current.TAB_SWITCH_COUNT = tabSwitchCount;
|
|
16
|
+
statistics.current.FULLSCREEN_EXIT_COUNT = fullScreenExitCount;
|
|
17
|
+
statistics.current.LOOKED_AWAY_COUNT = lookedAwayCount;
|
|
18
|
+
statistics.current.USER_COUNT_MAX = Math.max(userCount, statistics.current.USER_COUNT_MAX);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.updateStatistics = updateStatistics;
|
|
22
|
+
|
|
23
|
+
const getGlancePercentage = partSegmentation => {
|
|
24
|
+
if (!partSegmentation || !(partSegmentation instanceof Object) || !(0, _.isArrayValid)(partSegmentation.allPoses)) {
|
|
25
|
+
return 0.0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const allPoses = partSegmentation.allPoses;
|
|
29
|
+
let totalScoreLeftEye = 0.0,
|
|
30
|
+
totalScoreRightEye = 0.0,
|
|
31
|
+
totalScoreNose = 0.0,
|
|
32
|
+
totalScoreLeftEar = 0.0,
|
|
33
|
+
totalScoreRightEar = 0.0;
|
|
34
|
+
let noseIndex = 0,
|
|
35
|
+
leftEyeIndex = 1,
|
|
36
|
+
rightEyeIndex = 2,
|
|
37
|
+
leftEarIndex = 3,
|
|
38
|
+
rightEarIndex = 4;
|
|
39
|
+
allPoses.forEach(poseArray => {
|
|
40
|
+
let keypointsArray = poseArray.keypoints;
|
|
41
|
+
totalScoreNose += keypointsArray[noseIndex].score;
|
|
42
|
+
totalScoreLeftEye += keypointsArray[leftEyeIndex].score;
|
|
43
|
+
totalScoreRightEye += keypointsArray[rightEyeIndex].score;
|
|
44
|
+
totalScoreLeftEar += keypointsArray[leftEarIndex].score;
|
|
45
|
+
totalScoreRightEar += keypointsArray[rightEarIndex].score;
|
|
46
|
+
});
|
|
47
|
+
const avgScoreLeftEye = totalScoreLeftEye / allPoses.length,
|
|
48
|
+
avgScoreRightEye = totalScoreRightEye / allPoses.length,
|
|
49
|
+
avgScoreNose = totalScoreNose / allPoses.length,
|
|
50
|
+
avgScoreLeftEar = totalScoreLeftEar / allPoses.length,
|
|
51
|
+
avgScoreRightEar = totalScoreRightEar / allPoses.length;
|
|
52
|
+
const avgPercentage = 100 * (avgScoreLeftEye + avgScoreRightEye + avgScoreNose + avgScoreLeftEar + avgScoreRightEar) / 5;
|
|
53
|
+
return Math.ceil(avgPercentage);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
exports.getGlancePercentage = getGlancePercentage;
|
|
57
|
+
|
|
58
|
+
const getVideoPermission = function getVideoPermission(stream) {
|
|
59
|
+
let exludeTrackId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
|
|
60
|
+
return stream.getVideoTracks().filter(track => track.enabled && track.label && track.id !== exludeTrackId).length > 0;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
exports.getVideoPermission = getVideoPermission;
|
|
64
|
+
|
|
65
|
+
const getAudioPermission = function getAudioPermission(stream) {
|
|
66
|
+
let exludeTrackId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
|
|
67
|
+
return stream.getAudioTracks().filter(track => track.enabled && track.label && !track.muted && track.id !== exludeTrackId).length > 0;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
exports.getAudioPermission = getAudioPermission;
|
|
71
|
+
|
|
72
|
+
const getAudioVideoPermission = stream => {
|
|
73
|
+
return {
|
|
74
|
+
audio: getAudioPermission(stream),
|
|
75
|
+
video: getVideoPermission(stream)
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
exports.getAudioVideoPermission = getAudioVideoPermission;
|
package/package.json
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@newtonschool/react_proctoring_library",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Used to proctor online tests",
|
|
5
|
-
"author": "ayushkagrawal",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"module": "dist/index.js",
|
|
8
|
-
"files": [
|
|
9
|
-
"dist",
|
|
10
|
-
"README.md"
|
|
11
|
-
],
|
|
12
|
-
"keywords": [
|
|
13
|
-
""
|
|
14
|
-
],
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"@tensorflow-models/body-pix": "^2.2.0",
|
|
17
|
-
"@tensorflow/tfjs": "^3.9.0",
|
|
18
|
-
"bootstrap": "^5.1.3",
|
|
19
|
-
"react-bootstrap": "^2.0.4",
|
|
20
|
-
"react-webcam": "^6.0.0"
|
|
21
|
-
},
|
|
22
|
-
"peerDependencies": {
|
|
23
|
-
"react": ">=16.8.0",
|
|
24
|
-
"react-dom": ">=16.8.0"
|
|
25
|
-
},
|
|
26
|
-
"scripts": {
|
|
27
|
-
"build": "babel src
|
|
28
|
-
"test": "react-scripts test",
|
|
29
|
-
"eject": "react-scripts eject"
|
|
30
|
-
},
|
|
31
|
-
"eslintConfig": {
|
|
32
|
-
"extends": [
|
|
33
|
-
"react-app",
|
|
34
|
-
"react-app/jest"
|
|
35
|
-
]
|
|
36
|
-
},
|
|
37
|
-
"browserslist": {
|
|
38
|
-
"production": [
|
|
39
|
-
">0.2%",
|
|
40
|
-
"not dead",
|
|
41
|
-
"not op_mini all"
|
|
42
|
-
],
|
|
43
|
-
"development": [
|
|
44
|
-
"last 1 chrome version",
|
|
45
|
-
"last 1 firefox version",
|
|
46
|
-
"last 1 safari version"
|
|
47
|
-
]
|
|
48
|
-
},
|
|
49
|
-
"devDependencies": {
|
|
50
|
-
"
|
|
51
|
-
"@babel/
|
|
52
|
-
"@babel/
|
|
53
|
-
"
|
|
54
|
-
}
|
|
55
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@newtonschool/react_proctoring_library",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Used to proctor online tests",
|
|
5
|
+
"author": "ayushkagrawal",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"README.md"
|
|
11
|
+
],
|
|
12
|
+
"keywords": [
|
|
13
|
+
""
|
|
14
|
+
],
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@tensorflow-models/body-pix": "^2.2.0",
|
|
17
|
+
"@tensorflow/tfjs": "^3.9.0",
|
|
18
|
+
"bootstrap": "^5.1.3",
|
|
19
|
+
"react-bootstrap": "^2.0.4",
|
|
20
|
+
"react-webcam": "^6.0.0"
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"react": ">=16.8.0",
|
|
24
|
+
"react-dom": ">=16.8.0"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "babel src --out-dir dist --copy-files",
|
|
28
|
+
"test": "react-scripts test",
|
|
29
|
+
"eject": "react-scripts eject"
|
|
30
|
+
},
|
|
31
|
+
"eslintConfig": {
|
|
32
|
+
"extends": [
|
|
33
|
+
"react-app",
|
|
34
|
+
"react-app/jest"
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
"browserslist": {
|
|
38
|
+
"production": [
|
|
39
|
+
">0.2%",
|
|
40
|
+
"not dead",
|
|
41
|
+
"not op_mini all"
|
|
42
|
+
],
|
|
43
|
+
"development": [
|
|
44
|
+
"last 1 chrome version",
|
|
45
|
+
"last 1 firefox version",
|
|
46
|
+
"last 1 safari version"
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@babel/cli": "^7.16.7",
|
|
51
|
+
"@babel/core": "^7.16.7",
|
|
52
|
+
"@babel/preset-env": "^7.16.7",
|
|
53
|
+
"react-scripts": ">=5.0.0"
|
|
54
|
+
}
|
|
55
|
+
}
|
package/dist/ProctorApp.js
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ProctorApp = ProctorApp;
|
|
7
|
-
exports.getStatistics = exports.default = void 0;
|
|
8
|
-
|
|
9
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
10
|
-
|
|
11
|
-
require("core-js/modules/es.promise.js");
|
|
12
|
-
|
|
13
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
14
|
-
|
|
15
|
-
var tf = _interopRequireWildcard(require("@tensorflow/tfjs"));
|
|
16
|
-
|
|
17
|
-
var bodyPix = _interopRequireWildcard(require("@tensorflow-models/body-pix"));
|
|
18
|
-
|
|
19
|
-
var _ResponseModal = _interopRequireDefault(require("./components/ResponseModal"));
|
|
20
|
-
|
|
21
|
-
var _FullScreenTestInWebcam = _interopRequireDefault(require("./components/FullScreenTestInWebcam"));
|
|
22
|
-
|
|
23
|
-
var _index = require("./utils/index");
|
|
24
|
-
|
|
25
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
26
|
-
|
|
27
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
28
|
-
|
|
29
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
30
|
-
|
|
31
|
-
const defaultValues = {
|
|
32
|
-
tabSwitchCount: 0,
|
|
33
|
-
isTabSwitched: false,
|
|
34
|
-
userCount: 0,
|
|
35
|
-
isWatching: true,
|
|
36
|
-
canOpenFullScreen: false,
|
|
37
|
-
fullScreenExitCount: 0,
|
|
38
|
-
lookedAwayCount: 0,
|
|
39
|
-
firstTimeFullScreen: true
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
function ProctorApp(props) {
|
|
43
|
-
const webcamReference = (0, _react.useRef)(null);
|
|
44
|
-
const canvasReference = (0, _react.useRef)(null);
|
|
45
|
-
let Statistics = (0, _react.useRef)({
|
|
46
|
-
TAB_SWITCH_AWAY: 0,
|
|
47
|
-
FULL_SCREEN_EXIT: 0,
|
|
48
|
-
LOOKED_AWAY: 0,
|
|
49
|
-
CHANGE_IN_NUMBER_OF_PEOPLE_IN_CAMERA: 0
|
|
50
|
-
});
|
|
51
|
-
const fullScreenElement = (0, _react.useRef)(document.documentElement);
|
|
52
|
-
|
|
53
|
-
const tabSwitchingCheck = isTabVisible => {
|
|
54
|
-
if (isTabSwitched !== isTabVisible) {
|
|
55
|
-
if (!isTabVisible) {
|
|
56
|
-
setTabSwitchCount(tabSwitchCount + 1);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
setIsTabSwitched(isTabVisible);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const setValues = () => {
|
|
64
|
-
Statistics.current.TAB_SWITCH_AWAY = tabSwitchCount;
|
|
65
|
-
Statistics.current.FULL_SCREEN_EXIT = fullScreenExitCount;
|
|
66
|
-
Statistics.current.LOOKED_AWAY = lookedAwayCount;
|
|
67
|
-
Statistics.current.CHANGE_IN_NUMBER_OF_PEOPLE_IN_CAMERA = Math.max(userCount, Statistics.current.CHANGE_IN_NUMBER_OF_PEOPLE_IN_CAMERA);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const [isTabSwitched, setIsTabSwitched] = (0, _react.useState)(defaultValues.isTabSwitched);
|
|
71
|
-
const [tabSwitchCount, setTabSwitchCount] = (0, _react.useState)(defaultValues.tabSwitchCount);
|
|
72
|
-
const [userCount, setUserCount] = (0, _react.useState)(defaultValues.userCount);
|
|
73
|
-
const [isWatching, setIsWatching] = (0, _react.useState)(defaultValues.isWatching);
|
|
74
|
-
const [lookedAwayCount, setLookedAwayCount] = (0, _react.useState)(defaultValues.lookedAwayCount);
|
|
75
|
-
const [fullScreenExitCount, setFullScreenExitCount] = (0, _react.useState)(defaultValues.fullScreenExitCount);
|
|
76
|
-
const [firstTimeFullScreen, setFirstTimeFullScreen] = (0, _react.useState)(defaultValues.firstTimeFullScreen);
|
|
77
|
-
const [canOpenFullScreen, SetCanOpenFullScreen] = (0, _index.useFullscreenStatus)(fullScreenElement);
|
|
78
|
-
const isTabVisible = (0, _index.usePageVisibility)();
|
|
79
|
-
|
|
80
|
-
const setInitialStates = () => {
|
|
81
|
-
setTabSwitchCount(defaultValues.tabSwitchCount);
|
|
82
|
-
setIsTabSwitched(defaultValues.isTabSwitched);
|
|
83
|
-
setUserCount(defaultValues.userCount);
|
|
84
|
-
setIsWatching(defaultValues.isWatching);
|
|
85
|
-
setLookedAwayCount(defaultValues.lookedAwayCount);
|
|
86
|
-
setFullScreenExitCount(defaultValues.fullScreenExitCount);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const init = () => {
|
|
90
|
-
setInitialStates();
|
|
91
|
-
setValues();
|
|
92
|
-
(0, _index.addOrUpdateStatsToLocalStorage)(props.testIdentifier, Statistics.current);
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
(0, _react.useEffect)(() => {
|
|
96
|
-
(0, _index.removeStatsFromLocalStorage)(props.testIdentifier);
|
|
97
|
-
init();
|
|
98
|
-
loadBodyPixModel();
|
|
99
|
-
}, []);
|
|
100
|
-
(0, _react.useEffect)(() => {
|
|
101
|
-
if (!isWatching) {
|
|
102
|
-
setLookedAwayCount(lookedAwayCount => lookedAwayCount + 1);
|
|
103
|
-
}
|
|
104
|
-
}, [isWatching]);
|
|
105
|
-
(0, _react.useEffect)(() => {
|
|
106
|
-
tabSwitchingCheck(isTabVisible);
|
|
107
|
-
}, [isTabVisible]);
|
|
108
|
-
(0, _react.useEffect)(() => {
|
|
109
|
-
if (!canOpenFullScreen && !firstTimeFullScreen) {
|
|
110
|
-
setFullScreenExitCount(fullScreenExitCount => fullScreenExitCount + 1);
|
|
111
|
-
}
|
|
112
|
-
}, [canOpenFullScreen]);
|
|
113
|
-
(0, _react.useEffect)(() => {
|
|
114
|
-
setValues();
|
|
115
|
-
(0, _index.addOrUpdateStatsToLocalStorage)(props.testIdentifier, Statistics.current);
|
|
116
|
-
}, [userCount, tabSwitchCount, fullScreenExitCount, lookedAwayCount, props.testIdentifier, isWatching]);
|
|
117
|
-
|
|
118
|
-
if (props.TestComponent === undefined || props.testIdentifier === undefined) {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const multipleUserCount = async (network, video) => {
|
|
123
|
-
try {
|
|
124
|
-
const body = await network.segmentMultiPerson(video, _index.bodypixConfigs);
|
|
125
|
-
setUserCount(body ? body.length : 0);
|
|
126
|
-
|
|
127
|
-
if (!(0, _index.isArrayValid)(body)) {
|
|
128
|
-
setIsWatching(false);
|
|
129
|
-
}
|
|
130
|
-
} catch (err) {
|
|
131
|
-
console.log('Error Trace:', err);
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
const glanceChecker = async (network, video) => {
|
|
137
|
-
try {
|
|
138
|
-
const partSegmentation = await network.segmentPersonParts(video, _index.bodypixConfigs);
|
|
139
|
-
const currentPercentage = (0, _index.getGlancePercentage)(partSegmentation);
|
|
140
|
-
setIsWatching(currentPercentage >= _index.glancePercentageToPass);
|
|
141
|
-
} catch (err) {
|
|
142
|
-
console.log('Error Trace:', err);
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
const loadBodyPixModel = async () => {
|
|
148
|
-
const network = await bodyPix.load();
|
|
149
|
-
setInterval(() => {
|
|
150
|
-
if ((0, _index.isWebcamVideoValid)(webcamReference) && fullScreenElement) {
|
|
151
|
-
const video = webcamReference.current.video;
|
|
152
|
-
const videoWidth = webcamReference.current.video.videoWidth;
|
|
153
|
-
const videoHeight = webcamReference.current.video.videoHeight;
|
|
154
|
-
webcamReference.current.video.width = videoWidth;
|
|
155
|
-
webcamReference.current.video.height = videoHeight;
|
|
156
|
-
canvasReference.current.width = videoWidth;
|
|
157
|
-
canvasReference.current.height = videoHeight;
|
|
158
|
-
multipleUserCount(network, video);
|
|
159
|
-
glanceChecker(network, video);
|
|
160
|
-
}
|
|
161
|
-
}, _index.secondsToCheckUserCountAndGlance * 1000);
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
165
|
-
className: "ProctorApp"
|
|
166
|
-
}, !canOpenFullScreen ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("h1", null, "Test can run only in Full Screen Mode"), /*#__PURE__*/_react.default.createElement(_ResponseModal.default, {
|
|
167
|
-
SetCanOpenFullScreen: SetCanOpenFullScreen,
|
|
168
|
-
setFirstTimeFullScreen: setFirstTimeFullScreen,
|
|
169
|
-
firstTimeFullScreen: firstTimeFullScreen,
|
|
170
|
-
setFullScreenExitCount: setFullScreenExitCount,
|
|
171
|
-
fullScreenMessage: props.fullScreenMessage
|
|
172
|
-
})) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_FullScreenTestInWebcam.default, {
|
|
173
|
-
webcamRef: webcamReference,
|
|
174
|
-
canvasRef: canvasReference,
|
|
175
|
-
userCount: userCount,
|
|
176
|
-
isWatching: isWatching
|
|
177
|
-
})));
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const getStatistics = testIdentifier => {
|
|
181
|
-
return JSON.parse((0, _index.retriveStatsFromLocalStorage)(testIdentifier));
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
exports.getStatistics = getStatistics;
|
|
185
|
-
var _default = ProctorApp;
|
|
186
|
-
exports.default = _default;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = usePageVisibility;
|
|
7
|
-
|
|
8
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
9
|
-
|
|
10
|
-
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
|
-
var _GetBrowserDocumentProp = _interopRequireDefault(require("./GetBrowserDocumentProp"));
|
|
13
|
-
|
|
14
|
-
var _GetIsDocumentHidden = _interopRequireDefault(require("./GetIsDocumentHidden"));
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
function usePageVisibility() {
|
|
19
|
-
const [isVisible, setIsVisible] = _react.default.useState((0, _GetIsDocumentHidden.default)());
|
|
20
|
-
|
|
21
|
-
const onVisibilityChange = () => setIsVisible((0, _GetIsDocumentHidden.default)());
|
|
22
|
-
|
|
23
|
-
_react.default.useEffect(() => {
|
|
24
|
-
const visibilityChange = (0, _GetBrowserDocumentProp.default)('Visibility');
|
|
25
|
-
document.addEventListener(visibilityChange, onVisibilityChange, false);
|
|
26
|
-
return () => {
|
|
27
|
-
document.removeEventListener(visibilityChange, onVisibilityChange);
|
|
28
|
-
};
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
return isVisible;
|
|
32
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.secondsToCheckUserCountAndGlance = exports.glancePercentageToPass = exports.bodypixConfigs = void 0;
|
|
7
|
-
const bodypixConfigs = {
|
|
8
|
-
flipHorizontal: false,
|
|
9
|
-
internalResolution: 'medium',
|
|
10
|
-
segmentationThreshold: 0.4,
|
|
11
|
-
maxDetections: 10,
|
|
12
|
-
scoreThreshold: 0.2,
|
|
13
|
-
nmsRadius: 20,
|
|
14
|
-
minKeypointScore: 0.3,
|
|
15
|
-
refineSteps: 10
|
|
16
|
-
};
|
|
17
|
-
exports.bodypixConfigs = bodypixConfigs;
|
|
18
|
-
const glancePercentageToPass = 60;
|
|
19
|
-
exports.glancePercentageToPass = glancePercentageToPass;
|
|
20
|
-
const secondsToCheckUserCountAndGlance = 0.5;
|
|
21
|
-
exports.secondsToCheckUserCountAndGlance = secondsToCheckUserCountAndGlance;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
const defaultValues = {
|
|
8
|
-
tabSwitchCount: 0,
|
|
9
|
-
isTabSwitched: false,
|
|
10
|
-
userCount: 0,
|
|
11
|
-
isWatching: true,
|
|
12
|
-
canOpenFullScreen: null
|
|
13
|
-
};
|
|
14
|
-
var _default = defaultValues;
|
|
15
|
-
exports.default = _default;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.retriveStatsFromLocalStorage = exports.removeStatsFromLocalStorage = exports.addOrUpdateStatsToLocalStorage = void 0;
|
|
7
|
-
|
|
8
|
-
require("core-js/modules/es.json.stringify.js");
|
|
9
|
-
|
|
10
|
-
const addOrUpdateStatsToLocalStorage = (testIdentifier, data) => {
|
|
11
|
-
const stringifiedData = JSON.stringify(data);
|
|
12
|
-
localStorage.setItem(testIdentifier, stringifiedData);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
exports.addOrUpdateStatsToLocalStorage = addOrUpdateStatsToLocalStorage;
|
|
16
|
-
|
|
17
|
-
const retriveStatsFromLocalStorage = testIdentifier => {
|
|
18
|
-
return localStorage.getItem(testIdentifier);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
exports.retriveStatsFromLocalStorage = retriveStatsFromLocalStorage;
|
|
22
|
-
|
|
23
|
-
const removeStatsFromLocalStorage = testIdentifier => {
|
|
24
|
-
localStorage.removeItem(testIdentifier);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
exports.removeStatsFromLocalStorage = removeStatsFromLocalStorage;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = useFullscreenStatus;
|
|
7
|
-
|
|
8
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
9
|
-
|
|
10
|
-
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
function useFullscreenStatus(elRef) {
|
|
15
|
-
const [isFullscreen, setIsFullscreen] = _react.default.useState(document[getBrowserFullscreenElementProp()] != null);
|
|
16
|
-
|
|
17
|
-
const setFullscreen = () => {
|
|
18
|
-
if (!elRef || !elRef.current) return;
|
|
19
|
-
elRef.current.requestFullscreen().then(() => {
|
|
20
|
-
setIsFullscreen(document[getBrowserFullscreenElementProp()] != null);
|
|
21
|
-
}).catch(() => {
|
|
22
|
-
setIsFullscreen(false);
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
_react.default.useEffect(() => {
|
|
27
|
-
document.onfullscreenchange = () => setIsFullscreen(document[getBrowserFullscreenElementProp()] != null);
|
|
28
|
-
|
|
29
|
-
return () => document.onfullscreenchange = undefined;
|
|
30
|
-
}, []);
|
|
31
|
-
|
|
32
|
-
return [isFullscreen, setFullscreen];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function getBrowserFullscreenElementProp() {
|
|
36
|
-
if (typeof document.fullscreenElement !== 'undefined') {
|
|
37
|
-
return 'fullscreenElement';
|
|
38
|
-
} else if (typeof document.mozFullScreenElement !== 'undefined') {
|
|
39
|
-
return 'mozFullScreenElement';
|
|
40
|
-
} else if (typeof document.msFullscreenElement !== 'undefined') {
|
|
41
|
-
return 'msFullscreenElement';
|
|
42
|
-
} else if (typeof document.webkitFullscreenElement !== 'undefined') {
|
|
43
|
-
return 'webkitFullscreenElement';
|
|
44
|
-
}
|
|
45
|
-
}
|