@khanacademy/perseus-core 12.1.0 → 14.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accessibility.d.ts +26 -0
- package/dist/es/index.js +55 -47
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.js +66 -48
- package/dist/index.js.map +1 -1
- package/dist/parse-perseus-json/perseus-parsers/cs-program-user-input.d.ts +4 -0
- package/dist/parse-perseus-json/perseus-parsers/cs-program-user-input.typetest.d.ts +1 -0
- package/dist/parse-perseus-json/perseus-parsers/expression-widget.d.ts +1 -1
- package/dist/parse-perseus-json/perseus-parsers/free-response-user-input.d.ts +3 -0
- package/dist/parse-perseus-json/perseus-parsers/free-response-user-input.typetest.d.ts +1 -0
- package/dist/parse-perseus-json/perseus-parsers/grapher-user-input.d.ts +24 -0
- package/dist/parse-perseus-json/perseus-parsers/grapher-user-input.typetest.d.ts +1 -0
- package/dist/parse-perseus-json/perseus-parsers/group-user-input.d.ts +3 -0
- package/dist/parse-perseus-json/perseus-parsers/group-user-input.typetest.d.ts +1 -0
- package/dist/parse-perseus-json/perseus-parsers/iframe-user-input.d.ts +4 -0
- package/dist/parse-perseus-json/perseus-parsers/iframe-user-input.typetest.d.ts +1 -0
- package/dist/parse-perseus-json/perseus-parsers/user-input-map.d.ts +17 -0
- package/dist/parse-perseus-json/perseus-parsers/widget-id-components.d.ts +27 -0
- package/dist/traversal.d.ts +16 -0
- package/dist/utils/get-default-answer-area.d.ts +2 -0
- package/dist/utils/util.graphie.d.ts +6 -0
- package/dist/validation.types.d.ts +1 -0
- package/dist/widgets/apply-defaults.d.ts +3 -0
- package/dist/widgets/core-widget-registry.d.ts +5 -2
- package/dist/widgets/expression/index.d.ts +7 -1
- package/dist/widgets/logic-export.types.d.ts +3 -2
- package/dist/widgets/measurer/index.d.ts +7 -1
- package/dist/widgets/radio/derive-num-correct.d.ts +2 -0
- package/dist/widgets/radio/index.d.ts +7 -1
- package/package.json +4 -4
- package/dist/widgets/expression/expression-upgrade.d.ts +0 -11
- package/dist/widgets/measurer/measurer-upgrade.d.ts +0 -10
- package/dist/widgets/radio/radio-upgrade.d.ts +0 -12
- package/dist/widgets/upgrade.d.ts +0 -3
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identifies whether or not a given perseus item requires the use of a mouse
|
|
3
|
+
* or screen, based on the widgets it contains.
|
|
4
|
+
*/
|
|
5
|
+
import type { PerseusItem } from "./data-schema";
|
|
6
|
+
/**
|
|
7
|
+
* Returns a list of widget types that cause a given Perseus item to require
|
|
8
|
+
* the use of a screen or mouse.
|
|
9
|
+
*
|
|
10
|
+
* For now we'll just check the `accessible` field on each of the widgets
|
|
11
|
+
* in the item data, but in the future we may specify accessibility on
|
|
12
|
+
* each widget with higher granularity.
|
|
13
|
+
*
|
|
14
|
+
* @deprecated This function returns a list of widget _types_ that violate our
|
|
15
|
+
* accessibility requirements which is not very accurate given that some
|
|
16
|
+
* instances _could_ be accessible and some not based on their widget options.
|
|
17
|
+
* In most cases, you should use {@link isItemAccessible} instead.
|
|
18
|
+
*
|
|
19
|
+
* @todo Inline this into {@link isItemAccessible}!
|
|
20
|
+
*/
|
|
21
|
+
export declare function violatingWidgets(itemData: PerseusItem): Array<string>;
|
|
22
|
+
/**
|
|
23
|
+
* Returns true if the given Perseus item is accessible (i.e., does not contain
|
|
24
|
+
* any widgets that violate our accessibility requirements).
|
|
25
|
+
*/
|
|
26
|
+
export declare function isItemAccessible(itemData: PerseusItem): boolean;
|
package/dist/es/index.js
CHANGED
|
@@ -156,7 +156,7 @@ const parsePlotterWidget=parseWidget(constant("plotter"),object({labels:array(st
|
|
|
156
156
|
|
|
157
157
|
const parsePythonProgramWidget=parseWidget(constant("python-program"),object({programID:string,height:number}));
|
|
158
158
|
|
|
159
|
-
|
|
159
|
+
function deriveNumCorrect(options){const{choices,numCorrect}=options;return numCorrect??choices.filter(c=>c.correct).length}
|
|
160
160
|
|
|
161
161
|
const parseWidgetsMapOrUndefined=defaulted(optional((rawVal,ctx)=>parseWidgetsMap(rawVal,ctx)),()=>undefined);function getDefaultOptions(){return {choices:[{content:""},{content:""},{content:""},{content:""}]}}const version2=optional(object({major:constant(2),minor:number}));const parseRadioWidgetV2=parseWidgetWithVersion(version2,constant("radio"),defaulted(object({numCorrect:optional(number),choices:array(object({content:defaulted(string,()=>""),clue:optional(string),correct:optional(boolean),isNoneOfTheAbove:optional(boolean),widgets:parseWidgetsMapOrUndefined})),hasNoneOfTheAbove:optional(boolean),countChoices:optional(boolean),randomize:optional(boolean),multipleSelect:optional(boolean),deselectEnabled:optional(boolean),onePerLine:optional(boolean),displayCount:optional(any),noneOfTheAbove:optional(constant(false))}),getDefaultOptions));const version1=optional(object({major:constant(1),minor:number}));const parseRadioWidgetV1=parseWidgetWithVersion(version1,constant("radio"),defaulted(object({choices:array(object({content:defaulted(string,()=>""),clue:optional(string),correct:optional(boolean),isNoneOfTheAbove:optional(boolean),widgets:parseWidgetsMapOrUndefined})),hasNoneOfTheAbove:optional(boolean),countChoices:optional(boolean),randomize:optional(boolean),multipleSelect:optional(boolean),deselectEnabled:optional(boolean),onePerLine:optional(boolean),displayCount:optional(any),noneOfTheAbove:optional(constant(false))}),getDefaultOptions));function migrateV1ToV2(widget){const{options}=widget;return {...widget,version:{major:2,minor:0},options:{...options,numCorrect:deriveNumCorrect(options)}}}const version0=optional(object({major:constant(0),minor:number}));const parseRadioWidgetV0=parseWidgetWithVersion(version0,constant("radio"),defaulted(object({choices:array(object({content:defaulted(string,()=>""),clue:optional(string),correct:optional(boolean),isNoneOfTheAbove:optional(boolean),widgets:parseWidgetsMapOrUndefined})),hasNoneOfTheAbove:optional(boolean),countChoices:optional(boolean),randomize:optional(boolean),multipleSelect:optional(boolean),deselectEnabled:optional(boolean),onePerLine:optional(boolean),displayCount:optional(any),noneOfTheAbove:optional(constant(false))}),getDefaultOptions));function migrateV0ToV1(widget){const{options}=widget;const{noneOfTheAbove:_,...rest}=options;return {...widget,version:{major:1,minor:0},options:{...rest,hasNoneOfTheAbove:false,noneOfTheAbove:undefined}}}const parseRadioWidget=versionedWidgetOptions(2,parseRadioWidgetV2).withMigrationFrom(1,parseRadioWidgetV1,migrateV1ToV2).withMigrationFrom(0,parseRadioWidgetV0,migrateV0ToV1).parser;
|
|
162
162
|
|
|
@@ -166,7 +166,9 @@ const parseTableWidget=parseWidget(constant("table"),object({headers:array(strin
|
|
|
166
166
|
|
|
167
167
|
const parseVideoWidget=parseWidget(constant("video"),object({location:string,static:optional(boolean)}));
|
|
168
168
|
|
|
169
|
-
const
|
|
169
|
+
const parseStringToNonNegativeInt=(rawValue,ctx)=>{if(typeof rawValue!=="string"||!/^(0|[1-9][0-9]*)$/.test(rawValue)){return ctx.failure("a string representing a non-negative integer",rawValue)}return ctx.success(+rawValue)};const parseWidgetIdComponents=pair(string,parseStringToNonNegativeInt);
|
|
170
|
+
|
|
171
|
+
const parseWidgetsMap=(rawValue,ctx)=>{if(!isPlainObject(rawValue)){return ctx.failure("PerseusWidgetsMap",rawValue)}const widgetsMap={};for(const key of Object.keys(rawValue)){const entryResult=parseWidgetsMapEntry([key,rawValue[key]],widgetsMap,ctx.forSubtree(key));if(isFailure(entryResult)){return entryResult}}return ctx.success(widgetsMap)};const parseWidgetsMapEntry=([id,widget],widgetMap,ctx)=>{const idComponentsResult=parseWidgetIdComponents(id.split(" "),ctx.forSubtree("(widget ID)"));if(isFailure(idComponentsResult)){return idComponentsResult}const[type,n]=idComponentsResult.value;function parseAndAssign(key,parse){const widgetResult=parse(widget,ctx);if(isFailure(widgetResult)){return widgetResult}widgetMap[key]=widgetResult.value;return ctx.success(undefined)}switch(type){case "categorizer":return parseAndAssign(`categorizer ${n}`,parseCategorizerWidget);case "cs-program":return parseAndAssign(`cs-program ${n}`,parseCSProgramWidget);case "definition":return parseAndAssign(`definition ${n}`,parseDefinitionWidget);case "dropdown":return parseAndAssign(`dropdown ${n}`,parseDropdownWidget);case "explanation":return parseAndAssign(`explanation ${n}`,parseExplanationWidget);case "expression":return parseAndAssign(`expression ${n}`,parseExpressionWidget);case "free-response":return parseAndAssign(`free-response ${n}`,parseFreeResponseWidget);case "grapher":return parseAndAssign(`grapher ${n}`,parseGrapherWidget);case "group":return parseAndAssign(`group ${n}`,parseGroupWidget);case "graded-group":return parseAndAssign(`graded-group ${n}`,parseGradedGroupWidget);case "graded-group-set":return parseAndAssign(`graded-group-set ${n}`,parseGradedGroupSetWidget);case "iframe":return parseAndAssign(`iframe ${n}`,parseIframeWidget);case "image":return parseAndAssign(`image ${n}`,parseImageWidget);case "input-number":return parseAndAssign(`input-number ${n}`,parseInputNumberWidget);case "interaction":return parseAndAssign(`interaction ${n}`,parseInteractionWidget);case "interactive-graph":return parseAndAssign(`interactive-graph ${n}`,parseInteractiveGraphWidget);case "label-image":return parseAndAssign(`label-image ${n}`,parseLabelImageWidget);case "matcher":return parseAndAssign(`matcher ${n}`,parseMatcherWidget);case "matrix":return parseAndAssign(`matrix ${n}`,parseMatrixWidget);case "measurer":return parseAndAssign(`measurer ${n}`,parseMeasurerWidget);case "molecule-renderer":return parseAndAssign(`molecule-renderer ${n}`,parseMoleculeRendererWidget);case "number-line":return parseAndAssign(`number-line ${n}`,parseNumberLineWidget);case "numeric-input":return parseAndAssign(`numeric-input ${n}`,parseNumericInputWidget);case "orderer":return parseAndAssign(`orderer ${n}`,parseOrdererWidget);case "passage":return parseAndAssign(`passage ${n}`,parsePassageWidget);case "passage-ref":return parseAndAssign(`passage-ref ${n}`,parsePassageRefWidget);case "passage-ref-target":return parseAndAssign(`passage-ref-target ${n}`,any);case "phet-simulation":return parseAndAssign(`phet-simulation ${n}`,parsePhetSimulationWidget);case "plotter":return parseAndAssign(`plotter ${n}`,parsePlotterWidget);case "python-program":return parseAndAssign(`python-program ${n}`,parsePythonProgramWidget);case "radio":return parseAndAssign(`radio ${n}`,parseRadioWidget);case "sorter":return parseAndAssign(`sorter ${n}`,parseSorterWidget);case "table":return parseAndAssign(`table ${n}`,parseTableWidget);case "video":return parseAndAssign(`video ${n}`,parseVideoWidget);case "sequence":return parseAndAssign(`sequence ${n}`,parseDeprecatedWidget);case "lights-puzzle":return parseAndAssign(`lights-puzzle ${n}`,parseDeprecatedWidget);case "simulator":return parseAndAssign(`simulator ${n}`,parseDeprecatedWidget);case "transformer":return parseAndAssign(`transformer ${n}`,parseDeprecatedWidget);default:return parseAndAssign(`${type} ${n}`,parseWidget(constant(type),any))}};const parseDeprecatedWidget=parseWidget((_,ctx)=>ctx.success("deprecated-standin"),object({}));
|
|
170
172
|
|
|
171
173
|
const parsePerseusRenderer=defaulted(object({content:defaulted(string,()=>""),widgets:defaulted((rawVal,ctx)=>parseWidgetsMap(rawVal,ctx),()=>({})),images:parseImages,metadata:any}),()=>({content:"",widgets:{},images:{}}));
|
|
172
174
|
|
|
@@ -180,7 +182,7 @@ const parsePerseusItem$1=object({question:parsePerseusRenderer,hints:defaulted(a
|
|
|
180
182
|
|
|
181
183
|
function parsePerseusItem(json){if(isRealJSONParse(JSON.parse)){return JSON.parse(json)}throw new Error("Something went wrong.")}function parseAndMigratePerseusItem(data){throwErrorIfCheatingDetected();const object=typeof data==="string"?JSON.parse(data):data;const result=parse(object,parsePerseusItem$1);if(isFailure(result)){return failure({message:result.detail,invalidObject:object})}return result}function parseAndMigratePerseusArticle(data){throwErrorIfCheatingDetected();const object=typeof data==="string"?JSON.parse(data):data;const result=parse(object,parsePerseusArticle);if(isFailure(result)){return failure({message:result.detail,invalidObject:object})}return result}function throwErrorIfCheatingDetected(){if(!isRealJSONParse(JSON.parse)){throw new Error("Something went wrong.")}}
|
|
182
184
|
|
|
183
|
-
const libName="@khanacademy/perseus-core";const libVersion="
|
|
185
|
+
const libName="@khanacademy/perseus-core";const libVersion="14.0.0";addLibraryVersionToPerseusDebug(libName,libVersion);
|
|
184
186
|
|
|
185
187
|
const Errors=Object.freeze({Unknown:"Unknown",Internal:"Internal",InvalidInput:"InvalidInput",NotAllowed:"NotAllowed",TransientService:"TransientService",Service:"Service"});
|
|
186
188
|
|
|
@@ -190,117 +192,115 @@ const pluck=function(table,subKey){return _.object(_.map(table,function(value,ke
|
|
|
190
192
|
|
|
191
193
|
function getCategorizerPublicWidgetOptions(options){return {items:options.items,categories:options.categories,randomizeItems:options.randomizeItems,static:options.static}}
|
|
192
194
|
|
|
193
|
-
const defaultWidgetOptions$
|
|
195
|
+
const defaultWidgetOptions$w={items:[],categories:[],values:[],randomizeItems:false};const categorizerWidgetLogic={name:"categorizer",defaultWidgetOptions: defaultWidgetOptions$w,getPublicWidgetOptions:getCategorizerPublicWidgetOptions,accessible:false};
|
|
194
196
|
|
|
195
197
|
function getCSProgramPublicWidgetOptions(options){return options}
|
|
196
198
|
|
|
197
|
-
const DEFAULT_HEIGHT=400;const defaultWidgetOptions$
|
|
199
|
+
const DEFAULT_HEIGHT=400;const defaultWidgetOptions$v={programID:"",programType:null,settings:[{name:"",value:""}],showEditor:false,showButtons:false,height:DEFAULT_HEIGHT};const csProgramWidgetLogic={name:"cs-program",defaultWidgetOptions: defaultWidgetOptions$v,supportedAlignments:["block","full-width"],getPublicWidgetOptions:getCSProgramPublicWidgetOptions,accessible:false};
|
|
198
200
|
|
|
199
|
-
const defaultWidgetOptions$
|
|
201
|
+
const defaultWidgetOptions$u={togglePrompt:"",definition:""};const definitionWidgetLogic={name:"definition",defaultWidgetOptions: defaultWidgetOptions$u,defaultAlignment:"inline",accessible:true};
|
|
200
202
|
|
|
201
203
|
function getDropdownPublicWidgetOptions(options){return {choices:options.choices.map(choice=>({content:choice.content})),placeholder:options.placeholder,static:options.static,visibleLabel:options.visibleLabel,ariaLabel:options.ariaLabel}}
|
|
202
204
|
|
|
203
|
-
const defaultWidgetOptions$
|
|
204
|
-
|
|
205
|
-
const defaultWidgetOptions$r={showPrompt:"Explain",hidePrompt:"Hide explanation",explanation:"explanation goes here\n\nmore explanation",widgets:{}};const explanationWidgetLogic={name:"explanation",defaultWidgetOptions: defaultWidgetOptions$r,defaultAlignment:"inline"};
|
|
205
|
+
const defaultWidgetOptions$t={placeholder:"",choices:[{content:"",correct:false}]};const dropdownWidgetLogic={name:"dropdown",defaultWidgetOptions: defaultWidgetOptions$t,defaultAlignment:"inline-block",getPublicWidgetOptions:getDropdownPublicWidgetOptions,accessible:true};
|
|
206
206
|
|
|
207
|
-
const
|
|
207
|
+
const defaultWidgetOptions$s={showPrompt:"Explain",hidePrompt:"Hide explanation",explanation:"explanation goes here\n\nmore explanation",widgets:{}};const explanationWidgetLogic={name:"explanation",defaultWidgetOptions: defaultWidgetOptions$s,defaultAlignment:"inline",accessible:true};
|
|
208
208
|
|
|
209
209
|
function getExpressionPublicWidgetOptions(options){return {buttonSets:options.buttonSets,functions:options.functions,times:options.times,visibleLabel:options.visibleLabel,ariaLabel:options.ariaLabel,buttonsVisible:options.buttonsVisible,extraKeys:options.extraKeys}}
|
|
210
210
|
|
|
211
|
-
const expressionWidgetLogic={name:"expression",version:currentVersion$
|
|
211
|
+
const currentVersion$3={major:2,minor:0};const defaultWidgetOptions$r={answerForms:[],times:false,buttonSets:["basic"],functions:["f","g","h"]};const expressionWidgetLogic={name:"expression",version:currentVersion$3,defaultWidgetOptions:defaultWidgetOptions$r,defaultAlignment:"inline-block",getPublicWidgetOptions:getExpressionPublicWidgetOptions,accessible:true};
|
|
212
212
|
|
|
213
|
-
const defaultWidgetOptions$
|
|
213
|
+
const defaultWidgetOptions$q={title:"",content:"",widgets:{},images:{},hint:null};const traverseChildWidgets$3=function(props,traverseRenderer){return {...props,...traverseRenderer(props)}};const gradedGroupWidgetLogic={name:"graded-group",defaultWidgetOptions: defaultWidgetOptions$q,accessible:false,traverseChildWidgets:traverseChildWidgets$3};
|
|
214
214
|
|
|
215
215
|
function getFreeResponsePublicWidgetOptions(options){return {allowUnlimitedCharacters:options.allowUnlimitedCharacters,characterLimit:options.characterLimit,placeholder:options.placeholder,question:options.question}}
|
|
216
216
|
|
|
217
|
-
const defaultWidgetOptions$
|
|
217
|
+
const defaultWidgetOptions$p={allowUnlimitedCharacters:false,characterLimit:500,placeholder:"Please provide response here",question:"",scoringCriteria:[{text:""}]};const freeResponseWidgetLogic={name:"free-response",defaultWidgetOptions: defaultWidgetOptions$p,getPublicWidgetOptions:getFreeResponsePublicWidgetOptions};
|
|
218
218
|
|
|
219
|
-
const defaultWidgetOptions$
|
|
219
|
+
const defaultWidgetOptions$o={gradedGroups:[]};const traverseChildWidgets$2=function(props,traverseRenderer){return {...props,...traverseRenderer(props)}};const gradedGroupSetWidgetLogic={name:"graded-group-set",defaultWidgetOptions: defaultWidgetOptions$o,accessible:false,traverseChildWidgets:traverseChildWidgets$2};
|
|
220
220
|
|
|
221
221
|
function getGrapherPublicWidgetOptions(options){const{correct:_,...publicOptions}=options;return publicOptions}
|
|
222
222
|
|
|
223
|
-
const defaultWidgetOptions$
|
|
223
|
+
const defaultWidgetOptions$n={graph:{labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],backgroundImage:{url:null},markings:"graph",rulerLabel:"",rulerTicks:10,valid:true,showTooltips:false},correct:{type:"linear",coords:null},availableTypes:["linear"]};const grapherWidgetLogic={name:"grapher",defaultWidgetOptions: defaultWidgetOptions$n,getPublicWidgetOptions:getGrapherPublicWidgetOptions,accessible:false};
|
|
224
224
|
|
|
225
225
|
class Registry{throwIfUnregistered(){if(!this.anythingRegistered){throw new Error(`${this.name} accessed before initialization!`)}}has(key){this.throwIfUnregistered();return Object.prototype.hasOwnProperty.call(this.contents,key)}get(key){this.throwIfUnregistered();return this.contents[key]}keys(){this.throwIfUnregistered();return Object.keys(this.contents)}entries(){this.throwIfUnregistered();return Object.entries(this.contents)}set(key,value){this.anythingRegistered=true;this.contents[key]=value;}constructor(name="Registry"){this.contents={};this.anythingRegistered=false;this.name=name;}}
|
|
226
226
|
|
|
227
227
|
function getIFramePublicWidgetOptions(options){return options}
|
|
228
228
|
|
|
229
|
-
const defaultWidgetOptions$
|
|
229
|
+
const defaultWidgetOptions$m={url:"",settings:[{name:"",value:""}],width:"400",height:"400",allowFullScreen:false,allowTopNavigation:false};const iframeWidgetLogic={name:"iframe",defaultWidgetOptions: defaultWidgetOptions$m,getPublicWidgetOptions:getIFramePublicWidgetOptions,accessible:false};
|
|
230
230
|
|
|
231
|
-
const defaultWidgetOptions$
|
|
231
|
+
const defaultWidgetOptions$l={title:"",range:[[0,10],[0,10]],box:[400,400],backgroundImage:{url:null,width:0,height:0},labels:[],alt:"",caption:""};const imageWidgetLogic={name:"image",defaultWidgetOptions: defaultWidgetOptions$l,supportedAlignments:["block","full-width"],defaultAlignment:"block",accessible:widgetOptions=>{const imageOptions=widgetOptions;const bgImage=imageOptions.backgroundImage;return !(bgImage.url!=null&&!imageOptions.alt)}};
|
|
232
232
|
|
|
233
233
|
function getInputNumberPublicWidgetOptions(options){const{value:_,...publicWidgetOptions}=options;return publicWidgetOptions}
|
|
234
234
|
|
|
235
|
-
const defaultWidgetOptions$
|
|
235
|
+
const defaultWidgetOptions$k={value:0,simplify:"required",size:"normal",inexact:false,maxError:.1,answerType:"number",rightAlign:false};const inputNumberWidgetLogic={name:"input-number",defaultWidgetOptions: defaultWidgetOptions$k,defaultAlignment:"inline-block",accessible:false,getPublicWidgetOptions:getInputNumberPublicWidgetOptions};
|
|
236
236
|
|
|
237
|
-
const defaultWidgetOptions$
|
|
237
|
+
const defaultWidgetOptions$j={graph:{box:[400,400],labels:["x","y"],range:[[-10,10],[-10,10]],tickStep:[1,1],gridStep:[1,1],markings:"graph"},elements:[]};const interactionWidgetLogic={name:"interaction",defaultWidgetOptions: defaultWidgetOptions$j,accessible:false};
|
|
238
|
+
|
|
239
|
+
const svgLabelsRegex=/^web\+graphie:/;const svgLocalLabelsRegex=/^file\+graphie:/;function getRealImageUrl(graphieUrl){if(isLabeledSVG(graphieUrl)){return getSvgUrl(graphieUrl)}return graphieUrl}function isLabeledSVG(graphieUrl){return svgLabelsRegex.test(graphieUrl)||svgLocalLabelsRegex.test(graphieUrl)}function getBaseUrl(graphieUrl){return graphieUrl.replace(svgLabelsRegex,"https:").replace(svgLocalLabelsRegex,"file:")}function getSvgUrl(graphieUrl){return getBaseUrl(graphieUrl)+".svg"}function getDataUrl(graphieUrl){return getBaseUrl(graphieUrl)+"-data.json"}async function getImageSizeModern(url){const image=new Image;return new Promise((resolve,reject)=>{image.onload=()=>{resolve([image.naturalWidth,image.naturalHeight]);};image.onerror=reject;image.src=getRealImageUrl(url);})}
|
|
238
240
|
|
|
239
241
|
function getInteractiveGraphPublicWidgetOptions(options){const{correct:_,...publicOptions}=options;return publicOptions}
|
|
240
242
|
|
|
241
|
-
const defaultWidgetOptions$
|
|
243
|
+
const defaultWidgetOptions$i={labels:["x","y"],labelLocation:"onAxis",range:[[-10,10],[-10,10]],step:[1,1],backgroundImage:{url:null},markings:"graph",showTooltips:false,showProtractor:false,graph:{type:"linear"},correct:{type:"linear",coords:null}};const interactiveGraphWidgetLogic={name:"interactive-graph",defaultWidgetOptions: defaultWidgetOptions$i,getPublicWidgetOptions:getInteractiveGraphPublicWidgetOptions,accessible:widgetOptions=>{const interactiveGraphOptions=widgetOptions;if(interactiveGraphOptions.showProtractor){return false}if(interactiveGraphOptions.backgroundImage?.url&&isLabeledSVG(interactiveGraphOptions.backgroundImage?.url)){return false}return true}};
|
|
242
244
|
|
|
243
245
|
function getLabelImagePublicWidgetOptions(options){return {...options,markers:options.markers.map(getLabelImageMarkerPublicData)}}function getLabelImageMarkerPublicData(marker){const{answers:_,...publicData}=marker;return publicData}
|
|
244
246
|
|
|
245
|
-
const defaultWidgetOptions$
|
|
247
|
+
const defaultWidgetOptions$h={choices:[],imageAlt:"",imageUrl:"",imageWidth:0,imageHeight:0,markers:[],multipleAnswers:false,hideChoicesFromInstructions:false};const labelImageWidgetLogic={name:"label-image",defaultWidgetOptions: defaultWidgetOptions$h,getPublicWidgetOptions:getLabelImagePublicWidgetOptions,accessible:widgetOptions=>{const labelImageOptions=widgetOptions;if(labelImageOptions.imageUrl!==""&&labelImageOptions.imageAlt===""){return false}return true}};
|
|
246
248
|
|
|
247
249
|
const seededRNG=function(seed){let randomSeed=seed;return function(){let seed=randomSeed;seed=seed+0x7ed55d16+(seed<<12)&0xffffffff;seed=(seed^0xc761c23c^seed>>>19)&0xffffffff;seed=seed+0x165667b1+(seed<<5)&0xffffffff;seed=(seed+0xd3a2646c^seed<<9)&0xffffffff;seed=seed+0xfd7046c5+(seed<<3)&0xffffffff;seed=(seed^0xb55a4f09^seed>>>16)&0xffffffff;return (randomSeed=seed&0xfffffff)/0x10000000}};function shuffle(array,randomSeed,ensurePermuted=false){let random;if(typeof randomSeed==="function"){random=randomSeed;}else {random=seededRNG(randomSeed);}function isValidShuffle(shuffled){return ensurePermuted?!_.isEqual(array,shuffled):true}return constrainedShuffle(array,random,isValidShuffle)}function constrainedShuffle(array,random,isValidShuffle){const maxIterations=100;const shuffled=[...array];if(shuffled.every(value=>_.isEqual(value,shuffled[0]))){return shuffled}for(let i=0;i<maxIterations;i++){shuffleInPlace(shuffled,random);if(isValidShuffle(shuffled)){return shuffled}}throw new Error(`constrainedShuffle: constraint not met after ${maxIterations} attempts`)}function shuffleInPlace(a,random){for(let i=a.length-1;i>0;i--){const k=randomIntInRange(0,i,random);[a[k],a[i]]=[a[i],a[k]];}}function randomIntInRange(min,max,random){return Math.floor(random()*(max-min+1))+min}const random=seededRNG(new Date().getTime()&0xffffffff);
|
|
248
250
|
|
|
249
251
|
const shuffleMatcher=props=>{const rng=seededRNG(props.problemNum);return {left:!props.orderMatters?props.left:shuffleDisplacingFirst$1(props.left,rng),right:shuffleDisplacingFirst$1(props.right,rng)}};function getMatcherPublicWidgetOptions(options){return {...options,left:options.orderMatters?sortAllButFirst$1(options.left):options.left,right:sortAllButFirst$1(options.right)}}function sortAllButFirst$1([first,...rest]){return [first,...rest.sort()]}function shuffleDisplacingFirst$1(array,rng){function isFirstElementDisplaced(shuffled){return shuffled[0]!==array[0]}return constrainedShuffle(array,rng,isFirstElementDisplaced)}
|
|
250
252
|
|
|
251
|
-
const defaultWidgetOptions$
|
|
253
|
+
const defaultWidgetOptions$g={left:["$x$","$y$","$z$"],right:["$1$","$2$","$3$"],labels:["test","label"],orderMatters:false,padding:true};const matcherWidgetLogic={name:"matcher",defaultWidgetOptions: defaultWidgetOptions$g,getPublicWidgetOptions:getMatcherPublicWidgetOptions,accessible:false};
|
|
252
254
|
|
|
253
255
|
function getMatrixPublicWidgetOptions(options){const{answers:_,...publicOptions}=options;return publicOptions}
|
|
254
256
|
|
|
255
|
-
const defaultWidgetOptions$
|
|
256
|
-
|
|
257
|
-
const currentVersion$1={major:1,minor:0};const widgetOptionsUpgrades={"1":v0options=>{const{imageUrl,imageTop,imageLeft,...rest}=v0options;return {...rest,image:{url:imageUrl,top:imageTop,left:imageLeft}}}};const defaultWidgetOptions$d={box:[480,480],image:{},showProtractor:true,showRuler:false,rulerLabel:"",rulerTicks:10,rulerPixels:40,rulerLength:10};
|
|
257
|
+
const defaultWidgetOptions$f={matrixBoardSize:[3,3],answers:[[]],prefix:"",suffix:"",cursorPosition:[0,0]};const matrixWidgetLogic={name:"matrix",defaultWidgetOptions: defaultWidgetOptions$f,getPublicWidgetOptions:getMatrixPublicWidgetOptions,accessible:false};
|
|
258
258
|
|
|
259
|
-
const measurerWidgetLogic={name:"measurer",version:currentVersion$
|
|
259
|
+
const currentVersion$2={major:1,minor:0};const defaultWidgetOptions$e={box:[480,480],image:{},showProtractor:true,showRuler:false,rulerLabel:"",rulerTicks:10,rulerPixels:40,rulerLength:10};const measurerWidgetLogic={name:"measurer",version:currentVersion$2,defaultWidgetOptions:defaultWidgetOptions$e,accessible:false};
|
|
260
260
|
|
|
261
261
|
function getNumberLinePublicWidgetOptions(options){const{correctX:_,correctRel:__,...publicOptions}=options;return publicOptions}
|
|
262
262
|
|
|
263
|
-
const defaultWidgetOptions$
|
|
263
|
+
const defaultWidgetOptions$d={range:[0,10],labelRange:[null,null],labelStyle:"decimal",labelTicks:true,divisionRange:[1,12],numDivisions:5,snapDivisions:2,tickStep:null,correctRel:"eq",correctX:null,initialX:null,showTooltips:false};const numberLineWidgetLogic={name:"number-line",defaultWidgetOptions: defaultWidgetOptions$d,getPublicWidgetOptions:getNumberLinePublicWidgetOptions,accessible:false};
|
|
264
264
|
|
|
265
265
|
function getNumericInputAnswerPublicData(answer){const{answerForms,simplify,status}=answer;return {answerForms,simplify,status}}function getNumericInputPublicWidgetOptions(options){const{answers,...publicWidgetOptions}=options;return {...publicWidgetOptions,answers:answers.map(getNumericInputAnswerPublicData)}}
|
|
266
266
|
|
|
267
|
-
const defaultWidgetOptions$
|
|
267
|
+
const defaultWidgetOptions$c={answers:[{value:null,status:"correct",message:"",simplify:"required",answerForms:[],strict:false,maxError:null}],size:"normal",coefficient:false,labelText:"",rightAlign:false};const numericInputWidgetLogic={name:"numeric-input",defaultWidgetOptions: defaultWidgetOptions$c,defaultAlignment:"inline-block",getPublicWidgetOptions:getNumericInputPublicWidgetOptions,accessible:true};
|
|
268
268
|
|
|
269
269
|
function getOrdererPublicWidgetOptions(fullOptions){const{options,height,layout}=fullOptions;return {options,height,layout}}
|
|
270
270
|
|
|
271
|
-
const defaultWidgetOptions$
|
|
271
|
+
const defaultWidgetOptions$b={correctOptions:[{content:"$x$"}],otherOptions:[{content:"$y$"}],height:"normal",layout:"horizontal"};const ordererWidgetLogic={name:"orderer",defaultWidgetOptions: defaultWidgetOptions$b,getPublicWidgetOptions:getOrdererPublicWidgetOptions,accessible:false};
|
|
272
272
|
|
|
273
|
-
const defaultWidgetOptions$
|
|
273
|
+
const defaultWidgetOptions$a={passageTitle:"",passageText:"",footnotes:"",showLineNumbers:true};const passageWidgetLogic={name:"passage",defaultWidgetOptions: defaultWidgetOptions$a,accessible:false};
|
|
274
274
|
|
|
275
|
-
const currentVersion={major:0,minor:1};const defaultWidgetOptions$
|
|
275
|
+
const currentVersion$1={major:0,minor:1};const defaultWidgetOptions$9={passageNumber:1,referenceNumber:1,summaryText:""};
|
|
276
276
|
|
|
277
|
-
const passageRefWidgetLogic={name:"passage-ref",version:currentVersion,defaultWidgetOptions:defaultWidgetOptions$
|
|
277
|
+
const passageRefWidgetLogic={name:"passage-ref",version:currentVersion$1,defaultWidgetOptions:defaultWidgetOptions$9,defaultAlignment:"inline",accessible:false};
|
|
278
278
|
|
|
279
|
-
const defaultWidgetOptions$
|
|
279
|
+
const defaultWidgetOptions$8={content:""};const passageRefTargetWidgetLogic={name:"passage-ref-target",defaultWidgetOptions: defaultWidgetOptions$8,defaultAlignment:"inline",accessible:false};
|
|
280
280
|
|
|
281
|
-
const defaultWidgetOptions$
|
|
281
|
+
const defaultWidgetOptions$7={url:"",description:""};const phetSimulationWidgetLogic={name:"phet-simulation",defaultWidgetOptions: defaultWidgetOptions$7,accessible:true};
|
|
282
282
|
|
|
283
283
|
function getPlotterPublicWidgetOptions(options){const{correct:_,...publicOptions}=options;return publicOptions}
|
|
284
284
|
|
|
285
|
-
const defaultWidgetOptions$
|
|
285
|
+
const defaultWidgetOptions$6={scaleY:1,maxY:10,snapsPerLine:2,correct:[1],starting:[1],type:"bar",labels:["",""],categories:[""],picSize:30,picBoxHeight:36,plotDimensions:[275,200],labelInterval:1,picUrl:null};const plotterWidgetLogic={name:"plotter",defaultWidgetOptions: defaultWidgetOptions$6,getPublicWidgetOptions:getPlotterPublicWidgetOptions,accessible:false};
|
|
286
286
|
|
|
287
|
-
const defaultWidgetOptions$
|
|
287
|
+
const defaultWidgetOptions$5={programID:"",height:400};const pythonProgramWidgetLogic={name:"python-program",defaultWidgetOptions: defaultWidgetOptions$5,accessible:false};
|
|
288
288
|
|
|
289
289
|
function getRadioChoicePublicData(choice){const{content,isNoneOfTheAbove,widgets}=choice;return {content,isNoneOfTheAbove,widgets}}function usesNumCorrect(multipleSelect,countChoices,numCorrect){return multipleSelect&&countChoices&&numCorrect}function getRadioPublicWidgetOptions(options){const{numCorrect,choices,multipleSelect,countChoices}=options;return {...options,numCorrect:usesNumCorrect(multipleSelect,countChoices,numCorrect)?numCorrect:undefined,choices:choices.map(getRadioChoicePublicData)}}
|
|
290
290
|
|
|
291
|
-
const radioWidgetLogic={name:"radio",version:currentVersion
|
|
291
|
+
const currentVersion={major:2,minor:0};const defaultWidgetOptions$4={choices:[{},{},{},{}],displayCount:null,randomize:false,hasNoneOfTheAbove:false,multipleSelect:false,countChoices:false,deselectEnabled:false};const radioWidgetLogic={name:"radio",version:currentVersion,defaultWidgetOptions:defaultWidgetOptions$4,getPublicWidgetOptions:getRadioPublicWidgetOptions,accessible:true};
|
|
292
292
|
|
|
293
293
|
function getSorterPublicWidgetOptions(options){return {...options,correct:sortAllButFirst(options.correct)}}function shuffleSorter(props){const{correct,problemNum}=props;const rng=seededRNG(problemNum??0);return shuffleDisplacingFirst(correct,rng)}function sortAllButFirst([first,...rest]){return [first,...rest.sort()]}function shuffleDisplacingFirst(array,rng){function isFirstElementDisplaced(shuffled){return shuffled[0]!==array[0]}return constrainedShuffle(array,rng,isFirstElementDisplaced)}
|
|
294
294
|
|
|
295
|
-
const defaultWidgetOptions$3={correct:["$x$","$y$","$z$"],layout:"horizontal",padding:true};const sorterWidgetLogic={name:"sorter",defaultWidgetOptions: defaultWidgetOptions$3,getPublicWidgetOptions:getSorterPublicWidgetOptions};
|
|
295
|
+
const defaultWidgetOptions$3={correct:["$x$","$y$","$z$"],layout:"horizontal",padding:true};const sorterWidgetLogic={name:"sorter",defaultWidgetOptions: defaultWidgetOptions$3,getPublicWidgetOptions:getSorterPublicWidgetOptions,accessible:false};
|
|
296
296
|
|
|
297
297
|
function getTablePublicWidgetOptions(options){const{answers:_,...publicOptions}=options;return publicOptions}
|
|
298
298
|
|
|
299
|
-
const defaultRows=4;const defaultColumns=1;const answers=new Array(defaultRows).fill(0).map(()=>new Array(defaultColumns).fill(""));const defaultWidgetOptions$2={headers:[""],rows:defaultRows,columns:defaultColumns,answers:answers};const tableWidgetLogic={name:"table",defaultWidgetOptions: defaultWidgetOptions$2,getPublicWidgetOptions:getTablePublicWidgetOptions};
|
|
299
|
+
const defaultRows=4;const defaultColumns=1;const answers=new Array(defaultRows).fill(0).map(()=>new Array(defaultColumns).fill(""));const defaultWidgetOptions$2={headers:[""],rows:defaultRows,columns:defaultColumns,answers:answers};const tableWidgetLogic={name:"table",defaultWidgetOptions: defaultWidgetOptions$2,getPublicWidgetOptions:getTablePublicWidgetOptions,accessible:true};
|
|
300
300
|
|
|
301
|
-
const defaultWidgetOptions$1={location:""};const videoWidgetLogic={name:"video",defaultWidgetOptions: defaultWidgetOptions$1,supportedAlignments:["block","float-left","float-right","full-width"],defaultAlignment:"block"};
|
|
301
|
+
const defaultWidgetOptions$1={location:""};const videoWidgetLogic={name:"video",defaultWidgetOptions: defaultWidgetOptions$1,supportedAlignments:["block","float-left","float-right","full-width"],defaultAlignment:"block",accessible:false};
|
|
302
302
|
|
|
303
|
-
const widgets=new Registry("Core widget registry");function registerWidget(type,logic){widgets.set(type,logic);}function isWidgetRegistered(type){const widgetLogic=widgets.get(type);return
|
|
303
|
+
const widgets=new Registry("Core widget registry");function registerWidget(type,logic){widgets.set(type,logic);}function isWidgetRegistered(type){const widgetLogic=widgets.get(type);return Boolean(widgetLogic)}function getCurrentVersion(type){const widgetLogic=widgets.get(type);return widgetLogic?.version||{major:0,minor:0}}const getPublicWidgetOptionsFunction=type=>{return widgets.get(type)?.getPublicWidgetOptions??(i=>i)};function getDefaultWidgetOptions(type){const widgetLogic=widgets.get(type);return widgetLogic?.defaultWidgetOptions||{}}function isAccessible(type,widgetOptions){const accessible=widgets.get(type)?.accessible;return typeof accessible==="function"?accessible(widgetOptions):!!accessible}const traverseChildWidgets$1=(widgetInfo,traverseRenderer)=>{if(!traverseRenderer){throw new PerseusError("traverseRenderer must be provided, but was not",Errors.Internal)}if(!widgetInfo||!widgetInfo.type||!widgets.get(widgetInfo.type)){return widgetInfo}const widgetExports=widgets.get(widgetInfo.type);const props=widgetInfo.options;if(widgetExports?.traverseChildWidgets!=null&&props!=null){const newProps=widgetExports.traverseChildWidgets(props,traverseRenderer);return {...widgetInfo,options:newProps}}return widgetInfo};const getSupportedAlignments=type=>{const widgetLogic=widgets.get(type);if(!widgetLogic?.supportedAlignments?.[0]){return ["default"]}return widgetLogic?.supportedAlignments};const getDefaultAlignment=type=>{const widgetLogic=widgets.get(type);if(!widgetLogic?.defaultAlignment){return "block"}return widgetLogic.defaultAlignment};function registerCoreWidgets(){const widgets=[categorizerWidgetLogic,csProgramWidgetLogic,definitionWidgetLogic,dropdownWidgetLogic,explanationWidgetLogic,expressionWidgetLogic,gradedGroupWidgetLogic,gradedGroupSetWidgetLogic,grapherWidgetLogic,groupWidgetLogic,iframeWidgetLogic,imageWidgetLogic,inputNumberWidgetLogic,interactionWidgetLogic,interactiveGraphWidgetLogic,labelImageWidgetLogic,matcherWidgetLogic,matrixWidgetLogic,measurerWidgetLogic,numberLineWidgetLogic,numericInputWidgetLogic,ordererWidgetLogic,passageWidgetLogic,passageRefWidgetLogic,passageRefTargetWidgetLogic,phetSimulationWidgetLogic,plotterWidgetLogic,pythonProgramWidgetLogic,radioWidgetLogic,sorterWidgetLogic,tableWidgetLogic,videoWidgetLogic];widgets.forEach(w=>{registerWidget(w.name,w);});}
|
|
304
304
|
|
|
305
305
|
var coreWidgetRegistry = /*#__PURE__*/Object.freeze({
|
|
306
306
|
__proto__: null,
|
|
@@ -309,22 +309,30 @@ var coreWidgetRegistry = /*#__PURE__*/Object.freeze({
|
|
|
309
309
|
getDefaultWidgetOptions: getDefaultWidgetOptions,
|
|
310
310
|
getPublicWidgetOptionsFunction: getPublicWidgetOptionsFunction,
|
|
311
311
|
getSupportedAlignments: getSupportedAlignments,
|
|
312
|
-
|
|
312
|
+
isAccessible: isAccessible,
|
|
313
313
|
isWidgetRegistered: isWidgetRegistered,
|
|
314
|
-
registerCoreWidgets: registerCoreWidgets
|
|
314
|
+
registerCoreWidgets: registerCoreWidgets,
|
|
315
|
+
registerWidget: registerWidget,
|
|
316
|
+
traverseChildWidgets: traverseChildWidgets$1
|
|
315
317
|
});
|
|
316
318
|
|
|
317
|
-
const DEFAULT_STATIC=false;const
|
|
319
|
+
const DEFAULT_STATIC=false;const applyDefaultsToWidget=oldWidgetInfo=>{const type=oldWidgetInfo.type;if(!_.isString(type)){throw new PerseusError("widget type must be a string, but was: "+type,Errors.Internal)}if(!isWidgetRegistered(type)){return oldWidgetInfo}const initialVersion=oldWidgetInfo.version||{major:0,minor:0};const latestVersion=getCurrentVersion(type);if(initialVersion.major>latestVersion.major||initialVersion.major===latestVersion.major&&initialVersion.minor>latestVersion.minor){return oldWidgetInfo}let newEditorOptions=_.clone(oldWidgetInfo.options)??{};const defaultOptions=getDefaultWidgetOptions(type);newEditorOptions={...defaultOptions,...newEditorOptions};let alignment=oldWidgetInfo.alignment;if(alignment==null||alignment==="default"){alignment=getSupportedAlignments(type)?.[0];if(!alignment){throw new PerseusError("No default alignment found when upgrading widget",Errors.Internal,{metadata:{widgetType:type}})}}let widgetStatic=oldWidgetInfo.static;if(widgetStatic==null){widgetStatic=DEFAULT_STATIC;}return {...oldWidgetInfo,version:latestVersion,graded:oldWidgetInfo.graded!=null?oldWidgetInfo.graded:true,alignment:alignment,static:widgetStatic,options:newEditorOptions}};function applyDefaultsToWidgets(oldWidgetOptions){return mapObject(oldWidgetOptions,(widgetInfo,widgetId)=>{if(!widgetInfo.type||!widgetInfo.alignment){const newValues={};if(!widgetInfo.type){newValues.type=widgetId.split(" ")[0];}if(!widgetInfo.alignment){newValues.alignment="default";}widgetInfo={...widgetInfo,...newValues};}return applyDefaultsToWidget(widgetInfo)})}
|
|
318
320
|
|
|
319
|
-
function splitPerseusRenderer(original){const clone=deepClone(original);const originalWidgets=clone.widgets??{};const upgradedWidgets=
|
|
321
|
+
function splitPerseusRenderer(original){const clone=deepClone(original);const originalWidgets=clone.widgets??{};const upgradedWidgets=applyDefaultsToWidgets(originalWidgets);const splitWidgets={};for(const[id,widget]of Object.entries(upgradedWidgets)){const publicWidgetOptionsFun=getPublicWidgetOptionsFunction(widget.type);splitWidgets[id]={...widget,options:publicWidgetOptionsFun(widget.options)};}return {...original,widgets:splitWidgets}}
|
|
320
322
|
|
|
321
323
|
function getGroupPublicWidgetOptions(options){return splitPerseusRenderer(options)}
|
|
322
324
|
|
|
323
|
-
const defaultWidgetOptions={content:"",widgets:{},images:{}};const groupWidgetLogic={name:"group",defaultWidgetOptions,getPublicWidgetOptions:getGroupPublicWidgetOptions};
|
|
325
|
+
const defaultWidgetOptions={content:"",widgets:{},images:{}};const traverseChildWidgets=function(props,traverseRenderer){return {...props,...traverseRenderer(props)}};const groupWidgetLogic={name:"group",defaultWidgetOptions,accessible:false,traverseChildWidgets:traverseChildWidgets,getPublicWidgetOptions:getGroupPublicWidgetOptions};
|
|
326
|
+
|
|
327
|
+
function getDefaultAnswerArea(){return ItemExtras.reduce((acc,curr)=>({...acc,[curr]:false}),{})}
|
|
324
328
|
|
|
325
329
|
function splitPerseusItem(original){const item=deepClone(original);return {...item,question:splitPerseusRenderer(item.question),hints:[]}}function splitPerseusItemJSON(data){const parseResult=parseAndMigratePerseusItem(data);if(isFailure(parseResult)){throw new SyntaxError(parseResult.detail.message)}const item=parseResult.value;return JSON.stringify(splitPerseusItem(item))}
|
|
326
330
|
|
|
327
331
|
const PerseusFeatureFlags=["new-radio-widget"];
|
|
328
332
|
|
|
329
|
-
|
|
333
|
+
const noop=function(){};const deepCallbackFor=function(contentCallback,widgetCallback,optionsCallback){const deepCallback=function(widgetInfo,widgetId){const newWidgetInfo=traverseChildWidgets$1(widgetInfo,rendererOptions=>{return traverseRenderer(rendererOptions,contentCallback,deepCallback,optionsCallback)});const userWidgetInfo=widgetCallback(newWidgetInfo,widgetId);if(userWidgetInfo!==undefined){return userWidgetInfo}return newWidgetInfo};return deepCallback};const traverseRenderer=function(rendererOptions,contentCallback,deepWidgetCallback,optionsCallback){let newContent=rendererOptions.content;if(rendererOptions.content!=null){const modifiedContent=contentCallback(rendererOptions.content);if(modifiedContent!==undefined){newContent=modifiedContent;}}const newWidgets=mapObject(rendererOptions.widgets||{},function(widgetInfo,widgetId){if(widgetInfo==null||widgetInfo.type==null){return widgetInfo}return deepWidgetCallback(widgetInfo,widgetId)});const newOptions=_.extend({},rendererOptions,{content:newContent,widgets:newWidgets});const userOptions=optionsCallback(newOptions);if(userOptions!==undefined){return userOptions}return newOptions};const traverse=function(rendererOptions,contentCallback,widgetCallback,optionsCallback){contentCallback=contentCallback||noop;widgetCallback=widgetCallback||noop;optionsCallback=optionsCallback||noop;return traverseRenderer(rendererOptions,contentCallback,deepCallbackFor(contentCallback,widgetCallback,optionsCallback),optionsCallback)};
|
|
334
|
+
|
|
335
|
+
function violatingWidgets(itemData){const widgetTypes=[];traverse(itemData.question,null,function(info){if(info.type&&!isAccessible(info.type,info.options)){widgetTypes.push(info.type);}});return [...new Set(widgetTypes)]}function isItemAccessible(itemData){return violatingWidgets(itemData).length===0}
|
|
336
|
+
|
|
337
|
+
export { coreWidgetRegistry as CoreWidgetRegistry, Errors, grapherUtil as GrapherUtil, ItemExtras, PerseusError, PerseusExpressionAnswerFormConsidered, PerseusFeatureFlags, Registry, addWidget, applyDefaultsToWidget, applyDefaultsToWidgets, approximateDeepEqual, approximateEqual, categorizerWidgetLogic as categorizerLogic, csProgramWidgetLogic as csProgramLogic, deepClone, definitionWidgetLogic as definitionLogic, deriveExtraKeys, deriveNumCorrect, dropdownWidgetLogic as dropdownLogic, explanationWidgetLogic as explanationLogic, expressionWidgetLogic as expressionLogic, freeResponseWidgetLogic as freeResponseLogic, generateTestPerseusItem, generateTestPerseusRenderer, getBaseUrl, getCSProgramPublicWidgetOptions, getCategorizerPublicWidgetOptions, getDataUrl, getDecimalSeparator, getDefaultAnswerArea, getDropdownPublicWidgetOptions, getExpressionPublicWidgetOptions, getFreeResponsePublicWidgetOptions, getGrapherPublicWidgetOptions, getGroupPublicWidgetOptions, getIFramePublicWidgetOptions, getImageSizeModern, getInteractiveGraphPublicWidgetOptions, getLabelImagePublicWidgetOptions, getMatcherPublicWidgetOptions, getMatrixPublicWidgetOptions, getMatrixSize, getNumberLinePublicWidgetOptions, getNumericInputPublicWidgetOptions, getOrdererPublicWidgetOptions, getPlotterPublicWidgetOptions, getRadioPublicWidgetOptions, getRealImageUrl, getSorterPublicWidgetOptions, getSvgUrl, getTablePublicWidgetOptions, getWidgetIdsFromContent, getWidgetIdsFromContentByType, gradedGroupWidgetLogic as gradedGroupLogic, gradedGroupSetWidgetLogic as gradedGroupSetLogic, grapherWidgetLogic as grapherLogic, groupWidgetLogic as groupLogic, iframeWidgetLogic as iframeLogic, imageWidgetLogic as imageLogic, inputNumberWidgetLogic as inputNumberLogic, interactionWidgetLogic as interactionLogic, interactiveGraphWidgetLogic as interactiveGraphLogic, isFailure, isItemAccessible, isLabeledSVG, isSuccess, itemHasHints, itemHasRationales, labelImageWidgetLogic as labelImageLogic, libVersion, lockedFigureColorNames, lockedFigureColors, lockedFigureFillStyles, mapObject, matcherWidgetLogic as matcherLogic, matrixWidgetLogic as matrixLogic, measurerWidgetLogic as measurerLogic, numberLineWidgetLogic as numberLineLogic, numericInputWidgetLogic as numericInputLogic, ordererWidgetLogic as ordererLogic, parseAndMigratePerseusArticle, parseAndMigratePerseusItem, parsePerseusItem, passageWidgetLogic as passageLogic, passageRefWidgetLogic as passageRefLogic, passageRefTargetWidgetLogic as passageRefTargetLogic, phetSimulationWidgetLogic as phetSimulationLogic, plotterWidgetLogic as plotterLogic, plotterPlotTypes, pluck, pythonProgramWidgetLogic as pythonProgramLogic, radioWidgetLogic as radioLogic, random, registerCoreWidgets, seededRNG, shuffle, shuffleMatcher, shuffleSorter, sorterWidgetLogic as sorterLogic, splitPerseusItem, splitPerseusItemJSON, tableWidgetLogic as tableLogic, traverse, usesNumCorrect, videoWidgetLogic as videoLogic, violatingWidgets };
|
|
330
338
|
//# sourceMappingURL=index.js.map
|