@khanacademy/perseus-core 0.0.0-PR3147-20251218001733 → 0.0.0-PR3149-20251218020241
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/data-schema.d.ts +22 -4
- package/dist/es/index.item-splitting.js +5 -1
- package/dist/es/index.item-splitting.js.map +1 -1
- package/dist/es/index.js +49 -27
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.item-splitting.js +5 -1
- package/dist/index.item-splitting.js.map +1 -1
- package/dist/index.js +76 -26
- package/dist/index.js.map +1 -1
- package/dist/parse-perseus-json/perseus-parsers/passage-ref-widget.d.ts +5 -0
- package/dist/parse-perseus-json/perseus-parsers/passage-ref-widget.typetest.d.ts +1 -0
- package/dist/parse-perseus-json/perseus-parsers/passage-widget.d.ts +7 -0
- package/dist/parse-perseus-json/perseus-parsers/passage-widget.typetest.d.ts +1 -0
- package/dist/parse-perseus-json/regression-tests/item-data/passage-missing-footnotes-and-title.d.ts +47 -0
- package/dist/parse-perseus-json/regression-tests/item-data/passage-ref-missing-summaryText.d.ts +147 -0
- package/dist/utils/generators/graded-group-set-widget-generator.d.ts +2 -0
- package/dist/utils/generators/graded-group-widget-generator.d.ts +3 -0
- package/dist/utils/generators/group-widget-generator.d.ts +3 -0
- package/dist/utils/generators/interactive-graph-widget-generator.d.ts +21 -0
- package/dist/widgets/interactive-graph/index.d.ts +1 -1
- package/dist/widgets/passage/index.d.ts +5 -0
- package/dist/widgets/passage-ref/index.d.ts +4 -0
- package/dist/widgets/passage-ref/passage-ref-upgrade.d.ts +7 -0
- package/dist/widgets/passage-ref-target/index.d.ts +5 -0
- package/package.json +2 -2
package/dist/es/index.js
CHANGED
|
@@ -154,6 +154,10 @@ const parseMathFormat=enumeration("integer","mixed","improper","proper","decimal
|
|
|
154
154
|
|
|
155
155
|
function parseRenderer(rawValue,ctx){return parsePerseusRenderer(rawValue,ctx)}const largeToAuto=(height,ctx)=>{if(height==="large"){return ctx.success("auto")}return ctx.success(height)};const parseOrdererWidget=parseWidget(constant("orderer"),object({options:defaulted(array(parseRenderer),()=>[]),correctOptions:defaulted(array(parseRenderer),()=>[]),otherOptions:defaulted(array(parseRenderer),()=>[]),height:pipeParsers(enumeration("normal","auto","large")).then(largeToAuto).parser,layout:defaulted(enumeration("horizontal","vertical"),()=>"horizontal")}));
|
|
156
156
|
|
|
157
|
+
const parsePassageRefWidget=parseWidget(constant("passage-ref"),object({passageNumber:number,referenceNumber:number,summaryText:optional(string)}));
|
|
158
|
+
|
|
159
|
+
const parsePassageWidget=parseWidget(constant("passage"),object({footnotes:defaulted(string,()=>""),passageText:string,passageTitle:defaulted(string,()=>""),showLineNumbers:boolean,static:defaulted(boolean,()=>false)}));
|
|
160
|
+
|
|
157
161
|
const parsePhetSimulationWidget=parseWidget(constant("phet-simulation"),object({url:string,description:string}));
|
|
158
162
|
|
|
159
163
|
const parsePlotterWidget=parseWidget(constant("plotter"),object({labels:array(string),categories:array(string),type:enumeration(...plotterPlotTypes),maxY:number,scaleY:defaulted(number,()=>1),labelInterval:optional(nullable(number)),snapsPerLine:defaulted(number,()=>2),starting:array(number),correct:defaulted(array(number),()=>[]),picUrl:optional(nullable(string)),picSize:optional(nullable(number)),picBoxHeight:optional(nullable(number)),plotDimensions:defaulted(array(number),()=>[380,300])}));
|
|
@@ -172,7 +176,7 @@ const parseVideoWidget=parseWidget(constant("video"),object({location:string,sta
|
|
|
172
176
|
|
|
173
177
|
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);
|
|
174
178
|
|
|
175
|
-
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 "
|
|
179
|
+
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({}));
|
|
176
180
|
|
|
177
181
|
const parsePerseusRenderer=defaulted(object({content:defaulted(string,()=>""),widgets:defaulted((rawVal,ctx)=>parseWidgetsMap(rawVal,ctx),()=>({})),images:parseImages,metadata:any}),()=>({content:"",widgets:{},images:{}}));
|
|
178
182
|
|
|
@@ -238,35 +242,35 @@ const pluck=function(table,subKey){return _.object(_.map(table,function(value,ke
|
|
|
238
242
|
|
|
239
243
|
function getCategorizerPublicWidgetOptions(options){return {items:options.items,categories:options.categories,randomizeItems:options.randomizeItems,static:options.static}}
|
|
240
244
|
|
|
241
|
-
const defaultWidgetOptions$
|
|
245
|
+
const defaultWidgetOptions$w={items:[],categories:[],values:[],randomizeItems:false};const categorizerWidgetLogic={name:"categorizer",defaultWidgetOptions: defaultWidgetOptions$w,getPublicWidgetOptions:getCategorizerPublicWidgetOptions,accessible:false};
|
|
242
246
|
|
|
243
247
|
function getCSProgramPublicWidgetOptions(options){return options}
|
|
244
248
|
|
|
245
|
-
const DEFAULT_HEIGHT=400;const defaultWidgetOptions$
|
|
249
|
+
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};
|
|
246
250
|
|
|
247
|
-
const defaultWidgetOptions$
|
|
251
|
+
const defaultWidgetOptions$u={togglePrompt:"",definition:""};const definitionWidgetLogic={name:"definition",defaultWidgetOptions: defaultWidgetOptions$u,defaultAlignment:"inline",accessible:true};
|
|
248
252
|
|
|
249
253
|
function getDropdownPublicWidgetOptions(options){return {choices:options.choices.map(choice=>({content:choice.content})),placeholder:options.placeholder,static:options.static,visibleLabel:options.visibleLabel,ariaLabel:options.ariaLabel}}
|
|
250
254
|
|
|
251
|
-
const defaultWidgetOptions$
|
|
255
|
+
const defaultWidgetOptions$t={placeholder:"",choices:[{content:"",correct:false}]};const dropdownWidgetLogic={name:"dropdown",defaultWidgetOptions: defaultWidgetOptions$t,defaultAlignment:"inline-block",getPublicWidgetOptions:getDropdownPublicWidgetOptions,accessible:true};
|
|
252
256
|
|
|
253
|
-
const defaultWidgetOptions$
|
|
257
|
+
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};
|
|
254
258
|
|
|
255
259
|
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}}
|
|
256
260
|
|
|
257
|
-
const currentVersion$
|
|
261
|
+
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};
|
|
258
262
|
|
|
259
|
-
const defaultWidgetOptions$
|
|
263
|
+
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:true,traverseChildWidgets:traverseChildWidgets$3};
|
|
260
264
|
|
|
261
265
|
function getFreeResponsePublicWidgetOptions(options){return {allowUnlimitedCharacters:options.allowUnlimitedCharacters,characterLimit:options.characterLimit,placeholder:options.placeholder,question:options.question}}
|
|
262
266
|
|
|
263
|
-
const defaultWidgetOptions$
|
|
267
|
+
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};
|
|
264
268
|
|
|
265
|
-
const defaultWidgetOptions$
|
|
269
|
+
const defaultWidgetOptions$o={gradedGroups:[]};const traverseChildWidgets$2=function(props,traverseRenderer){return {...props,...traverseRenderer(props)}};const gradedGroupSetWidgetLogic={name:"graded-group-set",defaultWidgetOptions: defaultWidgetOptions$o,accessible:true,traverseChildWidgets:traverseChildWidgets$2};
|
|
266
270
|
|
|
267
271
|
function getGrapherPublicWidgetOptions(options){const{correct:_,...publicOptions}=options;return publicOptions}
|
|
268
272
|
|
|
269
|
-
const defaultWidgetOptions$
|
|
273
|
+
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};
|
|
270
274
|
|
|
271
275
|
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;}}
|
|
272
276
|
|
|
@@ -274,49 +278,57 @@ const deprecatedStandinWidgetLogic={name:"deprecated-standin",accessible:true};
|
|
|
274
278
|
|
|
275
279
|
function getIFramePublicWidgetOptions(options){return options}
|
|
276
280
|
|
|
277
|
-
const defaultWidgetOptions$
|
|
281
|
+
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};
|
|
278
282
|
|
|
279
|
-
const defaultWidgetOptions$
|
|
283
|
+
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","wrap-left","wrap-right","full-width"],defaultAlignment:"block",accessible:widgetOptions=>{const imageOptions=widgetOptions;const bgImage=imageOptions.backgroundImage;const hasBackgroundImage=bgImage.url!=null;const hasAltText=!!imageOptions.alt;const isDecorative=imageOptions.decorative===true;return hasBackgroundImage&&(hasAltText||isDecorative)}};
|
|
280
284
|
|
|
281
285
|
function getInputNumberPublicWidgetOptions(options){const{value:_,...publicWidgetOptions}=options;return publicWidgetOptions}
|
|
282
286
|
|
|
283
|
-
const defaultWidgetOptions$
|
|
287
|
+
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};
|
|
284
288
|
|
|
285
|
-
const defaultWidgetOptions$
|
|
289
|
+
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};
|
|
286
290
|
|
|
287
291
|
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);})}
|
|
288
292
|
|
|
289
293
|
function getInteractiveGraphPublicWidgetOptions(options){const{correct:_,...publicOptions}=options;return publicOptions}
|
|
290
294
|
|
|
291
|
-
const defaultWidgetOptions$
|
|
295
|
+
const defaultWidgetOptions$i={labels:["$x$","$y$"],labelLocation:"onAxis",lockedFigures:[],range:[[-10,10],[-10,10]],step:[1,1],backgroundImage:{url:null},markings:"graph",showAxisArrows:{xMin:true,xMax:true,yMin:true,yMax:true},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}};
|
|
292
296
|
|
|
293
297
|
function getLabelImagePublicWidgetOptions(options){return {...options,markers:options.markers.map(getLabelImageMarkerPublicData)}}function getLabelImageMarkerPublicData(marker){const{answers:_,...publicData}=marker;return publicData}function isLabelImageAccessible(options){const labelImageOptions=options;if(labelImageOptions.imageUrl!==""&&labelImageOptions.imageAlt===""){return false}for(const marker of labelImageOptions.markers){if(marker.label===""){return false}}return true}
|
|
294
298
|
|
|
295
|
-
const defaultWidgetOptions$
|
|
299
|
+
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:isLabelImageAccessible};
|
|
296
300
|
|
|
297
301
|
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);
|
|
298
302
|
|
|
299
303
|
const shuffleMatcher=(options,problemNum)=>{const rng=seededRNG(problemNum);return {left:!options.orderMatters?options.left:shuffleDisplacingFirst$1(options.left,rng),right:shuffleDisplacingFirst$1(options.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)}
|
|
300
304
|
|
|
301
|
-
const defaultWidgetOptions$
|
|
305
|
+
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};
|
|
302
306
|
|
|
303
307
|
function getMatrixPublicWidgetOptions(options){const{answers:_,...publicOptions}=options;return publicOptions}
|
|
304
308
|
|
|
305
|
-
const defaultWidgetOptions$
|
|
309
|
+
const defaultWidgetOptions$f={matrixBoardSize:[3,3],answers:[[]],prefix:"",suffix:"",cursorPosition:[0,0]};const matrixWidgetLogic={name:"matrix",defaultWidgetOptions: defaultWidgetOptions$f,getPublicWidgetOptions:getMatrixPublicWidgetOptions,accessible:false};
|
|
306
310
|
|
|
307
|
-
const currentVersion$
|
|
311
|
+
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};
|
|
308
312
|
|
|
309
313
|
function getNumberLinePublicWidgetOptions(options){const{correctX:_,correctRel:__,...publicOptions}=options;return publicOptions}
|
|
310
314
|
|
|
311
|
-
const defaultWidgetOptions$
|
|
315
|
+
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};
|
|
312
316
|
|
|
313
317
|
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)}}
|
|
314
318
|
|
|
315
|
-
const defaultWidgetOptions$
|
|
319
|
+
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};
|
|
316
320
|
|
|
317
321
|
function getOrdererPublicWidgetOptions(fullOptions){const{options,height,layout}=fullOptions;return {options,height,layout}}
|
|
318
322
|
|
|
319
|
-
const defaultWidgetOptions$
|
|
323
|
+
const defaultWidgetOptions$b={correctOptions:[{content:"$x$"}],otherOptions:[{content:"$y$"}],height:"normal",layout:"horizontal"};const ordererWidgetLogic={name:"orderer",defaultWidgetOptions: defaultWidgetOptions$b,getPublicWidgetOptions:getOrdererPublicWidgetOptions,accessible:false};
|
|
324
|
+
|
|
325
|
+
const defaultWidgetOptions$a={passageTitle:"",passageText:"",footnotes:"",showLineNumbers:true};const passageWidgetLogic={name:"passage",defaultWidgetOptions: defaultWidgetOptions$a,accessible:false};
|
|
326
|
+
|
|
327
|
+
const currentVersion$1={major:0,minor:1};const defaultWidgetOptions$9={passageNumber:1,referenceNumber:1,summaryText:""};
|
|
328
|
+
|
|
329
|
+
const passageRefWidgetLogic={name:"passage-ref",version:currentVersion$1,defaultWidgetOptions:defaultWidgetOptions$9,defaultAlignment:"inline",accessible:false};
|
|
330
|
+
|
|
331
|
+
const defaultWidgetOptions$8={content:""};const passageRefTargetWidgetLogic={name:"passage-ref-target",defaultWidgetOptions: defaultWidgetOptions$8,defaultAlignment:"inline",accessible:false};
|
|
320
332
|
|
|
321
333
|
const defaultWidgetOptions$7={url:"",description:""};const phetSimulationWidgetLogic={name:"phet-simulation",defaultWidgetOptions: defaultWidgetOptions$7,accessible:true};
|
|
322
334
|
|
|
@@ -340,7 +352,7 @@ const defaultRows=4;const defaultColumns=1;const answers=new Array(defaultRows).
|
|
|
340
352
|
|
|
341
353
|
const defaultWidgetOptions$1={location:""};const videoWidgetLogic={name:"video",defaultWidgetOptions: defaultWidgetOptions$1,supportedAlignments:["block","wrap-left","wrap-right","full-width"],defaultAlignment:"block",accessible:true};
|
|
342
354
|
|
|
343
|
-
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};const getAlignmentClassName=(type,alignment)=>{switch(alignment){case "block":return " widget-block";case "inline-block":return " widget-inline-block";case "inline":return " widget-inline";case "wrap-left":return " widget-wrap-left";case "wrap-right":return " widget-wrap-right";case "full-width":return " widget-full-width";case "default":return getDefaultAlignment(type);default:return ""}};function registerCoreWidgets(){const widgets=[categorizerWidgetLogic,csProgramWidgetLogic,definitionWidgetLogic,deprecatedStandinWidgetLogic,dropdownWidgetLogic,explanationWidgetLogic,expressionWidgetLogic,gradedGroupWidgetLogic,gradedGroupSetWidgetLogic,grapherWidgetLogic,groupWidgetLogic,iframeWidgetLogic,imageWidgetLogic,inputNumberWidgetLogic,interactionWidgetLogic,interactiveGraphWidgetLogic,labelImageWidgetLogic,matcherWidgetLogic,matrixWidgetLogic,measurerWidgetLogic,numberLineWidgetLogic,numericInputWidgetLogic,ordererWidgetLogic,phetSimulationWidgetLogic,plotterWidgetLogic,pythonProgramWidgetLogic,radioWidgetLogic,sorterWidgetLogic,tableWidgetLogic,videoWidgetLogic];widgets.forEach(w=>{registerWidget(w.name,w);});}
|
|
355
|
+
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};const getAlignmentClassName=(type,alignment)=>{switch(alignment){case "block":return " widget-block";case "inline-block":return " widget-inline-block";case "inline":return " widget-inline";case "wrap-left":return " widget-wrap-left";case "wrap-right":return " widget-wrap-right";case "full-width":return " widget-full-width";case "default":return getDefaultAlignment(type);default:return ""}};function registerCoreWidgets(){const widgets=[categorizerWidgetLogic,csProgramWidgetLogic,definitionWidgetLogic,deprecatedStandinWidgetLogic,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);});}
|
|
344
356
|
|
|
345
357
|
var coreWidgetRegistry = /*#__PURE__*/Object.freeze({
|
|
346
358
|
__proto__: null,
|
|
@@ -387,7 +399,15 @@ function generateExpressionOptions(options){return {...expressionWidgetLogic.def
|
|
|
387
399
|
|
|
388
400
|
function generateFreeResponseOptions(options){return {...freeResponseWidgetLogic.defaultWidgetOptions,...options}}function generateFreeResponseWidget(freeResponseWidgetProperties){return {type:"free-response",graded:true,version:{major:0,minor:0},static:false,alignment:"default",options:generateFreeResponseOptions(),...freeResponseWidgetProperties}}
|
|
389
401
|
|
|
390
|
-
function
|
|
402
|
+
function generateGradedGroupOptions(options){return {...gradedGroupWidgetLogic.defaultWidgetOptions,...options}}function generateGradedGroupWidget(gradedGroupWidgetProperties){return {type:"graded-group",graded:false,version:{major:0,minor:0},static:false,alignment:"default",options:generateGradedGroupOptions(),...gradedGroupWidgetProperties}}
|
|
403
|
+
|
|
404
|
+
function generateGradedGroupSetWidget(gradedGroupSetWidgetProperties){return {type:"graded-group-set",graded:false,version:{major:0,minor:0},static:false,alignment:"default",options:{gradedGroups:[]},...gradedGroupSetWidgetProperties}}
|
|
405
|
+
|
|
406
|
+
function generateGroupOptions(options){return {...groupWidgetLogic.defaultWidgetOptions,...options}}function generateGroupWidget(groupWidgetProperties){return {type:"group",graded:true,version:{major:0,minor:0},static:false,alignment:"default",options:generateGroupOptions(),...groupWidgetProperties}}
|
|
407
|
+
|
|
408
|
+
function generateImageOptions(options){const defaultImageOptions={backgroundImage:{}};return {...defaultImageOptions,...options}}function generateImageWidget(imageWidgetProperties){return {type:"image",graded:false,version:{major:0,minor:0},static:false,alignment:"default",options:generateImageOptions({}),...imageWidgetProperties}}
|
|
409
|
+
|
|
410
|
+
function generateInteractiveGraphWidget(interactiveGraphWidgetProperties){return {type:"interactive-graph",graded:true,version:{major:0,minor:0},static:false,alignment:"default",options:generateInteractiveGraphOptions(),...interactiveGraphWidgetProperties}}function generateInteractiveGraphOptions(options){return {...interactiveGraphWidgetLogic.defaultWidgetOptions,...options}}function generateIGAngleGraph(options){return {type:"angle",...options}}function generateIGCircleGraph(options){return {type:"circle",...options}}function generateIGLinearGraph(options){return {type:"linear",...options}}function generateIGLinearSystemGraph(options){return {type:"linear-system",...options}}function generateIGNoneGraph(){return {type:"none"}}function generateIGPointGraph(options){return {type:"point",...options}}function generateIGPolygonGraph(options){return {type:"polygon",...options}}function generateIGQuadraticGraph(options){return {type:"quadratic",...options}}function generateIGRayGraph(options){return {type:"ray",...options}}function generateIGSegmentGraph(options){return {type:"segment",...options}}function generateIGSinusoidGraph(options){return {type:"sinusoid",...options}}function generateIGLockedPoint(options){return {...getDefaultFigureForType("point"),...options}}function generateIGLockedLine(options){return {...getDefaultFigureForType("line"),...options}}function generateIGLockedVector(options){return {...getDefaultFigureForType("vector"),...options}}function generateIGLockedEllipse(options){return {...getDefaultFigureForType("ellipse"),...options}}function generateIGLockedPolygon(options){return {...getDefaultFigureForType("polygon"),...options}}function generateIGLockedFunction(options){return {...getDefaultFigureForType("function"),...options}}function generateIGLockedLabel(options){return {...getDefaultFigureForType("label"),...options}}
|
|
391
411
|
|
|
392
412
|
function generateNumericInputOptions(options){return {...numericInputWidgetLogic.defaultWidgetOptions,static:false,...options}}function generateNumericInputAnswer(answerOptions){return {...numericInputWidgetLogic.defaultWidgetOptions.answers[0],...answerOptions}}function generateNumericInputWidget(numericInputWidgetProperties){return {type:"numeric-input",graded:true,version:{major:0,minor:0},static:false,alignment:"default",options:generateNumericInputOptions(),...numericInputWidgetProperties}}
|
|
393
413
|
|
|
@@ -396,7 +416,9 @@ function generateRadioOptions(options){return {...radioWidgetLogic.defaultWidget
|
|
|
396
416
|
function generateVideoWidget(videoWidgetProperties){return {type:"video",graded:true,version:{major:0,minor:0},static:false,alignment:"default",options:{location:""},...videoWidgetProperties}}
|
|
397
417
|
|
|
398
418
|
const joinOptionContents=options=>options.map(({content})=>content).join("\n");const toOptionLetter=index=>String.fromCharCode("A".charCodeAt(0)+index);function getAnswersFromWidgets(widgets){const answers=[];keys(widgets).forEach(widgetID=>{const widget=widgets[widgetID];if(!widget.options){return}switch(widget.type){case "radio":const radio=widget;const options=radio.options;if(options?.choices?.length){for(const choice of options.choices){if(choice?.correct){answers.push(choice.content);}}}break;case "categorizer":const categorizer=widget;if(categorizer.options?.categories&&categorizer.options?.items&&categorizer.options?.values){const categories=categorizer.options?.categories;const items=categorizer.options?.items;const values=categorizer.options?.values;answers.push(...values.map((value,index)=>`${items[index]}: ${categories[value]}`));}break;case "dropdown":const dropdown=widget;if(dropdown.options?.choices){for(const choice of dropdown.options.choices){if(choice.correct){answers.push(choice.content);}}}break;case "numeric-input":const numericInput=widget;if(numericInput.options?.answers){for(const ans of numericInput.options.answers){if(ans.status==="correct"&&ans.value!=null){answers.push(ans.value.toString());}}}break;case "input-number":const inputNumber=widget;if(inputNumber.options?.value){answers.push(inputNumber.options.value.toString());}break;case "expression":const expression=widget;if(expression.options?.answerForms){answers.push(...expression.options.answerForms.map(answer=>answer.value));}break;case "group":case "graded-group":const gradedGroup=widget;if(gradedGroup.options?.widgets){answers.push(...getAnswersFromWidgets(gradedGroup.options.widgets));}break;case "plotter":const plotter=widget;if(plotter.options?.categories&&plotter.options?.correct&&plotter.options.categories.length===plotter.options.correct.length){const{categories,correct}=plotter.options;answers.push(`{${categories.map((category,index)=>`${category}: ${correct[index]}`).join(", ")}}`);}break;case "interactive-graph":case "grapher":const grapher=widget;if(grapher.options?.correct?.coords){answers.push(`There should be point(s) on [${grapher.options.correct?.coords.join("], [")}]`);}break;case "orderer":const orderer=widget;if(orderer.options?.correctOptions){answers.push(joinOptionContents(orderer.options.correctOptions));}break;case "sorter":const sorter=widget;if(sorter.options?.correct){answers.push(sorter.options.correct.join(", "));}break;case "label-image":const labelImage=widget;if(labelImage.options?.markers){answers.push(...labelImage.options.markers.map(m=>`{label: "${m.label}", position: {${m.x},${m.y}}, answer: "${m.answers.join(", ")}"}`));}break;case "number-line":const numberLine=widget;if(numberLine.options?.correctX!=null){answers.push(numberLine.options.correctX.toString());}break;case "matrix":const matrix=widget;if(matrix.options?.answers){answers.push(`[${matrix.options.answers.join("], [")}]`);}break;case "matcher":const matcher=widget;if(matcher.options?.left&&matcher.options?.right){const{left,right}=matcher.options;const[leftHeader,rightHeader]=matcher.options.labels;const tableHeader=`| ${leftHeader} | ${rightHeader} |
|
|
399
|
-
| --- | --- |`;const tableRows=left.map((leftItem,index)=>{return `| ${leftItem} | ${right[index]} |`});const table=[tableHeader,...tableRows].join("\n");answers.push(table);}break}});return answers}function injectWidgets(content,widgets,widgetProps){if(!content){return ""}if(!widgets){return content}let context=content;keys(widgets).forEach(widgetID=>{const widget=widgets[widgetID];if(!widget.options){return}switch(widget.type){case "radio":const radio=widget;const radioProps=widgetProps?.[widgetID];if(radio.options?.choices?.length){let radioContext=joinOptionContents(radioProps?radioProps.choices.map(({content},i)=>({content:`Option ${toOptionLetter(i)}: ${content}`})):radio.options.choices);if(!radioProps&&radio.options?.randomize){radioContext+="\nThose options are displayed in a different order to the user. If the user says the letter, number, or ordinal number, always ask them clarify which option they are referring to.\n";}context=context.replace(`[[☃ ${widgetID}]]`,radioContext);}break;case "image":const image=widget;if(image.options?.alt){context=context.replace(`[[☃ ${widgetID}]]`,`<img id="${widgetID}" alt="${image.options.alt}">`);}break;case "label-image":const labelImage=widget;if(labelImage.options?.imageAlt){context=context.replace(`[[☃ ${widgetID}]]`,`[An image with dots that user needs to label. Label choices: [${labelImage.options.choices.join(", ")}]. Image alt text: ${labelImage.options?.imageAlt??""}]`);}break;case "explanation":const explanation=widget;if(explanation.options?.explanation){context=context.replace(`[[☃ ${widgetID}]]`,injectWidgets(explanation.options.explanation,explanation.options.widgets));}break;case "
|
|
419
|
+
| --- | --- |`;const tableRows=left.map((leftItem,index)=>{return `| ${leftItem} | ${right[index]} |`});const table=[tableHeader,...tableRows].join("\n");answers.push(table);}break}});return answers}function injectWidgets(content,widgets,widgetProps){if(!content){return ""}if(!widgets){return content}let context=content;keys(widgets).forEach(widgetID=>{const widget=widgets[widgetID];if(!widget.options){return}switch(widget.type){case "radio":const radio=widget;const radioProps=widgetProps?.[widgetID];if(radio.options?.choices?.length){let radioContext=joinOptionContents(radioProps?radioProps.choices.map(({content},i)=>({content:`Option ${toOptionLetter(i)}: ${content}`})):radio.options.choices);if(!radioProps&&radio.options?.randomize){radioContext+="\nThose options are displayed in a different order to the user. If the user says the letter, number, or ordinal number, always ask them clarify which option they are referring to.\n";}context=context.replace(`[[☃ ${widgetID}]]`,radioContext);}break;case "image":const image=widget;if(image.options?.alt){context=context.replace(`[[☃ ${widgetID}]]`,`<img id="${widgetID}" alt="${image.options.alt}">`);}break;case "label-image":const labelImage=widget;if(labelImage.options?.imageAlt){context=context.replace(`[[☃ ${widgetID}]]`,`[An image with dots that user needs to label. Label choices: [${labelImage.options.choices.join(", ")}]. Image alt text: ${labelImage.options?.imageAlt??""}]`);}break;case "explanation":const explanation=widget;if(explanation.options?.explanation){context=context.replace(`[[☃ ${widgetID}]]`,injectWidgets(explanation.options.explanation,explanation.options.widgets));}break;case "passage":const passage=widget;if(passage.options?.passageTitle||passage.options?.passageText){const{passageTitle,passageText}=passage.options;context=context.replace(`[[☃ ${widgetID}]]`,`# ${passageTitle}
|
|
420
|
+
|
|
421
|
+
${passageText}`);}break;case "group":case "graded-group":const group=widget;if(group.options?.widgets&&group.options.content){context=context.replace(`[[☃ ${widgetID}]]`,injectWidgets(group.options.content,group.options.widgets));}break;case "graded-group-set":const gradedGroup=widget;if(gradedGroup.options?.gradedGroups){const gradedGroups=gradedGroup.options.gradedGroups;const gradedGroupsContent=gradedGroups.reduce((acc,group)=>{if(group.widgets&&group.content){acc+=injectWidgets(group.content,group.widgets)+"\n";}return acc},"");context=context.replace(`[[☃ ${widgetID}]]`,gradedGroupsContent);}break;case "categorizer":const categorizer=widget;if(categorizer.options?.categories&&categorizer.options.items){const categories=categorizer.options.categories;const items=categorizer.options.items;context=context.replace(`[[☃ ${widgetID}]]`,`For each item, select the correct category. Categories: ${categories.join(", ")}.
|
|
400
422
|
Items:
|
|
401
423
|
${items.join("\n")}
|
|
402
424
|
`);}break;case "dropdown":const dropdown=widget;if(dropdown.options?.choices){const choices=dropdown.options.choices.map(choice=>choice.content);context=context.replace(`[[☃ ${widgetID}]]`,`[${choices.join(" | ")}]`);}break;case "definition":const definition=widget;if(definition.options?.togglePrompt){context=context.replace(`[[☃ ${widgetID}]]`,definition.options.togglePrompt);}break;case "orderer":const orderer=widget;if(orderer.options?.options){context=context.replace(`[[☃ ${widgetID}]]`,joinOptionContents(orderer.options.options));}break;case "sorter":const sorter=widget;if(sorter.options?.correct){const choices=sorter.options.correct;context=context.replace(`[[☃ ${widgetID}]]`,`[${choices.join(" | ")}]`);}break;case "interactive-graph":const interactiveGraph=widget;if(interactiveGraph.options?.range.length===2){const[x,y]=interactiveGraph.options.range;context=context.replace(`[[☃ ${widgetID}]]`,`[Graph with an x range of ${x[0]} to ${x[1]} and y range of ${y[0]} to ${y[1]}]`);}break;case "number-line":const numberLine=widget;if(numberLine.options?.range.length===2&&numberLine.options?.tickStep&&numberLine.options?.initialX){const[min,max]=numberLine.options.range;const step=numberLine.options.tickStep;const initialPosition=numberLine.options.initialX;context=context.replace(`[[☃ ${widgetID}]]`,`[Number line with a range of ${min} to ${max}, a step of ${step}, and an initial position of ${initialPosition}]`);}break;case "matrix":const matrix=widget;if(matrix.options?.matrixBoardSize.length===2){const[rows,columns]=matrix.options.matrixBoardSize;context=context.replace(`[[☃ ${widgetID}]]`,`[Matrix with ${rows} rows and ${columns} columns. The user can click on each cell to enter a value]`);}break;case "matcher":const matcher=widget;if(matcher.options?.left&&matcher.options?.right){const{left,right}=matcher.options;const[leftHeader,rightHeader]=matcher.options.labels;const tableHeader=`| ${leftHeader} | ${rightHeader} |
|
|
@@ -405,5 +427,5 @@ ${table}`);}break;case "numeric-input":case "input-number":case "expression":con
|
|
|
405
427
|
|
|
406
428
|
registerCoreWidgets();
|
|
407
429
|
|
|
408
|
-
export { coreWidgetRegistry as CoreWidgetRegistry, ErrorCodes, 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, generateDefinitionOptions, generateDefinitionWidget, generateDropdownOptions, generateDropdownWidget, generateExplanationOptions, generateExplanationWidget, generateExpressionAnswerForm, generateExpressionOptions, generateExpressionWidget, generateFreeResponseOptions, generateFreeResponseWidget, generateImageOptions, generateImageWidget, generateNumericInputAnswer, generateNumericInputOptions, generateNumericInputWidget, generateRadioChoice, generateRadioOptions, generateRadioWidget, generateSimpleRadioItem, generateSimpleRadioQuestion, generateTestPerseusItem, generateTestPerseusRenderer, generateVideoWidget, getAnswersFromWidgets, getBaseUrl, getCSProgramPublicWidgetOptions, getCategorizerPublicWidgetOptions, getDataUrl, getDecimalSeparator, getDefaultAnswerArea, getDefaultFigureForType, getDivideSymbol, getDivideSymbolForTex, getDropdownPublicWidgetOptions, getExpressionPublicWidgetOptions, getFreeResponsePublicWidgetOptions, getGrapherPublicWidgetOptions, getGroupPublicWidgetOptions, getIFramePublicWidgetOptions, getImageSizeModern, getInteractiveGraphPublicWidgetOptions, getLabelImagePublicWidgetOptions, getMatcherPublicWidgetOptions, getMatrixPublicWidgetOptions, getMatrixSize, getNumberLinePublicWidgetOptions, getNumericInputPublicWidgetOptions, getOrdererPublicWidgetOptions, getPerseusAIData, 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, injectWidgets, inputNumberWidgetLogic as inputNumberLogic, interactionWidgetLogic as interactionLogic, interactiveGraphWidgetLogic as interactiveGraphLogic, isFailure, isFeatureOn, isItemAccessible, isLabeledSVG, isSuccess, itemHasHints, itemHasRationales, labelImageWidgetLogic as labelImageLogic, libVersion, lockedFigureColorNames, lockedFigureColors, lockedFigureFillStyles, makeSafeUrl, mapObject, matcherWidgetLogic as matcherLogic, matrixWidgetLogic as matrixLogic, measurerWidgetLogic as measurerLogic, numberLineWidgetLogic as numberLineLogic, numericInputWidgetLogic as numericInputLogic, ordererWidgetLogic as ordererLogic, parseAndMigratePerseusArticle, parseAndMigratePerseusItem, parseAndMigrateUserInputMap, parsePerseusItem, phetSimulationWidgetLogic as phetSimulationLogic, plotterWidgetLogic as plotterLogic, plotterPlotTypes, pluck, pythonProgramWidgetLogic as pythonProgramLogic, radioWidgetLogic as radioLogic, random, seededRNG, shuffle, shuffleMatcher, shuffleSorter, sorterWidgetLogic as sorterLogic, splitPerseusItem, splitPerseusItemJSON, tableWidgetLogic as tableLogic, traverse, usesNumCorrect, videoWidgetLogic as videoLogic, violatingWidgets };
|
|
430
|
+
export { coreWidgetRegistry as CoreWidgetRegistry, ErrorCodes, 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, generateDefinitionOptions, generateDefinitionWidget, generateDropdownOptions, generateDropdownWidget, generateExplanationOptions, generateExplanationWidget, generateExpressionAnswerForm, generateExpressionOptions, generateExpressionWidget, generateFreeResponseOptions, generateFreeResponseWidget, generateGradedGroupOptions, generateGradedGroupSetWidget, generateGradedGroupWidget, generateGroupOptions, generateGroupWidget, generateIGAngleGraph, generateIGCircleGraph, generateIGLinearGraph, generateIGLinearSystemGraph, generateIGLockedEllipse, generateIGLockedFunction, generateIGLockedLabel, generateIGLockedLine, generateIGLockedPoint, generateIGLockedPolygon, generateIGLockedVector, generateIGNoneGraph, generateIGPointGraph, generateIGPolygonGraph, generateIGQuadraticGraph, generateIGRayGraph, generateIGSegmentGraph, generateIGSinusoidGraph, generateImageOptions, generateImageWidget, generateInteractiveGraphOptions, generateInteractiveGraphWidget, generateNumericInputAnswer, generateNumericInputOptions, generateNumericInputWidget, generateRadioChoice, generateRadioOptions, generateRadioWidget, generateSimpleRadioItem, generateSimpleRadioQuestion, generateTestPerseusItem, generateTestPerseusRenderer, generateVideoWidget, getAnswersFromWidgets, getBaseUrl, getCSProgramPublicWidgetOptions, getCategorizerPublicWidgetOptions, getDataUrl, getDecimalSeparator, getDefaultAnswerArea, getDefaultFigureForType, getDivideSymbol, getDivideSymbolForTex, getDropdownPublicWidgetOptions, getExpressionPublicWidgetOptions, getFreeResponsePublicWidgetOptions, getGrapherPublicWidgetOptions, getGroupPublicWidgetOptions, getIFramePublicWidgetOptions, getImageSizeModern, getInteractiveGraphPublicWidgetOptions, getLabelImagePublicWidgetOptions, getMatcherPublicWidgetOptions, getMatrixPublicWidgetOptions, getMatrixSize, getNumberLinePublicWidgetOptions, getNumericInputPublicWidgetOptions, getOrdererPublicWidgetOptions, getPerseusAIData, 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, injectWidgets, inputNumberWidgetLogic as inputNumberLogic, interactionWidgetLogic as interactionLogic, interactiveGraphWidgetLogic as interactiveGraphLogic, isFailure, isFeatureOn, isItemAccessible, isLabeledSVG, isSuccess, itemHasHints, itemHasRationales, labelImageWidgetLogic as labelImageLogic, libVersion, lockedFigureColorNames, lockedFigureColors, lockedFigureFillStyles, makeSafeUrl, mapObject, matcherWidgetLogic as matcherLogic, matrixWidgetLogic as matrixLogic, measurerWidgetLogic as measurerLogic, numberLineWidgetLogic as numberLineLogic, numericInputWidgetLogic as numericInputLogic, ordererWidgetLogic as ordererLogic, parseAndMigratePerseusArticle, parseAndMigratePerseusItem, parseAndMigrateUserInputMap, 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, seededRNG, shuffle, shuffleMatcher, shuffleSorter, sorterWidgetLogic as sorterLogic, splitPerseusItem, splitPerseusItemJSON, tableWidgetLogic as tableLogic, traverse, usesNumCorrect, videoWidgetLogic as videoLogic, violatingWidgets };
|
|
409
431
|
//# sourceMappingURL=index.js.map
|