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:
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>
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="..." />
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.
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.
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.
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.
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