antoniop
committed
on 24 May 23
Implement "ground-truth" check for proctoring to make sure that we are sending pictures

When more than 10 times the expected maximum procto… Show more
Implement "ground-truth" check for proctoring to make sure that we are sending pictures

When more than 10 times the expected maximum proctoring interval has pasased without any picture being successfully sent to the server, the proctored session will be aborted.

Show less

openacs-4/.../resources/proctoring.js (+2 -1)
680 680
681 681
682 682     takeShot(stream, grayscale) {
683 683         const i = this.streams.indexOf(stream);
684 684         const video = this.videos[i];
685 685
686 686         if (!video.paused) {
687 687             const streamName = this.streamNames[i];
688 688             const conf = this.mediaConf[streamName];
689 689             // const height = stream.getVideoTracks()[0].getSettings().height;
690 690             // const width = stream.getVideoTracks()[0].getSettings().width;
691 691             const iHeight = typeof conf.height === 'undefined' ? video.videoHeight : conf.height;
692 692             const iWidth = typeof conf.width === 'undefined' ? video.videoWidth : conf.width;
693 693             const self = this;
694 694             const pictures = this.pictures[i];
695 695             const prevPicture = this.prevPictures[i];
696 696
697 697             const canvas = document.createElement('canvas');
698 698             canvas.width = iWidth;
699 699             canvas.height = iHeight;
700               canvas.getContext('2d').drawImage(video, 0, 0, iWidth, iHeight);
  700             const ctx = canvas.getContext('2d', {willReadFrequently: true});
  701             ctx.drawImage(video, 0, 0, iWidth, iHeight);
701 702
702 703             // In the future we might be stricter about black pictures...
703 704             // if (this.isCanvasMonochrome(canvas)) {
704 705             //     throw 'canvas is monochrome';
705 706             // }
706 707
707 708             // Check that camera does not keep sending the same
708 709             // picture over and over.
709 710             if (streamName === 'camera' &&
710 711                 prevPicture !== null &&
711 712                 this.areCanvasEquals(canvas, prevPicture)) {
712 713                 throw 'Camera is sending the same identical picture twice.';
713 714             }
714 715             this.prevPictures[i] = this.cloneCanvas(canvas);
715 716
716 717             if (grayscale) {
717 718                 this.canvasToGrayscale(canvas);
718 719             }
719 720
720 721             this.watermark(canvas, (new window.Date()).toTZISOString());