Blog 1

Random Talk on Random Thoughts

Cheat in an Online Quiz

| Comments |

Background

I saw an online quiz on France Technology.

I didn’t know the answers, but wanted to give the right response.1

How?

First, view the HTML source code of the web page for the quiz and find the relevant part.

Part of the source code for the quiz
1
2
3
4
5
6
7
8
<div><h3>1.In which year was the first French technical exhibition
held in China?</h3></div>
<input type="radio"  name="d1">A.1492 <br />
<input type="radio" name="d1">B.1954<br />
<input type="radio" name="d1" value="1">C.1964 <br />
<input type="radio" name="d1">D.2014<br />
<input type="button" value="Submit" class="submit"/>
</div>

It’s quite obvious that ‘C’ is the answer.

If one wants to know what will happen after clicking the “Submit” button, one may search for this word in the HTML source code. In this case, one finds a jQuery function.

What does the "Submit" button do?
1
2
3
4
5
6
7
8
9
10
11
$(document).ready(function(){
  $(".submit").click(function(){
	$this=$(this);
	value=$this.parent().find("input:radio:checked").val();
	if(value==1){
	    alert("Congratulations! right answer~");
	}else{
	    alert("OOPS, wrong answer~");
	}
  });
});

Finally, one can conclude that if the radio button has the value one, then it is certainly the answer.


  1. The link to the online quiz, which was on http://www.kejifalanxi.com/en/category/quiz, is now dead.

Comments