The safest method to use Javascript to check Quiz responses

After intensive work on a project using AJAX + PHP, developing a suitable quiz game, I found out that the training package that my company uses to distribute its products does not allow me to run server-side scripts on the server to safely check responses. This is all due to the failed hierarchical autocracy.

In short, I need to somehow check the responses on the client side (or find out something complicated). Fortunately, I was able to load jQuery into a local folder structure to use this.

What is the safest method for checking client responses on the client side? Or is there a way to link to an external file ... like an XML file or something else to check responses more securely?

+2
source share
2 answers

The only thing I can think of is obfuscating your code. This process is also known, it is its minimization. If you do this, your code will be harder to read and therefore a little harder to crack. This does not make it inaccessible, but it makes life a little more difficult for those who want to cheat. You have several options:

I think this applies to all the basic ones, but if you know more that I did not mention, please leave a comment below.

Related answer question: Is there a good JavaScript minifier?

+2
source

Well, if you really want and need to do everything in JS, here's how I do it:

  • Do not store the correct answers in clear text, use a kind of hashing.
  • Hide the response object and hash function in closure so that they cannot be called through the js browser console.
  • Add some asynchronous part in the verification process, for example. simple timeout. Use this throttling code to iterate over a form by programmatically checking responses and searching for result objects.
  • Obfuscate code. Security through obscurity is never a good concept, but it can prevent potential hackers from directly copying the relevant parts from your code.

However, it is not yet clear how you send the results to the server to store them. If this piece is easily tampered with, you get lost.

+3
source

All Articles