Assess API Methods
append()
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/features should be rendered. If no DOM element is provided, the created questions/features will be appended to the end of Assess API's container.
-
features array
An array of feature configuration objects.
-
questions array
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
-