Evaluation Options Editor API Methods
setOptions()
Loads the specified evaluation options into the editor.
You would want to use this method so that you can display options you saved earlier, for example, when the author switches to another Question.
The loaded options replace all the options that are currently set, and the editor shows the default value for every option that is not in the JSON. You can call this method before you attach the editor or while it is detached.
Examples
// Load options and suppress the change event for this call
await editor.setOptions(
{
grading: {
learner_level: 'academic-5'
}
},
{ silent: true }
);
Arguments
-
options object
The evaluation options object to load into the editor. For the format, see evaluation options.
-
settings object
Controls optional settings for how the options are loaded.
The following properties are supported.
-
silent boolean
Controls whether the
changeevent is fired.You would want to use this argument to load options without triggering the
changeevent.Default:
false -
strict boolean
Controls whether the options are validated against the evaluation options schema.
You would want to set this argument to
falsewhen you need to load options that contain values the schema does not allow, for example, options that you saved with an earlier version.Default:
truePossible values
-
true- The editor validates the options against the schema and rejects them if a value is not allowed. -
false- The editor does not validate the options.
-
-
Return value
Type Promise
Resolves when the options are loaded, or rejects if the options are invalid.
Caveats
- This method fires the
changeevent unless you setsilenttotrue. If you call this method from achangeevent handler, setsilenttotrueto avoid an infinite loop. - When the editor is attached with the
defaultvariant, it can fire thechangeevent again shortly after this method resolves, when it displays the loaded options. This can happen even whensilentistrue.