Plugin Question Specification

Plugin Questions

Plugin Questions allow you to extend Question Writer to use any question type. They are created as Javascript objects and must conform to the interface laid out here.

Constructor

The object name must start with the four letters ‘QWPQ’. This is shorthand for Question Writer Plugin Question. It is recommended that the object name contains a version number so that new versions of the plugin do not conflict with older versions.

The filename must be the object name, with the extension ‘.js’

Here is an example constructor defined in a file, QWPQ000CycleV1_2.js

function QWPQ000CycleV1_2(assessmentReference, theResponseID, parameterPairs){

     …

 }

Three objects are passed to the plugin file,

assessmentReference – A reference to the high level assessment object

theResponseID – A string containing the unique (within the assessment) identifier for the question. This will have a different value when the plugin is called to show the question, and the feedback for the question.

parameterPairs – An associative array containing a set of name/value pairs relevant to the question

Setup

Question Writer allocates a ‘div’ element for everything related to the question. To get this div call

var theDiv = assessmentRef.getNodeByID(respID);

The Div will contain all of the options for the question that have been defined in Question Writer. Each option will be in its own Div and will have and id attribute that begins with the ‘respID’ variable. Note – the main question Div may contain other Divs that are not options (they may indicate how to layout options instead), and the options may be nested inside of these at any depth.

The question parameters can be accessed through the associate array object, like so,

this.answer=parameterPairs[“_answer”];

The following parameters will always be present.

_maxScore (the awardable score from the plugin question properties box)

_isFeedback (false if showing the question, true if showing feedback)

Where _isFeedback is true, an additional parameter will be present _originalquestionid (theResponseID from the instance where the question is shown) In addition, any parameters defined in the plugin question properties box will be available too.

Responsibilities

The plugin question object must implement the ‘isFullyAnswered’ method QWPQ000CycleV1_2.prototype.isFullyAnswered = function () {  … }

This will be called by the Question Writer player when it needs to know if a satisfactory attempt has been made at the question. This is used when the ‘Force Attempt’ option is selected – the next button will not be displayed until all the questions present on the page return ‘true’ for this method.  The method should return a boolean, either true if an attempt has been made or false if has not.

Responses

To record responses and scores for a question, the plugin question object should call this method.

assessmentReference.setAnswers(theResponseID, answers, triggerFullyAnswered, score);

assessmentReference and theResponseID should be the objects passed to the constructor

answers should be an array of strings containing the response(s) for the question

triggerFullyAnswered should be a boolean and controls whether the page is evaluated as being in a ‘Fully Attempted’ state, so that the QW player can display the next button. Note: this should always be ‘false’ if called from the constructor, and usually ‘true’ otherwise.

score should be a number – it should not be in excess of _maxScore

You can retrieve the responses previously entered by the candidate by calling this method assessmentReference.getRespListAsArray(theResponseID);

This will return an array of strings containing the responses previous set with the ‘setAnswers’ method.

Note: If the question is being displayed in the feedback mode, the following adjustment should be used –

assessmentReference.getRespListAsArray(parameterPairs[“_originalquestionid”]);

Leave a Reply