Assess API Methods
append()
Append additional Questions or Features to the desired DOM element. The appended Question and Feature instances can then be stored and interacted with through Question instance methods and Feature instance methods respectively.
Examples
assessApp.append({
// optional - if not set, additional questions/features will be appended
// to the end of assess app's container
"element": document.querySelector('.additional-widget-wrapper'),
"features": [{
"type": "calculator",
"mode": "basic"
}],
"questions": [{
"type": "plaintext"
}]
}).then(function (data) {
// suffixed with 0, 1, ...n if there are many features with the same "type"
var newCalculatorInstance = data.features['calculator-0'];
// suffixed with 0, 1, ...n if there are many questions with the same "type"
var newPlaintextInstance = data.questions['plaintext-0'];
// User now can interact with appended widgets through their public methods
// Toggle visibility of current calculator instance
newCalculatorInstance.toggle();
}).catch(function (error) {
throw error;
});
Arguments
-
options object
-
element object
A DOM element into which additional Questions or Features should be rendered. If no DOM element is provided, the created Questions or Features will be appended to the end of Assess API's container.
-
features array[FeatureJSON]
An array of Feature configuration objects.
-
questions array[QuestionJSON]
An array of Question configuration objects.
-
Return value
Type promise
-
then function
Takes a success callback function that resolves the promise with an AppendData object as its parameter.
-
catch function
Takes a rejection callback function that rejects the promise with an error as its parameter.
Type definitions
-
AppendData object
An object containing Question and Feature objects that allow access to methods of each newly appended question and feature instance.
-
features AppendDataFeatures
-
questions AppendDataQuestions
-
-
AppendDataFeatures object
An object containing Feature objects. Each FeatureObject will be prefixed with "[feature type]-[index of feature]", e.g.
appendData.features['calculator-0']
.-
[featureKey] FeatureJson
-
-
AppendDataQuestions object
Each QuestionJson object will be prefixed with "[question type]-[index of question]", e.g.
appendData.questions['shorttext-0']
.-
[questionKey] QuestionJson
-