How can I automatically trigger fullscreen mode for my online exam system?

0
8
Asked By TechWhiz42 On

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?

3 Answers

Answered By DebuggingDude On

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.

Answered By CodeNinja99 On

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.

Answered By ExamExpert67 On

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.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.