@khanacademy/perseus-core 13.0.0 → 14.0.1
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 +48 -37
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +56 -36
- package/dist/index.js.map +1 -1
- package/dist/parse-perseus-json/perseus-parsers/expression-widget.d.ts +1 -1
- 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/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/util.graphie.d.ts +6 -0
- package/dist/validation.types.d.ts +1 -0
- package/dist/widgets/core-widget-registry.d.ts +5 -1
- package/dist/widgets/logic-export.types.d.ts +3 -1
- package/package.json +3 -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
|
@@ -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.1";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,113 +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$w={items:[],categories:[],values:[],randomizeItems:false};const categorizerWidgetLogic={name:"categorizer",defaultWidgetOptions: defaultWidgetOptions$w,getPublicWidgetOptions:getCategorizerPublicWidgetOptions};
|
|
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$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};
|
|
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$u={togglePrompt:"",definition:""};const definitionWidgetLogic={name:"definition",defaultWidgetOptions: defaultWidgetOptions$u,defaultAlignment:"inline"};
|
|
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$t={placeholder:"",choices:[{content:"",correct:false}]};const dropdownWidgetLogic={name:"dropdown",defaultWidgetOptions: defaultWidgetOptions$t,defaultAlignment:"inline-block",getPublicWidgetOptions:getDropdownPublicWidgetOptions};
|
|
205
|
+
const defaultWidgetOptions$t={placeholder:"",choices:[{content:"",correct:false}]};const dropdownWidgetLogic={name:"dropdown",defaultWidgetOptions: defaultWidgetOptions$t,defaultAlignment:"inline-block",getPublicWidgetOptions:getDropdownPublicWidgetOptions,accessible:true};
|
|
204
206
|
|
|
205
|
-
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"};
|
|
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};
|
|
206
208
|
|
|
207
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}}
|
|
208
210
|
|
|
209
|
-
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};
|
|
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};
|
|
210
212
|
|
|
211
|
-
const defaultWidgetOptions$q={title:"",content:"",widgets:{},images:{},hint:null};const gradedGroupWidgetLogic={name:"graded-group",defaultWidgetOptions: defaultWidgetOptions$q};
|
|
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};
|
|
212
214
|
|
|
213
215
|
function getFreeResponsePublicWidgetOptions(options){return {allowUnlimitedCharacters:options.allowUnlimitedCharacters,characterLimit:options.characterLimit,placeholder:options.placeholder,question:options.question}}
|
|
214
216
|
|
|
215
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};
|
|
216
218
|
|
|
217
|
-
const defaultWidgetOptions$o={gradedGroups:[]};const gradedGroupSetWidgetLogic={name:"graded-group-set",defaultWidgetOptions: defaultWidgetOptions$o};
|
|
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};
|
|
218
220
|
|
|
219
221
|
function getGrapherPublicWidgetOptions(options){const{correct:_,...publicOptions}=options;return publicOptions}
|
|
220
222
|
|
|
221
|
-
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};
|
|
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};
|
|
222
224
|
|
|
223
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;}}
|
|
224
226
|
|
|
225
227
|
function getIFramePublicWidgetOptions(options){return options}
|
|
226
228
|
|
|
227
|
-
const defaultWidgetOptions$m={url:"",settings:[{name:"",value:""}],width:"400",height:"400",allowFullScreen:false,allowTopNavigation:false};const iframeWidgetLogic={name:"iframe",defaultWidgetOptions: defaultWidgetOptions$m,getPublicWidgetOptions:getIFramePublicWidgetOptions};
|
|
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};
|
|
228
230
|
|
|
229
|
-
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"};
|
|
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)}};
|
|
230
232
|
|
|
231
233
|
function getInputNumberPublicWidgetOptions(options){const{value:_,...publicWidgetOptions}=options;return publicWidgetOptions}
|
|
232
234
|
|
|
233
|
-
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",getPublicWidgetOptions:getInputNumberPublicWidgetOptions};
|
|
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
|
+
|
|
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};
|
|
234
238
|
|
|
235
|
-
const
|
|
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);})}
|
|
236
240
|
|
|
237
241
|
function getInteractiveGraphPublicWidgetOptions(options){const{correct:_,...publicOptions}=options;return publicOptions}
|
|
238
242
|
|
|
239
|
-
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};
|
|
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}};
|
|
240
244
|
|
|
241
245
|
function getLabelImagePublicWidgetOptions(options){return {...options,markers:options.markers.map(getLabelImageMarkerPublicData)}}function getLabelImageMarkerPublicData(marker){const{answers:_,...publicData}=marker;return publicData}
|
|
242
246
|
|
|
243
|
-
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};
|
|
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}};
|
|
244
248
|
|
|
245
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);
|
|
246
250
|
|
|
247
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)}
|
|
248
252
|
|
|
249
|
-
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};
|
|
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};
|
|
250
254
|
|
|
251
255
|
function getMatrixPublicWidgetOptions(options){const{answers:_,...publicOptions}=options;return publicOptions}
|
|
252
256
|
|
|
253
|
-
const defaultWidgetOptions$f={matrixBoardSize:[3,3],answers:[[]],prefix:"",suffix:"",cursorPosition:[0,0]};const matrixWidgetLogic={name:"matrix",defaultWidgetOptions: defaultWidgetOptions$f,getPublicWidgetOptions:getMatrixPublicWidgetOptions};
|
|
257
|
+
const defaultWidgetOptions$f={matrixBoardSize:[3,3],answers:[[]],prefix:"",suffix:"",cursorPosition:[0,0]};const matrixWidgetLogic={name:"matrix",defaultWidgetOptions: defaultWidgetOptions$f,getPublicWidgetOptions:getMatrixPublicWidgetOptions,accessible:false};
|
|
254
258
|
|
|
255
|
-
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};
|
|
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};
|
|
256
260
|
|
|
257
261
|
function getNumberLinePublicWidgetOptions(options){const{correctX:_,correctRel:__,...publicOptions}=options;return publicOptions}
|
|
258
262
|
|
|
259
|
-
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};
|
|
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};
|
|
260
264
|
|
|
261
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)}}
|
|
262
266
|
|
|
263
|
-
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};
|
|
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};
|
|
264
268
|
|
|
265
269
|
function getOrdererPublicWidgetOptions(fullOptions){const{options,height,layout}=fullOptions;return {options,height,layout}}
|
|
266
270
|
|
|
267
|
-
const defaultWidgetOptions$b={correctOptions:[{content:"$x$"}],otherOptions:[{content:"$y$"}],height:"normal",layout:"horizontal"};const ordererWidgetLogic={name:"orderer",defaultWidgetOptions: defaultWidgetOptions$b,getPublicWidgetOptions:getOrdererPublicWidgetOptions};
|
|
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};
|
|
268
272
|
|
|
269
|
-
const defaultWidgetOptions$a={passageTitle:"",passageText:"",footnotes:"",showLineNumbers:true};const passageWidgetLogic={name:"passage",defaultWidgetOptions: defaultWidgetOptions$a};
|
|
273
|
+
const defaultWidgetOptions$a={passageTitle:"",passageText:"",footnotes:"",showLineNumbers:true};const passageWidgetLogic={name:"passage",defaultWidgetOptions: defaultWidgetOptions$a,accessible:false};
|
|
270
274
|
|
|
271
275
|
const currentVersion$1={major:0,minor:1};const defaultWidgetOptions$9={passageNumber:1,referenceNumber:1,summaryText:""};
|
|
272
276
|
|
|
273
|
-
const passageRefWidgetLogic={name:"passage-ref",version:currentVersion$1,defaultWidgetOptions:defaultWidgetOptions$9,defaultAlignment:"inline"};
|
|
277
|
+
const passageRefWidgetLogic={name:"passage-ref",version:currentVersion$1,defaultWidgetOptions:defaultWidgetOptions$9,defaultAlignment:"inline",accessible:false};
|
|
274
278
|
|
|
275
|
-
const defaultWidgetOptions$8={content:""};const passageRefTargetWidgetLogic={name:"passage-ref-target",defaultWidgetOptions: defaultWidgetOptions$8,defaultAlignment:"inline"};
|
|
279
|
+
const defaultWidgetOptions$8={content:""};const passageRefTargetWidgetLogic={name:"passage-ref-target",defaultWidgetOptions: defaultWidgetOptions$8,defaultAlignment:"inline",accessible:false};
|
|
276
280
|
|
|
277
|
-
const defaultWidgetOptions$7={url:"",description:""};const phetSimulationWidgetLogic={name:"phet-simulation",defaultWidgetOptions: defaultWidgetOptions$7};
|
|
281
|
+
const defaultWidgetOptions$7={url:"",description:""};const phetSimulationWidgetLogic={name:"phet-simulation",defaultWidgetOptions: defaultWidgetOptions$7,accessible:true};
|
|
278
282
|
|
|
279
283
|
function getPlotterPublicWidgetOptions(options){const{correct:_,...publicOptions}=options;return publicOptions}
|
|
280
284
|
|
|
281
|
-
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};
|
|
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};
|
|
282
286
|
|
|
283
|
-
const defaultWidgetOptions$5={programID:"",height:400};const pythonProgramWidgetLogic={name:"python-program",defaultWidgetOptions: defaultWidgetOptions$5};
|
|
287
|
+
const defaultWidgetOptions$5={programID:"",height:400};const pythonProgramWidgetLogic={name:"python-program",defaultWidgetOptions: defaultWidgetOptions$5,accessible:false};
|
|
284
288
|
|
|
285
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)}}
|
|
286
290
|
|
|
287
|
-
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};
|
|
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};
|
|
288
292
|
|
|
289
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)}
|
|
290
294
|
|
|
291
|
-
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};
|
|
292
296
|
|
|
293
297
|
function getTablePublicWidgetOptions(options){const{answers:_,...publicOptions}=options;return publicOptions}
|
|
294
298
|
|
|
295
|
-
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};
|
|
296
300
|
|
|
297
|
-
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};
|
|
298
302
|
|
|
299
|
-
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);});}
|
|
300
304
|
|
|
301
305
|
var coreWidgetRegistry = /*#__PURE__*/Object.freeze({
|
|
302
306
|
__proto__: null,
|
|
@@ -305,8 +309,11 @@ var coreWidgetRegistry = /*#__PURE__*/Object.freeze({
|
|
|
305
309
|
getDefaultWidgetOptions: getDefaultWidgetOptions,
|
|
306
310
|
getPublicWidgetOptionsFunction: getPublicWidgetOptionsFunction,
|
|
307
311
|
getSupportedAlignments: getSupportedAlignments,
|
|
312
|
+
isAccessible: isAccessible,
|
|
308
313
|
isWidgetRegistered: isWidgetRegistered,
|
|
309
|
-
registerCoreWidgets: registerCoreWidgets
|
|
314
|
+
registerCoreWidgets: registerCoreWidgets,
|
|
315
|
+
registerWidget: registerWidget,
|
|
316
|
+
traverseChildWidgets: traverseChildWidgets$1
|
|
310
317
|
});
|
|
311
318
|
|
|
312
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)})}
|
|
@@ -315,7 +322,7 @@ function splitPerseusRenderer(original){const clone=deepClone(original);const or
|
|
|
315
322
|
|
|
316
323
|
function getGroupPublicWidgetOptions(options){return splitPerseusRenderer(options)}
|
|
317
324
|
|
|
318
|
-
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};
|
|
319
326
|
|
|
320
327
|
function getDefaultAnswerArea(){return ItemExtras.reduce((acc,curr)=>({...acc,[curr]:false}),{})}
|
|
321
328
|
|
|
@@ -323,5 +330,9 @@ function splitPerseusItem(original){const item=deepClone(original);return {...it
|
|
|
323
330
|
|
|
324
331
|
const PerseusFeatureFlags=["new-radio-widget"];
|
|
325
332
|
|
|
326
|
-
|
|
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 };
|
|
327
338
|
//# sourceMappingURL=index.js.map
|