Java quiz applet - Photoquiz

This is the pure quizz applet. The applet show a question and the user must choice one of the possible responses. The plus of this applet is to interest the player by showing a photo with a mosaic. The more you answer the questions, the better is the photo resolution.
When a photo is discover, the applet loads another one and the game continue.
If you find a good subject, the player will absolutely want to discover the photo and will try to answer to the question seriously. Isn't it your goal ?

How does it work :

Photoquiz first load randomly one of the images. All the image must have the same filename representation ( for example img0.gif, img1.gif, img2.gif ). Parameters are provided to define the model of the image file name.
Then photoquiz loads the questions. If you have a little set of question ( less than 50 for example), the best is to ask photoquiz to load the complete set at the initialisation.
If you have a great set of question, give in parameter a script and the number of question photoquiz must load each time.
When the player has seen 75% of the questions, Photoquiz will call the script to load a new set of questions. The precedent questions will be kept for a new game.

How does a question file look like ?

A question file still have the same profile :
  • One question by line
  • A line is made of fields separated by comma
The order of the fields is very important and must be like this :
  • First field : Always equal to character 'q'. This is for an eventual evolution of the applet.
  • Second field : Index of the good answer.
  • Third field : Label of the question.
  • Next fields : The proposition. The number is limited to 4 elements.
Example :
I want to add a question in my file
  • The question is "1+1=?"
  • The possibles response are : 1,2,3
  • The index of the good answser is 1 ( the second proposal, I hope you agree ).
The line is equal to :

Exemple 1 : One load usage

In this example, the applet load all the questions at the initialisation.


<applet code="photoquiz.class" archive="photoquiz.jar" width="260" height="400">
<param name="qf" value="math.txt">
<param name="nqm" value="5">
<param name="nim" value="3">
<param name="mh" value="260">
<param name="bg" value="ffce63">
<param name="fontname" value="arial">
<param name="fontsize" value="12">
<param name="if" value="./image#.jpg">
<param name="oneload" value="">

The file math.txt

q,2,1 or 0 =,0, 2,1
q,1,0 nor 0 =,0,1,2

Usage with scripts

In this example, the applet call a script wich load five questions each time.
This is an example because the question file contains only ten question. But if you have hundreds of questions and doesn't want your user to wait to much time, it can be a good answer.
Here is the PHP script file :
$f = file ($fn);
$i = 0;
while ( $i++ < 5 && $nl < count($f) )
   print $f[$nl++];
It is very simple and only read 5 lines from a text file. The first line to read is given by the parameter nl. It is a very simple example but we can imagine data read from a database.


<applet code="photoquiz.class" archive="photoquiz.jar" width="260" height="400">
<param name="qf" value="./getquestion.php?fn=math.txt&nl=#">
<param name="nqm" value="5">
<param name="nim" value="3">
<param name="mh" value="260">
<param name="bg" value="ffce63">
<param name="if" value="./image#.jpg">

Photoquiz parameters

oneloadIf this parameter is present, the question file is loaded only at the initialisation. If the question file is a script, it will be called only one time.process.
qfURL of the question file. It can be a texte file to load or a script file. If you want photoquiz to give the actual number of loaded questions in parameter, just add the character '#'. Photoquiz will replace this character with this number
Example : You have to call the script myscript.php3 with the parameter ll equals to the number of lines already loaded.
You must enter :
<param name="qf" value="./myscript.php3?ll=#">
nqmMaximum number of question in the question file or, maximum number of existing question when you call a script
mhMaximum height of a photo in pixels.
nimMaximum number of image
ifImage file number. Enter a '#' character where you want photoquiz to put a number between 0 to nim.
Example : You have 3 images, called img0.gif,img1.gif,img2.gif, you must enter :
  • <param name="nim" value="3">
  • <param name="if" value="./img#.gif">
bgBackground color in RGB format.
inkInk color in RGB format.
fontnameFont name of the questions.
fontsizeFont size of the questions.
scoreIf this parameter is present, a score is added.
sngMultilanguage support. New game button label.
svMultilanguage support. Validate button label.
scMultilanguage support. Continue button label.
sgaMultilanguage support. "Good anwser" label.
sawMultilanguage support. "The good anwser was" label.
URLNo required. An URL to call each time the player has discover the photo. If the score parameter is set, the URL will be called with ?score=the user score.
  • The parameter score is set.
  • The URL equals "./savescore"
  • The player has a score of 30
A document ./savescore?score=30 will be called by the applet.
targetThe target where the applet must open the document given by URL. The default is "_top"