HTML5 API

Question Writer HTML5 API

Whenever you add a Javascript node, an object with the name ‘QWAPI’ is made available to your script. You can call the the following methods on this object.

QWAPI.getScore(scoreID)
scoreID is a string. Use “SCORE” to return the current overall score. Use any other Score identifier to get the total of any score you have defined.

QWAPI.getElement(theID)
theID is a string. Gets an HTML element referenced by its id attribute. Usually you will have defined this element in an HTML node. Use this in preference to the Javascript ‘getElementByID’ to ensure that the element is containted within the assessment div. However this method may be slower.

QWAPI.isLoading()
This method returns a boolean to indicate if the test is still loading.

QWAPI.isSending()
This method returns a boolean to indicate if the test is currently sending responses to the server.

QWAPI.isFinished()
This method returns a boolean to indicate if the test is on the ‘finished’ screen. Note, this will return false if the user is still viewing the report or feedback.

QWAPI.areResponsesSent()
This method returns a boolean to indicate if the responses of the test have been sent.

QWAPI.getCandidateData(id)
id should be an integer between 1 and 5. This retreives the user’s response to the user data fields in the introduction page

QWAPI.setResultsURL(newURL)
newURL should be the URL to the Collator software or other response processing script

QWAPI.setBackupResultsURL(newURL)
newURL should be the URL to the Backup software or other backup script

QWAPI.hideNextButton()
This sets the display value of the next button to ‘none’, effectively hiding it. Note, the display setting will be reset when the user exits or re-enters the page.

QWAPI.showNextButton()
This sets the display value of the next button to ‘inline’, displaying it. Note, it can only re-display a Next Button that has been hidden, it cannot create a new one.

QWAPI.setMaxTries(maxTries)
maxTries should be an integer. When sending results, QW will try this number of times to send results before giving up and displaying feedback. Set to 0 to try indefinitely.

QWAPI.setMaxTriesExceededMessage(maxTriesExceededMessage)
Set the message to be displayed to the user when maxTries has been reached. Set to the empty string, “”, to show no message.

Plugin Questions

If you need access to the API from a plugin question, you can access it through assessmentRef.getAPIQWObject()

Leave a Reply