Creating question styles

 

Question styles are entered in the Styles page by an administrator who has that access right. A question style uses the Form style tags. However, because it will be embedded within a page, it omits <head> and <body> sections. Make sure that all question types that can be used with this template are defined, such as radio buttons, checkboxes, etc. Study the Question Styles provided.

The Standard_ style include all the necessary JavaScript for validation. To create your own question styles, you must name them Standard_yourstylename. Examine the Standard_ style and note how it creates a ValidatorArray and includes an onSubmit function. Their purpose is to provide a way to check that entered values are correct before the form is submitted, and to cancel the submission if they are not.

Each Question Style includes JavaScript that adds a uniquely named function to the ValidatorArray, which performs the desired checks and displays appropriate Alerts.

To examine some existing styles, use the Styles page and examine the Standard_Number and Standard_Date styles.

Question properties

Styles use question properties to specify additional attributes of a question style, such as the format of a Date or the format of a Number. To use question properties, use the qpropertynames and xmlqproperties sections inside the comment section. Please open and print the Standard_Number and Standard_Date styles for an example, and create a question and assign the Number and Date styles to it to see how question properties work.

The qpropertynames section lists the names of the properties to be defined, separated by commas.

The xmlqproperties section is an XML fragment, beginning with an xml tag, and one element, xmlelements. Within this element, there are two elements: styledescription, which will describe what the style does under the "Select Style" drop down, and questionpropertiesform. This second element surrounds an HTML fragment in the XMLdelimiters <![CDATA[ and ]] so that the HTMLfragment will be interpreted correctly. The HTML fragment consists of form input fields whose names match the names listed in the qpropertynames section, and whose value expresses the value entered.

For example, this tag displays the "numberdecimals" property as an input field:
<input name="numberdecimals" tabindex="21" type="text" id="numberdecimals" value="[/qproperty,numberdecimals,0]" size="1" maxlength="3" />
The value field tag [/qproperty,numberdecimals,0] indicates that the current value of the property should be displayed, and that if there is no current value, the value 0 should be displayed.

In this example, a check box toggles the "include_in_report" property on and off:
<input type="checkbox" id="include_in_report" name="include_in_report" value="checked" [/qproperty,include_in_report,checked] />
Note that the value must be "checked".

See also Using Question Styles.

Next: Custom tags