Select "Organization" from the primary navigation menu located on the left-hand side of the Testinvite application.
Select Snippets from the presented options.
Select Functions from the presented snippet options.
A catalog of previously established custom functions will appear. To generate a new function, click on the red plus icon located in the lower-right corner of the page. A new form will appear, accompanied by a code editor.
Provide a title for your custom function.
Provide a description for your custom function.
Compose a personalized code for the function.
Composing the function code
The function must be designated as anonymous, and it should permit only one parameter, which can be named "data." The question's given answer will be transferred to your function via the "data" parameter, allowing you to analyze its contents, create a customized algorithm, and return an object with a single property called "score." The value of the "score" property should be a numeric value between -1 and 1.
The "data" parameter is anticipated to have a "response" property inside it, which may either contain an "undefined" value or a string value.
The function is executed within a secure container and cannot access any environmental variables or resources. All of the logic for assessing the provided response must be enclosed solely within the function's code, and no external resources or APIs can be accessed.
Emulating the execution of the function proving the data parameter
By selecting the "Emulator" button situated at the lower-right corner of the code editor, you can experiment with your function by crafting a data parameter in JSON format.
Create a JSON object with one property called "response" and allocate it a string value.
Click on the Apply button.
Observe the output area. The score property must be a number between -1 and 1.
Linking your personalized function with an input question as the automated evaluator.
If the input type is Text-field, Text area, or Numeric, your function can be connected with the input question as an automated evaluator.
If you revise your function code following its connection to your question, select the refresh button to apply the changes to your question.
Previewing your question and the operation of auto-scoring