@pie-element/hotspot 5.14.6-next.8 → 5.15.1-next.6

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.
@@ -51,7 +51,8 @@ function model(question, session, env) {
51
51
  outlineColor = normalizedQuestion.outlineColor,
52
52
  partialScoring = normalizedQuestion.partialScoring,
53
53
  prompt = normalizedQuestion.prompt,
54
- shapes = normalizedQuestion.shapes;
54
+ shapes = normalizedQuestion.shapes,
55
+ language = normalizedQuestion.language;
55
56
 
56
57
  var _ref = shapes || {},
57
58
  rectangles = _ref.rectangles,
@@ -67,6 +68,7 @@ function model(question, session, env) {
67
68
  hotspotColor: hotspotColor,
68
69
  multipleCorrect: multipleCorrect,
69
70
  partialScoring: partialScoring,
71
+ language: language,
70
72
  shapes: _objectSpread(_objectSpread({}, shapes), {}, {
71
73
  // eslint-disable-next-line no-unused-vars
72
74
  rectangles: (rectangles || []).map(function (_ref2) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["log","normalize","question","defaults","model","session","env","normalizedQuestion","imageUrl","dimensions","hotspotColor","multipleCorrect","outlineColor","partialScoring","prompt","shapes","rectangles","polygons","Promise","resolve","out","disabled","mode","map","index","rectProps","polyProps","responseCorrect","undefined","role","rationale","rationaleEnabled","teacherInstructions","teacherInstructionsEnabled","promptEnabled","strokeWidth","createDefaultModel","getScore","config","answers","partialScoringEnabled","enabled","correctAnswers","selectedChoices","choices","correctChoices","filter","choice","correct","forEach","shape","selected","answer","id","correctlySelected","extraAnswers","length","total","str","toFixed","parseFloat","outcome","score","empty","returnShapesCorrect","i","push","createCorrectResponseSession","rectangleCorrect","polygonsCorrect","validate","minShapes","maxShapes","maxSelections","errors","allShapes","Object","values","reduce","acc","nbOfSelections","nbOfShapes","shapesError","selectionsError"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AAEA;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,iCAA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B,4CAAzB;AACD,GAFD,MAEO,IAAIH,cAAc,GAAGP,aAArB,EAAoC;AACzCC,IAAAA,MAAM,CAACS,eAAP,0BAAyCV,aAAzC;AACD;;AAED,SAAOC,MAAP;AACD,CAxBM","sourcesContent":["import debug from 'debug';\nimport isEmpty from 'lodash/isEmpty';\nimport { partialScoring } from '@pie-lib/controller-utils';\n\nimport { isResponseCorrect } from './utils';\n\nimport defaults from './defaults';\n\nconst log = debug('pie-elements:hotspot:controller');\n\nexport const normalize = (question) => ({\n ...defaults,\n ...question,\n});\n\nexport function model(question, session, env) {\n const normalizedQuestion = normalize(question);\n const { imageUrl, dimensions, hotspotColor, multipleCorrect, outlineColor, partialScoring, prompt, shapes } =\n normalizedQuestion;\n const { rectangles, polygons } = shapes || {};\n\n return new Promise((resolve) => {\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n dimensions,\n imageUrl,\n outlineColor,\n hotspotColor,\n multipleCorrect,\n partialScoring,\n shapes: {\n ...shapes,\n // eslint-disable-next-line no-unused-vars\n rectangles: (rectangles || []).map(({ index, ...rectProps }) => ({ ...rectProps })),\n // eslint-disable-next-line no-unused-vars\n polygons: (polygons || []).map(({ index, ...polyProps }) => ({ ...polyProps })),\n },\n responseCorrect: env.mode === 'evaluate' ? isResponseCorrect(normalizedQuestion, session) : undefined,\n };\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n out.rationale = null;\n out.teacherInstructions = null;\n }\n\n out.prompt = normalizedQuestion.promptEnabled ? prompt : null;\n out.strokeWidth = normalizedQuestion.strokeWidth;\n\n // console.log(out);\n resolve(out);\n });\n}\n\nexport const createDefaultModel = (model = {}) =>\n new Promise((resolve) => {\n resolve({\n ...defaults,\n ...model,\n });\n });\n\nconst getScore = (config, session, env = {}) => {\n const { answers } = session || {};\n\n if (!config.shapes || (!config.shapes.rectangles && !config.shapes.polygons)) {\n return 0;\n }\n\n const { shapes: { rectangles = [], polygons = [] } = {} } = config;\n const partialScoringEnabled = partialScoring.enabled(config, env);\n\n if (!partialScoringEnabled) {\n return isResponseCorrect(config, session) ? 1 : 0;\n }\n\n let correctAnswers = 0;\n let selectedChoices = 0;\n\n const choices = [...rectangles, ...polygons];\n\n const correctChoices = choices.filter((choice) => choice.correct);\n\n choices.forEach((shape) => {\n const selected = answers && answers.filter((answer) => answer.id === shape.id)[0];\n const correctlySelected = shape.correct && selected;\n\n if (selected) {\n selectedChoices += 1;\n }\n\n if (correctlySelected) {\n correctAnswers += 1;\n }\n });\n\n const extraAnswers = selectedChoices > correctChoices.length ? selectedChoices - correctChoices.length : 0;\n\n const total = correctChoices.length === 0 ? 1 : correctChoices.length;\n const str = ((correctAnswers - extraAnswers) / total).toFixed(2);\n\n return str < 0 ? 0 : parseFloat(str);\n};\n\nexport function outcome(config, session, env = {}) {\n return new Promise((resolve) => {\n log('outcome...');\n\n if (!session || isEmpty(session)) {\n resolve({ score: 0, empty: true });\n }\n\n if (session.answers) {\n const score = getScore(config, session, env);\n resolve({ score });\n } else {\n resolve({ score: 0, empty: true });\n }\n });\n}\n\nconst returnShapesCorrect = (shapes) => {\n let answers = [];\n\n shapes.forEach((i) => {\n const { correct, id } = i;\n if (correct) {\n answers.push({ id });\n }\n });\n return answers;\n};\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { shapes: { rectangles = [], polygons = {} } = {} } = question;\n\n const rectangleCorrect = returnShapesCorrect(rectangles);\n const polygonsCorrect = returnShapesCorrect(polygons);\n\n resolve({\n answers: [...rectangleCorrect, ...polygonsCorrect],\n id: '1',\n });\n } else {\n resolve(null);\n }\n });\n};\n\nexport const validate = (model = {}, config = {}) => {\n const { shapes } = model;\n const { minShapes = 2, maxShapes, maxSelections } = config;\n const errors = {};\n\n const allShapes = Object.values(shapes || {}).reduce((acc, shape) => [...acc, ...shape], []);\n\n const nbOfSelections = (allShapes || []).reduce((acc, shape) => (shape.correct ? acc + 1 : acc), 0);\n\n const nbOfShapes = (allShapes || []).length;\n\n if (nbOfShapes < minShapes) {\n errors.shapesError = `There should be at least ${minShapes} shapes defined.`;\n } else if (nbOfShapes > maxShapes) {\n errors.shapesError = `No more than ${maxShapes} shapes should be defined.`;\n }\n\n if (nbOfSelections < 1) {\n errors.selectionsError = 'There should be at least 1 shape selected.';\n } else if (nbOfSelections > maxSelections) {\n errors.selectionsError = `No more than ${maxSelections} shapes should be selected.`;\n }\n\n return errors;\n};\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.js"],"names":["log","normalize","question","defaults","model","session","env","normalizedQuestion","imageUrl","dimensions","hotspotColor","multipleCorrect","outlineColor","partialScoring","prompt","shapes","language","rectangles","polygons","Promise","resolve","out","disabled","mode","map","index","rectProps","polyProps","responseCorrect","undefined","role","rationale","rationaleEnabled","teacherInstructions","teacherInstructionsEnabled","promptEnabled","strokeWidth","createDefaultModel","getScore","config","answers","partialScoringEnabled","enabled","correctAnswers","selectedChoices","choices","correctChoices","filter","choice","correct","forEach","shape","selected","answer","id","correctlySelected","extraAnswers","length","total","str","toFixed","parseFloat","outcome","score","empty","returnShapesCorrect","i","push","createCorrectResponseSession","rectangleCorrect","polygonsCorrect","validate","minShapes","maxShapes","maxSelections","errors","allShapes","Object","values","reduce","acc","nbOfSelections","nbOfShapes","shapesError","selectionsError"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AAEA;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,iCAAN,CAAZ;;AAEO,IAAMC,SAAS,GAAG,SAAZA,SAAY,CAACC,QAAD;AAAA,yCACpBC,oBADoB,GAEpBD,QAFoB;AAAA,CAAlB;;;;AAKA,SAASE,KAAT,CAAeF,QAAf,EAAyBG,OAAzB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MAAM,CAACS,eAAP,0BAAyCV,aAAzC;AACD;;AAED,SAAOC,MAAP;AACD,CAxBM","sourcesContent":["import debug from 'debug';\nimport isEmpty from 'lodash/isEmpty';\nimport { partialScoring } from '@pie-lib/controller-utils';\n\nimport { isResponseCorrect } from './utils';\n\nimport defaults from './defaults';\n\nconst log = debug('pie-elements:hotspot:controller');\n\nexport const normalize = (question) => ({\n ...defaults,\n ...question,\n});\n\nexport function model(question, session, env) {\n const normalizedQuestion = normalize(question);\n const { imageUrl, dimensions, hotspotColor, multipleCorrect, outlineColor, partialScoring, prompt, shapes, language } =\n normalizedQuestion;\n const { rectangles, polygons } = shapes || {};\n\n return new Promise((resolve) => {\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n dimensions,\n imageUrl,\n outlineColor,\n hotspotColor,\n multipleCorrect,\n partialScoring,\n language,\n shapes: {\n ...shapes,\n // eslint-disable-next-line no-unused-vars\n rectangles: (rectangles || []).map(({ index, ...rectProps }) => ({ ...rectProps })),\n // eslint-disable-next-line no-unused-vars\n polygons: (polygons || []).map(({ index, ...polyProps }) => ({ ...polyProps })),\n },\n responseCorrect: env.mode === 'evaluate' ? isResponseCorrect(normalizedQuestion, session) : undefined,\n };\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n out.rationale = null;\n out.teacherInstructions = null;\n }\n\n out.prompt = normalizedQuestion.promptEnabled ? prompt : null;\n out.strokeWidth = normalizedQuestion.strokeWidth;\n\n // console.log(out);\n resolve(out);\n });\n}\n\nexport const createDefaultModel = (model = {}) =>\n new Promise((resolve) => {\n resolve({\n ...defaults,\n ...model,\n });\n });\n\nconst getScore = (config, session, env = {}) => {\n const { answers } = session || {};\n\n if (!config.shapes || (!config.shapes.rectangles && !config.shapes.polygons)) {\n return 0;\n }\n\n const { shapes: { rectangles = [], polygons = [] } = {} } = config;\n const partialScoringEnabled = partialScoring.enabled(config, env);\n\n if (!partialScoringEnabled) {\n return isResponseCorrect(config, session) ? 1 : 0;\n }\n\n let correctAnswers = 0;\n let selectedChoices = 0;\n\n const choices = [...rectangles, ...polygons];\n\n const correctChoices = choices.filter((choice) => choice.correct);\n\n choices.forEach((shape) => {\n const selected = answers && answers.filter((answer) => answer.id === shape.id)[0];\n const correctlySelected = shape.correct && selected;\n\n if (selected) {\n selectedChoices += 1;\n }\n\n if (correctlySelected) {\n correctAnswers += 1;\n }\n });\n\n const extraAnswers = selectedChoices > correctChoices.length ? selectedChoices - correctChoices.length : 0;\n\n const total = correctChoices.length === 0 ? 1 : correctChoices.length;\n const str = ((correctAnswers - extraAnswers) / total).toFixed(2);\n\n return str < 0 ? 0 : parseFloat(str);\n};\n\nexport function outcome(config, session, env = {}) {\n return new Promise((resolve) => {\n log('outcome...');\n\n if (!session || isEmpty(session)) {\n resolve({ score: 0, empty: true });\n }\n\n if (session.answers) {\n const score = getScore(config, session, env);\n resolve({ score });\n } else {\n resolve({ score: 0, empty: true });\n }\n });\n}\n\nconst returnShapesCorrect = (shapes) => {\n let answers = [];\n\n shapes.forEach((i) => {\n const { correct, id } = i;\n if (correct) {\n answers.push({ id });\n }\n });\n return answers;\n};\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { shapes: { rectangles = [], polygons = {} } = {} } = question;\n\n const rectangleCorrect = returnShapesCorrect(rectangles);\n const polygonsCorrect = returnShapesCorrect(polygons);\n\n resolve({\n answers: [...rectangleCorrect, ...polygonsCorrect],\n id: '1',\n });\n } else {\n resolve(null);\n }\n });\n};\n\nexport const validate = (model = {}, config = {}) => {\n const { shapes } = model;\n const { minShapes = 2, maxShapes, maxSelections } = config;\n const errors = {};\n\n const allShapes = Object.values(shapes || {}).reduce((acc, shape) => [...acc, ...shape], []);\n\n const nbOfSelections = (allShapes || []).reduce((acc, shape) => (shape.correct ? acc + 1 : acc), 0);\n\n const nbOfShapes = (allShapes || []).length;\n\n if (nbOfShapes < minShapes) {\n errors.shapesError = `There should be at least ${minShapes} shapes defined.`;\n } else if (nbOfShapes > maxShapes) {\n errors.shapesError = `No more than ${maxShapes} shapes should be defined.`;\n }\n\n if (nbOfSelections < 1) {\n errors.selectionsError = 'There should be at least 1 shape selected.';\n } else if (nbOfSelections > maxSelections) {\n errors.selectionsError = `No more than ${maxSelections} shapes should be selected.`;\n }\n\n return errors;\n};\n"],"file":"index.js"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pie-element/hotspot-controller",
3
3
  "private": true,
4
- "version": "3.6.3",
4
+ "version": "3.7.0",
5
5
  "description": "",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -15,7 +15,7 @@ export const normalize = (question) => ({
15
15
 
16
16
  export function model(question, session, env) {
17
17
  const normalizedQuestion = normalize(question);
18
- const { imageUrl, dimensions, hotspotColor, multipleCorrect, outlineColor, partialScoring, prompt, shapes } =
18
+ const { imageUrl, dimensions, hotspotColor, multipleCorrect, outlineColor, partialScoring, prompt, shapes, language } =
19
19
  normalizedQuestion;
20
20
  const { rectangles, polygons } = shapes || {};
21
21
 
@@ -29,6 +29,7 @@ export function model(question, session, env) {
29
29
  hotspotColor,
30
30
  multipleCorrect,
31
31
  partialScoring,
32
+ language,
32
33
  shapes: {
33
34
  ...shapes,
34
35
  // eslint-disable-next-line no-unused-vars
@@ -177,6 +177,66 @@
177
177
  }
178
178
  }
179
179
  },
180
+ "language": {
181
+ "title": "ConfigurePropWithEnabled",
182
+ "type": "object",
183
+ "properties": {
184
+ "settings": {
185
+ "description": "Indicates if the item has to be displayed in the Settings Panel",
186
+ "type": "boolean",
187
+ "title": "settings"
188
+ },
189
+ "label": {
190
+ "description": "Indicates the label for the item that has to be displayed in the Settings Panel",
191
+ "type": "string",
192
+ "title": "label"
193
+ },
194
+ "enabled": {
195
+ "description": "Indicates the value of the item if it affects config-ui\n(eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)",
196
+ "type": "boolean",
197
+ "title": "enabled"
198
+ }
199
+ }
200
+ },
201
+ "languageChoices": {
202
+ "description": "Language choices configuration\nOnly available if language is enabled",
203
+ "type": "object",
204
+ "properties": {
205
+ "label": {
206
+ "type": "string",
207
+ "title": "label"
208
+ },
209
+ "options": {
210
+ "type": "array",
211
+ "items": {
212
+ "title": "ConfigureLanguageOptionsProp",
213
+ "type": "object",
214
+ "properties": {
215
+ "value": {
216
+ "description": "Value of the language option",
217
+ "type": "string",
218
+ "title": "value"
219
+ },
220
+ "label": {
221
+ "description": "Label of the language option",
222
+ "type": "string",
223
+ "title": "label"
224
+ }
225
+ },
226
+ "required": [
227
+ "label",
228
+ "value"
229
+ ]
230
+ },
231
+ "title": "options"
232
+ }
233
+ },
234
+ "required": [
235
+ "label",
236
+ "options"
237
+ ],
238
+ "title": "languageChoices"
239
+ },
180
240
  "showPrompt": {
181
241
  "description": "Determines whether prompt field will be displayed or not",
182
242
  "default": true,
@@ -293,6 +353,47 @@
293
353
  "title": "mmlEditing"
294
354
  }
295
355
  }
356
+ },
357
+ "ConfigurePropWithEnabled": {
358
+ "title": "ConfigurePropWithEnabled",
359
+ "type": "object",
360
+ "properties": {
361
+ "settings": {
362
+ "description": "Indicates if the item has to be displayed in the Settings Panel",
363
+ "type": "boolean",
364
+ "title": "settings"
365
+ },
366
+ "label": {
367
+ "description": "Indicates the label for the item that has to be displayed in the Settings Panel",
368
+ "type": "string",
369
+ "title": "label"
370
+ },
371
+ "enabled": {
372
+ "description": "Indicates the value of the item if it affects config-ui\n(eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)",
373
+ "type": "boolean",
374
+ "title": "enabled"
375
+ }
376
+ }
377
+ },
378
+ "ConfigureLanguageOptionsProp": {
379
+ "title": "ConfigureLanguageOptionsProp",
380
+ "type": "object",
381
+ "properties": {
382
+ "value": {
383
+ "description": "Value of the language option",
384
+ "type": "string",
385
+ "title": "value"
386
+ },
387
+ "label": {
388
+ "description": "Label of the language option",
389
+ "type": "string",
390
+ "title": "label"
391
+ }
392
+ },
393
+ "required": [
394
+ "label",
395
+ "value"
396
+ ]
296
397
  }
297
398
  },
298
399
  "$schema": "http://json-schema.org/draft-07/schema#"
@@ -134,6 +134,46 @@ Indicates if model should have mathML output instead of latex
134
134
 
135
135
  Indicates if mathML that's already in model should be editable
136
136
 
137
+ # `language` (object)
138
+
139
+ Properties of the `language` object:
140
+
141
+ ## `settings` (boolean)
142
+
143
+ Indicates if the item has to be displayed in the Settings Panel
144
+
145
+ ## `label` (string)
146
+
147
+ Indicates the label for the item that has to be displayed in the Settings Panel
148
+
149
+ ## `enabled` (boolean)
150
+
151
+ Indicates the value of the item if it affects config-ui
152
+ (eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
153
+
154
+ # `languageChoices` (object)
155
+
156
+ Language choices configuration
157
+ Only available if language is enabled
158
+
159
+ Properties of the `languageChoices` object:
160
+
161
+ ## `label` (string, required)
162
+
163
+ ## `options` (array, required)
164
+
165
+ The object is an array with all elements of the type `object`.
166
+
167
+ The array object has the following properties:
168
+
169
+ ### `value` (string, required)
170
+
171
+ Value of the language option
172
+
173
+ ### `label` (string, required)
174
+
175
+ Label of the language option
176
+
137
177
  # `showPrompt` (boolean)
138
178
 
139
179
  Determines whether prompt field will be displayed or not
@@ -230,4 +270,33 @@ Indicates if model should have mathML output instead of latex
230
270
 
231
271
  ### `mmlEditing` (number)
232
272
 
233
- Indicates if mathML that's already in model should be editable
273
+ Indicates if mathML that's already in model should be editable
274
+
275
+ ## `ConfigurePropWithEnabled` (object)
276
+
277
+ Properties of the `ConfigurePropWithEnabled` object:
278
+
279
+ ### `settings` (boolean)
280
+
281
+ Indicates if the item has to be displayed in the Settings Panel
282
+
283
+ ### `label` (string)
284
+
285
+ Indicates the label for the item that has to be displayed in the Settings Panel
286
+
287
+ ### `enabled` (boolean)
288
+
289
+ Indicates the value of the item if it affects config-ui
290
+ (eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
291
+
292
+ ## `ConfigureLanguageOptionsProp` (object)
293
+
294
+ Properties of the `ConfigureLanguageOptionsProp` object:
295
+
296
+ ### `value` (string, required)
297
+
298
+ Value of the language option
299
+
300
+ ### `label` (string, required)
301
+
302
+ Label of the language option
@@ -230,6 +230,11 @@
230
230
  "type": "boolean",
231
231
  "title": "rubricEnabled"
232
232
  },
233
+ "language": {
234
+ "description": "Indicates the language of the component\nSupported options: en, es, en_US, en-US, es_ES, es-ES, es_MX, es-MX",
235
+ "type": "string",
236
+ "title": "language"
237
+ },
233
238
  "id": {
234
239
  "description": "Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.",
235
240
  "type": "string",
@@ -309,6 +314,47 @@
309
314
  }
310
315
  }
311
316
  },
317
+ "ConfigurePropWithEnabled": {
318
+ "title": "ConfigurePropWithEnabled",
319
+ "type": "object",
320
+ "properties": {
321
+ "settings": {
322
+ "description": "Indicates if the item has to be displayed in the Settings Panel",
323
+ "type": "boolean",
324
+ "title": "settings"
325
+ },
326
+ "label": {
327
+ "description": "Indicates the label for the item that has to be displayed in the Settings Panel",
328
+ "type": "string",
329
+ "title": "label"
330
+ },
331
+ "enabled": {
332
+ "description": "Indicates the value of the item if it affects config-ui\n(eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)",
333
+ "type": "boolean",
334
+ "title": "enabled"
335
+ }
336
+ }
337
+ },
338
+ "ConfigureLanguageOptionsProp": {
339
+ "title": "ConfigureLanguageOptionsProp",
340
+ "type": "object",
341
+ "properties": {
342
+ "value": {
343
+ "description": "Value of the language option",
344
+ "type": "string",
345
+ "title": "value"
346
+ },
347
+ "label": {
348
+ "description": "Label of the language option",
349
+ "type": "string",
350
+ "title": "label"
351
+ }
352
+ },
353
+ "required": [
354
+ "label",
355
+ "value"
356
+ ]
357
+ },
312
358
  "Shape": {
313
359
  "title": "Shape",
314
360
  "type": "object",
@@ -165,6 +165,11 @@ Default: `": 'bottom'"`
165
165
 
166
166
  Indicates if Rubric is enabled
167
167
 
168
+ # `language` (string)
169
+
170
+ Indicates the language of the component
171
+ Supported options: en, es, en_US, en-US, es_ES, es-ES, es_MX, es-MX
172
+
168
173
  # `id` (string, required)
169
174
 
170
175
  Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.
@@ -219,6 +224,35 @@ Indicates if model should have mathML output instead of latex
219
224
 
220
225
  Indicates if mathML that's already in model should be editable
221
226
 
227
+ ## `ConfigurePropWithEnabled` (object)
228
+
229
+ Properties of the `ConfigurePropWithEnabled` object:
230
+
231
+ ### `settings` (boolean)
232
+
233
+ Indicates if the item has to be displayed in the Settings Panel
234
+
235
+ ### `label` (string)
236
+
237
+ Indicates the label for the item that has to be displayed in the Settings Panel
238
+
239
+ ### `enabled` (boolean)
240
+
241
+ Indicates the value of the item if it affects config-ui
242
+ (eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
243
+
244
+ ## `ConfigureLanguageOptionsProp` (object)
245
+
246
+ Properties of the `ConfigureLanguageOptionsProp` object:
247
+
248
+ ### `value` (string, required)
249
+
250
+ Value of the language option
251
+
252
+ ### `label` (string, required)
253
+
254
+ Label of the language option
255
+
222
256
  ## `Shape` (object)
223
257
 
224
258
  Properties of the `Shape` object:
@@ -125,6 +125,7 @@ var HotspotComponent = /*#__PURE__*/function (_React$Component) {
125
125
  teacherInstructions = _this$props$model.teacherInstructions,
126
126
  strokeWidth = _this$props$model.strokeWidth,
127
127
  responseCorrect = _this$props$model.responseCorrect,
128
+ language = _this$props$model.language,
128
129
  onSelectChoice = _this$props.onSelectChoice,
129
130
  classes = _this$props.classes;
130
131
  var showCorrect = this.state.showCorrect;
@@ -147,7 +148,8 @@ var HotspotComponent = /*#__PURE__*/function (_React$Component) {
147
148
  }), showCorrectAnswerToggle && /*#__PURE__*/_react["default"].createElement(_correctAnswerToggle["default"], {
148
149
  show: showCorrectAnswerToggle,
149
150
  toggled: showCorrect,
150
- onToggle: this.onToggle.bind(this)
151
+ onToggle: this.onToggle.bind(this),
152
+ language: language
151
153
  }), imageUrl ? /*#__PURE__*/_react["default"].createElement(_container["default"], {
152
154
  isEvaluateMode: isEvaluateMode,
153
155
  session: session,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hotspot/index.jsx"],"names":["HotspotComponent","props","showCorrect","state","setState","observer","scale","MutationObserver","mutations","forEach","target","document","getElementById","style","cssText","zoom","substring","indexOf","lastIndexOf","zoomParsed","replace","newScale","parseFloat","observe","attributes","attributeFilter","disconnect","session","model","disabled","imageUrl","prompt","mode","multipleCorrect","shapes","outlineColor","hotspotColor","dimensions","rationale","teacherInstructions","strokeWidth","responseCorrect","onSelectChoice","classes","isEvaluateMode","showCorrectAnswerToggle","main","hidden","visible","collapsible","onToggle","bind","React","Component","propTypes","PropTypes","object","isRequired","func","defaultProps","styles","theme","color","text","backgroundColor","background","marginBottom","spacing","unit","fontSize"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;IAEMA,gB;;;;;AACJ,4BAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AADiB,iGA2CR,YAAM;AACf,UAAQC,WAAR,GAAwB,MAAKC,KAA7B,CAAQD,WAAR;;AACA,YAAKE,QAAL,CAAc;AAAEF,QAAAA,WAAW,EAAE,CAACA;AAAhB,OAAd;AACD,KA9CkB;AAEjB,UAAKC,KAAL,GAAa;AACXD,MAAAA,WAAW,EAAE,KADF;AAEXG,MAAAA,QAAQ,EAAE,IAFC;AAGXC,MAAAA,KAAK,EAAE;AAHI,KAAb;AAFiB;AAOlB;;;;WAED,6BAAoB;AAAA;;AAClB,WAAKD,QAAL,GAAgB,IAAIE,gBAAJ,CAAqB,UAACC,SAAD,EAAe;AAClDA,QAAAA,SAAS,CAACC,OAAV,CAAkB,YAAM;AAAA;;AACtB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D,YAAjB,GAAgC;AAC9BhB,EAAAA,OAAO,EAAE;AADqB,CAAhC;;AAIA,IAAMiB,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBf,IAAAA,IAAI,EAAE;AACJgB,MAAAA,KAAK,EAAEA,gBAAMC,IAAN,EADH;AAEJC,MAAAA,eAAe,EAAEF,gBAAMG,UAAN;AAFb,KADmB;AAKzBhB,IAAAA,WAAW,EAAE;AACXiB,MAAAA,YAAY,EAAEL,KAAK,CAACM,OAAN,CAAcC,IAAd,GAAqB;AADxB,KALY;AAQzBrC,IAAAA,MAAM,EAAE;AACNsC,MAAAA,QAAQ,EAAE;AADJ;AARiB,GAAZ;AAAA,CAAf;;eAae,wBAAWT,MAAX,EAAmB5D,gBAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport CorrectAnswerToggle from '@pie-lib/correct-answer-toggle';\nimport { color, Collapsible, hasText, PreviewPrompt } from '@pie-lib/render-ui';\nimport { withStyles } from '@material-ui/core/styles';\n\nimport Container from './container';\n\nclass HotspotComponent extends React.Component {\n constructor(props) {\n super(props);\n this.state = {\n showCorrect: false,\n observer: null,\n scale: 1,\n };\n }\n\n componentDidMount() {\n this.observer = new MutationObserver((mutations) => {\n mutations.forEach(() => {\n const target = document.getElementById('question-container')?.style?.cssText;\n const zoom = target?.substring(target.indexOf('--pie-zoom') + 11, target.lastIndexOf('%'));\n const zoomParsed = zoom?.replace(/\\s/g, '');\n\n if (zoomParsed) {\n const newScale = parseFloat(zoomParsed) / 100;\n\n if (newScale !== this.state.scale) {\n this.setState({\n scale: parseFloat(zoomParsed) / 100,\n });\n }\n } else if (!zoomParsed && this.state.scale !== 1) {\n this.setState({\n scale: 1,\n });\n }\n });\n });\n\n const target = document.getElementById('question-container');\n\n if (target) {\n this.observer.observe(target, { attributes: true, attributeFilter: ['style'] });\n }\n }\n\n componentWillUnmount() {\n this.observer?.disconnect();\n }\n\n onToggle = () => {\n const { showCorrect } = this.state;\n this.setState({ showCorrect: !showCorrect });\n };\n\n render() {\n const {\n session,\n model: {\n disabled,\n imageUrl,\n prompt,\n mode,\n multipleCorrect,\n shapes,\n outlineColor,\n hotspotColor,\n dimensions,\n rationale,\n teacherInstructions,\n strokeWidth,\n responseCorrect,\n },\n onSelectChoice,\n classes,\n } = this.props;\n const { showCorrect } = this.state;\n const isEvaluateMode = mode === 'evaluate';\n const showCorrectAnswerToggle = isEvaluateMode && !responseCorrect;\n\n return (\n <div className={classes.main}>\n {teacherInstructions && hasText(teacherInstructions) && (\n <Collapsible\n labels={{ hidden: 'Show Teacher Instructions', visible: 'Hide Teacher Instructions' }}\n className={classes.collapsible}\n >\n <PreviewPrompt className=\"prompt\" prompt={teacherInstructions} />\n </Collapsible>\n )}\n\n {prompt && <PreviewPrompt className=\"prompt\" prompt={prompt} />}\n\n {showCorrectAnswerToggle && (\n <CorrectAnswerToggle\n show={showCorrectAnswerToggle}\n toggled={showCorrect}\n onToggle={this.onToggle.bind(this)}\n />\n )}\n\n {imageUrl ? (\n <Container\n isEvaluateMode={isEvaluateMode}\n session={session}\n dimensions={dimensions}\n imageUrl={imageUrl}\n hotspotColor={hotspotColor}\n multipleCorrect={multipleCorrect}\n outlineColor={outlineColor}\n onSelectChoice={onSelectChoice}\n shapes={shapes}\n disabled={disabled}\n strokeWidth={strokeWidth}\n scale={this.state.scale}\n showCorrect={showCorrect}\n />\n ) : null}\n\n {rationale && hasText(rationale) && (\n <Collapsible labels={{ hidden: 'Show Rationale', visible: 'Hide Rationale' }}>\n <PreviewPrompt className=\"prompt\" prompt={rationale} />\n </Collapsible>\n )}\n </div>\n );\n }\n}\n\nHotspotComponent.propTypes = {\n classes: PropTypes.object,\n model: PropTypes.object.isRequired,\n onSelectChoice: PropTypes.func.isRequired,\n session: PropTypes.object.isRequired,\n};\n\nHotspotComponent.defaultProps = {\n classes: {},\n};\n\nconst styles = (theme) => ({\n main: {\n color: color.text(),\n backgroundColor: color.background(),\n },\n collapsible: {\n marginBottom: theme.spacing.unit * 2,\n },\n prompt: {\n fontSize: 'inherit',\n },\n});\n\nexport default withStyles(styles)(HotspotComponent);\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/hotspot/index.jsx"],"names":["HotspotComponent","props","showCorrect","state","setState","observer","scale","MutationObserver","mutations","forEach","target","document","getElementById","style","cssText","zoom","substring","indexOf","lastIndexOf","zoomParsed","replace","newScale","parseFloat","observe","attributes","attributeFilter","disconnect","session","model","disabled","imageUrl","prompt","mode","multipleCorrect","shapes","outlineColor","hotspotColor","dimensions","rationale","teacherInstructions","strokeWidth","responseCorrect","language","onSelectChoice","classes","isEvaluateMode","showCorrectAnswerToggle","main","hidden","visible","collapsible","onToggle","bind","React","Component","propTypes","PropTypes","object","isRequired","func","defaultProps","styles","theme","color","text","backgroundColor","background","marginBottom","spacing","unit","fontSize"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;IAEMA,gB;;;;;AACJ,4BAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AADiB,iGA2CR,YAAM;AACf,UAAQC,WAAR,GAAwB,MAAKC,KAA7B,CAAQD,WAAR;;AACA,YAAKE,QAAL,CAAc;AAAEF,QAAAA,WAAW,EAAE,CAACA;AAAhB,OAAd;AACD,KA9CkB;AAEjB,UAAKC,KAAL,GAAa;AACXD,MAAAA,WAAW,EAAE,KADF;AAEXG,MAAAA,QAAQ,EAAE,IAFC;AAGXC,MAAAA,KAAK,EAAE;AAHI,KAAb;AAFiB;AAOlB;;;;WAED,6BAAoB;AAAA;;AAClB,WAAKD,QAAL,GAAgB,IAAIE,gBAAJ,CAAqB,UAACC,SAAD,EAAe;AAClDA,QAAAA,SAAS,CAACC,OAAV,CAAkB,YAAM;AAAA;;AACtB,cAAMC,MAAM,4BAAGC,QAAQ,CAACC,cAAT,CAAwB,oBAAxB,CAAH,oFAAG,sBAA+CC,KAAlD,2DAAG,u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B,EAAAA,OAAO,EAAE;AADqB,CAAhC;;AAIA,IAAMiB,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBf,IAAAA,IAAI,EAAE;AACJgB,MAAAA,KAAK,EAAEA,gBAAMC,IAAN,EADH;AAEJC,MAAAA,eAAe,EAAEF,gBAAMG,UAAN;AAFb,KADmB;AAKzBhB,IAAAA,WAAW,EAAE;AACXiB,MAAAA,YAAY,EAAEL,KAAK,CAACM,OAAN,CAAcC,IAAd,GAAqB;AADxB,KALY;AAQzBtC,IAAAA,MAAM,EAAE;AACNuC,MAAAA,QAAQ,EAAE;AADJ;AARiB,GAAZ;AAAA,CAAf;;eAae,wBAAWT,MAAX,EAAmB7D,gBAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport CorrectAnswerToggle from '@pie-lib/correct-answer-toggle';\nimport { color, Collapsible, hasText, PreviewPrompt } from '@pie-lib/render-ui';\nimport { withStyles } from '@material-ui/core/styles';\n\nimport Container from './container';\n\nclass HotspotComponent extends React.Component {\n constructor(props) {\n super(props);\n this.state = {\n showCorrect: false,\n observer: null,\n scale: 1,\n };\n }\n\n componentDidMount() {\n this.observer = new MutationObserver((mutations) => {\n mutations.forEach(() => {\n const target = document.getElementById('question-container')?.style?.cssText;\n const zoom = target?.substring(target.indexOf('--pie-zoom') + 11, target.lastIndexOf('%'));\n const zoomParsed = zoom?.replace(/\\s/g, '');\n\n if (zoomParsed) {\n const newScale = parseFloat(zoomParsed) / 100;\n\n if (newScale !== this.state.scale) {\n this.setState({\n scale: parseFloat(zoomParsed) / 100,\n });\n }\n } else if (!zoomParsed && this.state.scale !== 1) {\n this.setState({\n scale: 1,\n });\n }\n });\n });\n\n const target = document.getElementById('question-container');\n\n if (target) {\n this.observer.observe(target, { attributes: true, attributeFilter: ['style'] });\n }\n }\n\n componentWillUnmount() {\n this.observer?.disconnect();\n }\n\n onToggle = () => {\n const { showCorrect } = this.state;\n this.setState({ showCorrect: !showCorrect });\n };\n\n render() {\n const {\n session,\n model: {\n disabled,\n imageUrl,\n prompt,\n mode,\n multipleCorrect,\n shapes,\n outlineColor,\n hotspotColor,\n dimensions,\n rationale,\n teacherInstructions,\n strokeWidth,\n responseCorrect,\n language,\n },\n onSelectChoice,\n classes,\n } = this.props;\n const { showCorrect } = this.state;\n const isEvaluateMode = mode === 'evaluate';\n const showCorrectAnswerToggle = isEvaluateMode && !responseCorrect;\n\n return (\n <div className={classes.main}>\n {teacherInstructions && hasText(teacherInstructions) && (\n <Collapsible\n labels={{ hidden: 'Show Teacher Instructions', visible: 'Hide Teacher Instructions' }}\n className={classes.collapsible}\n >\n <PreviewPrompt className=\"prompt\" prompt={teacherInstructions} />\n </Collapsible>\n )}\n\n {prompt && <PreviewPrompt className=\"prompt\" prompt={prompt} />}\n\n {showCorrectAnswerToggle && (\n <CorrectAnswerToggle\n show={showCorrectAnswerToggle}\n toggled={showCorrect}\n onToggle={this.onToggle.bind(this)}\n language={language}\n />\n )}\n\n {imageUrl ? (\n <Container\n isEvaluateMode={isEvaluateMode}\n session={session}\n dimensions={dimensions}\n imageUrl={imageUrl}\n hotspotColor={hotspotColor}\n multipleCorrect={multipleCorrect}\n outlineColor={outlineColor}\n onSelectChoice={onSelectChoice}\n shapes={shapes}\n disabled={disabled}\n strokeWidth={strokeWidth}\n scale={this.state.scale}\n showCorrect={showCorrect}\n />\n ) : null}\n\n {rationale && hasText(rationale) && (\n <Collapsible labels={{ hidden: 'Show Rationale', visible: 'Hide Rationale' }}>\n <PreviewPrompt className=\"prompt\" prompt={rationale} />\n </Collapsible>\n )}\n </div>\n );\n }\n}\n\nHotspotComponent.propTypes = {\n classes: PropTypes.object,\n model: PropTypes.object.isRequired,\n onSelectChoice: PropTypes.func.isRequired,\n session: PropTypes.object.isRequired,\n};\n\nHotspotComponent.defaultProps = {\n classes: {},\n};\n\nconst styles = (theme) => ({\n main: {\n color: color.text(),\n backgroundColor: color.background(),\n },\n collapsible: {\n marginBottom: theme.spacing.unit * 2,\n },\n prompt: {\n fontSize: 'inherit',\n },\n});\n\nexport default withStyles(styles)(HotspotComponent);\n"],"file":"index.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/hotspot",
3
- "version": "5.14.6-next.8+17e168dd0",
3
+ "version": "5.15.1-next.6+516922dd4",
4
4
  "description": "",
5
5
  "repository": "pie-framework/pie-elements",
6
6
  "publishConfig": {
@@ -13,6 +13,7 @@
13
13
  "@pie-lib/math-rendering": "^2.5.17",
14
14
  "@pie-lib/render-ui": "^4.15.1",
15
15
  "@pie-lib/test-utils": "^0.2.33",
16
+ "@pie-lib/translator": "^2.2.0",
16
17
  "konva": "^3.2.5",
17
18
  "prop-types": "^15.6.1",
18
19
  "react": "^16.8.1",
@@ -21,7 +22,7 @@
21
22
  },
22
23
  "author": "pie framework developers",
23
24
  "license": "ISC",
24
- "gitHead": "17e168dd001a82a9c24deaf1c6a4c1f21a51ab03",
25
+ "gitHead": "516922dd4bda626da213aaa2c2ea0fde17acedc0",
25
26
  "scripts": {
26
27
  "postpublish": "../../scripts/postpublish"
27
28
  },
@@ -72,6 +72,7 @@ class HotspotComponent extends React.Component {
72
72
  teacherInstructions,
73
73
  strokeWidth,
74
74
  responseCorrect,
75
+ language,
75
76
  },
76
77
  onSelectChoice,
77
78
  classes,
@@ -98,6 +99,7 @@ class HotspotComponent extends React.Component {
98
99
  show={showCorrectAnswerToggle}
99
100
  toggled={showCorrect}
100
101
  onToggle={this.onToggle.bind(this)}
102
+ language={language}
101
103
  />
102
104
  )}
103
105