How create a new question type

In order to create or modify a custom question type, select the item "Custom question types" from Quiz menu, or click the button on toolbar of the main window. A dialog window will appear with a list of custom question types, as shown in the figure below:

In order to create a new question type, press the push button "Add". A new window will appear, as shown in figure below:

The "Main" sheet allows to insert the first information for define the question type:

  1. The name of question type (it is mandatory).
  2. A description of this type of question.
  3. An icon, with maximum size of 16 x 16 pixel and a file size less then 10KB.
  4. The number of this current version of the component (it can change, since is like a software module that can have more than one build).
  5. How valuate the question, if with a "correct" or "wrong" response, or using a score method (with a minimum point and a maximum point).

Sheet HEAD - Javascript

Here the list of the external Javascript files (with ".JS" as file extension) that will be copied into quiz file (.XQZ), and in the HTML quiz page (HEAD section) will be included as:

<script type="text/javascript" src="..."></script>

Sheet HEAD - CSS

Here the list of the external CSS files (with ".CSS" as file extension) that will be copied into quiz file (.XQZ), and in the HTML quiz page (HEAD section) will be included as:

<link rel="stylesheet" type="text/css" href="..." />

Sheet BODY - Javascript

Here the Javascript code that will be included into HTML quiz page (section BODY), that will be run when the page is opened and can contains functions that are called from some HTML elements or from any other functions.

Sheet BODY - HTML

Here the piece of HTML code in the BODY section of the HTML quiz page.

After the last line of your code, the following HTML line will be always added:

<INPUT type="hidden" NAME="custom_%NAME_%NUM" VALUE="0">

It is a "hidden" tag that it is not shown into HTML page but its value must be set from your Javascript code, VALUE=1 for a correct answer and VALUE=0 for a wrong answer.

Sheet BODY - Multimedia

Here the list of file that represent multimedia objects.

As happens for external Javascript and CSS file, also the multimedia files are copied into quiz file (.XQZ), so any dependences from source file will be lost.

Moreover, during the creation of the HTML quiz, these files will be copied into "media" sub-folder, so into your HTML code, you should refer to them in the following way (in a case of image):

<IMG SRC="media/filename">

It means that, in the HTML code, any file name listed in the "multimedia list" have to preceded from the "media/" path.

Sheet BODY - Parameters

A parameter is defined by:

Parameter type can be:

The cryptography of the parameter value into HTML page is important in some cases, mainly when the value is the correct answer or can help the student to discover the correct answer simply opening the HTML source code.

How use the parameters into code

A parameter can be used into HTML code and/or into Javascript code of the BODY section of the HTML page, but not into external Javascript files (included into HEAD section).

The refer of a parameter into code uses the following syntax : a percent (%) sign must be precede and follow the parameter name, like in %PARAMETER%.

Consider the following example of a parametrized Javascript function:

	function checkNumericAnswer%NUM%()
	{
	  var answerField = document.getElementById("numeric_ans_%NUM%");
	  var answerValue = parseFloat(answerField.value);
	  var min_value = (%ANSWER% - %TOLERANCE%);
	  var max_value = (%ANSWER% + %TOLERANCE%);
	  if ((answerValue >= min_value) && (answerValue <= max_value)) {
		document.domanda.custom_%NAME%_%NUM%.value = 1;
	  }
	  else {
		document.domanda.custom_%NAME%_%NUM%.value = 0;
	  }
	}

Note that the name of this function depends on the number of question where it will be inserted, so, if you have more than a question with this type, the function will never will have the same name and the code will be correct.


Related topics