How can I automatically trigger fullscreen mode for my online exam system?
Asked by
TechWhiz42
I'm working on an online examination system using PHP and XAMPP, and I've hit a roadblock. I want to automatically enter fullscreen mode when a student starts an exam to prevent them from accessing other browser tabs. I attempted to use a JavaScript function that I found, but it hasn't worked as expected. Here's the code I used:
```javascript
function openFullscreen() {
const elem = document.documentElement;
if (elem.requestFullscreen) {
elem.requestFullscreen();
} else if (elem.mozRequestFullScreen) { // Firefox
elem.mozRequestFullScreen();
} else if (elem.webkitRequestFullscreen) { // Chrome, Safari, Opera
elem.webkitRequestFullscreen();
} else if (elem.msRequestFullscreen) { // IE/Edge
elem.msRequestFullscreen();
}
}
```
And I added a button in my HTML to trigger it:
```html
```
Unfortunately, this isn't functioning as I anticipated. Any tips on how I can solve this issue?
Answers
To effectively prevent cheating, consider using a dedicated tool like Safe Exam Browser, which many educational programs rely on for secure testing. Relying solely on PHP and JavaScript might not be sufficient for preventing dishonest behavior.
Reply to this answer
If you have control over the computer, you can restrict students from navigating away from the exam page. But if that's not the case, keep in mind that browser security is designed to prevent sites from doing exactly what you're trying to do. It might be tough to fully achieve what you want without extra tools or permissions.
Reply to this answer
Just saying 'it didn't work' isn't enough. You need to debug and find out which part of your script is failing. Check your console for any error messages or logs that can help pinpoint the issue.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions