@pie-element/hotspot 5.4.3-next.5 → 5.4.3-next.54

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.
Files changed (64) hide show
  1. package/configure/lib/button.js.map +1 -1
  2. package/configure/lib/defaults.js.map +1 -1
  3. package/configure/lib/hotspot-container.js.map +1 -1
  4. package/configure/lib/hotspot-drawable.js.map +1 -1
  5. package/configure/lib/hotspot-palette.js.map +1 -1
  6. package/configure/lib/hotspot-polygon.js.map +1 -1
  7. package/configure/lib/hotspot-rectangle.js.map +1 -1
  8. package/configure/lib/index.js.map +1 -1
  9. package/configure/lib/root.js +1 -1
  10. package/configure/lib/root.js.map +1 -1
  11. package/configure/lib/upload-control.js.map +1 -1
  12. package/configure/lib/utils.js.map +1 -1
  13. package/configure/package.json +2 -2
  14. package/configure/src/__tests__/hotspot-container.test.js +98 -71
  15. package/configure/src/__tests__/hotspot-drawable.test.js +48 -49
  16. package/configure/src/__tests__/index.test.js +28 -51
  17. package/configure/src/__tests__/root.test.js +162 -82
  18. package/configure/src/__tests__/utils.test.js +112 -98
  19. package/configure/src/button.jsx +4 -4
  20. package/configure/src/defaults.js +16 -20
  21. package/configure/src/hotspot-container.jsx +72 -89
  22. package/configure/src/hotspot-drawable.jsx +55 -55
  23. package/configure/src/hotspot-palette.jsx +12 -25
  24. package/configure/src/hotspot-polygon.jsx +20 -22
  25. package/configure/src/hotspot-rectangle.jsx +5 -15
  26. package/configure/src/index.js +20 -20
  27. package/configure/src/root.jsx +38 -67
  28. package/configure/src/upload-control.jsx +9 -20
  29. package/configure/src/utils.js +35 -28
  30. package/controller/lib/defaults.js.map +1 -1
  31. package/controller/lib/index.js.map +1 -1
  32. package/controller/lib/utils.js.map +1 -1
  33. package/controller/package.json +1 -1
  34. package/controller/src/__tests__/index.test.js +29 -50
  35. package/controller/src/defaults.js +4 -8
  36. package/controller/src/index.js +22 -34
  37. package/controller/src/utils.js +9 -6
  38. package/docs/config-schema.json.md +1 -1
  39. package/docs/demo/config.js +2 -2
  40. package/docs/demo/generate.js +49 -37
  41. package/docs/demo/session.js +2 -2
  42. package/docs/pie-schema.json.md +1 -1
  43. package/lib/hotspot/container.js.map +1 -1
  44. package/lib/hotspot/icons.js.map +1 -1
  45. package/lib/hotspot/image.js.map +1 -1
  46. package/lib/hotspot/index.js.map +1 -1
  47. package/lib/hotspot/polygon.js.map +1 -1
  48. package/lib/hotspot/rectangle.js.map +1 -1
  49. package/lib/index.js.map +1 -1
  50. package/lib/session-updater.js.map +1 -1
  51. package/package.json +6 -6
  52. package/src/__tests__/container.test.jsx +57 -43
  53. package/src/__tests__/image.test.jsx +2 -2
  54. package/src/__tests__/polygon.test.jsx +31 -20
  55. package/src/__tests__/rectangle.test.jsx +22 -18
  56. package/src/__tests__/session-updater.test.jsx +22 -31
  57. package/src/hotspot/container.jsx +20 -23
  58. package/src/hotspot/icons.js +4 -2
  59. package/src/hotspot/image.jsx +4 -8
  60. package/src/hotspot/index.jsx +27 -47
  61. package/src/hotspot/polygon.jsx +13 -18
  62. package/src/hotspot/rectangle.jsx +11 -16
  63. package/src/index.js +5 -18
  64. package/src/session-updater.js +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["log","normalize","question","promptEnabled","rationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","strokeWidth","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","teacherInstructions","createDefaultModel","defaults","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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AAEA,MAAIyB,UAAU,GAAGV,SAAjB,EAA4B;AAC1BG,IAAAA,MAAM,CAACQ,WAAP,sCAAiDX,SAAjD;AACD,GAFD,MAEO,IAAIU,UAAU,GAAGT,SAAjB,EAA4B;AACjCE,IAAAA,MAAM,CAACQ,WAAP,0BAAqCV,SAArC;AACD;;AAED,MAAIQ,cAAc,GAAG,CAArB,EAAwB;AACtBN,IAAAA,MAAM,CAACS,eAAP,GAAyB,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 promptEnabled: true,\n rationaleEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n strokeWidth: 5,\n ...question,\n});\n\nexport function model(question, session, env) {\n const normalizedQuestion = normalize(question);\n const {\n imageUrl,\n dimensions,\n hotspotColor,\n multipleCorrect,\n outlineColor,\n partialScoring,\n prompt,\n 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:\n env.mode === 'evaluate'\n ? isResponseCorrect(normalizedQuestion, session)\n : 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 ? normalizedQuestion.teacherInstructions : 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: [\n ...rectangleCorrect,\n ...polygonsCorrect\n ],\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","promptEnabled","rationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","strokeWidth","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","teacherInstructions","createDefaultModel","defaults","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;AACvBC,IAAAA,aAAa,EAAE,IADQ;AAEvBC,IAAAA,gBAAgB,EAAE,IAFK;AAGvBC,IAAAA,0BAA0B,EAAE,IAHL;AAIvBC,IAAAA,0BAA0B,EAAE,IAJL;AAKvBC,IAAAA,WAAW,EAAE;AALU,KAMpBL,QANoB;AAAA,CAAlB;;;;AASA,SAASM,KAAT,CAAeN,QAAf,EAAyBO,OAAzB,EAAkCC,GAAlC,EAAuC;AAC5C,MAAMC,kBAAkB,GAAGV,SAAS,CAACC,QAAD,CAApC;AACA,MAAQU,QAAR,GACED,kBADF,CAAQC,QAAR;AAAA,MAAkBC,UAAlB,GACEF,kBADF,CAAkBE,UAAlB;AAAA,MAA8BC,YAA9B,GACEH,kBADF,CAA8BG,YAA9B;AAAA,MAA4CC,eAA5C,GACEJ,kBADF,CAA4CI,eAA5C;AAAA,MAA6DC,YAA7D,GACEL,kBADF,CAA6DK,YAA7D;AAAA,MAA2EC,cAA3E,GACEN,kBADF,CAA2EM,cAA3E;AAAA,MAA2FC,MAA3F,GACEP,kBADF,CAA2FO,MAA3F;AAAA,MAAmGC,MAAnG,GACER,kBADF,CAAmGQ,MAAnG;;AAEA,aAAiCA,MAAM,IAAI,EAA3C;AAAA,MAAQC,UAAR,QAAQA,UAAR;AAAA,MAAoBC,QAApB,QAAoBA,QAApB;;AAEA,SAAO,IAAIC,OAAJ,CAAY,UAACC,OAAD,EAAa;AAC9B,QAAMC,GAAG,GAAG;AACVC,MAAAA,QAAQ,EAAEf,GAAG,CAACgB,IAAJ,KAA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AAzB,EAA0E,CAA1E,CAAvB;AAEA,MAAME,UAAU,GAAG,CAACN,SAAS,IAAI,EAAd,EAAkBnB,MAArC;;AAEA,MAAIyB,UAAU,GAAGV,SAAjB,EAA4B;AAC1BG,IAAAA,MAAM,CAACQ,WAAP,sCAAiDX,SAAjD;AACD,GAFD,MAEO,IAAIU,UAAU,GAAGT,SAAjB,EAA4B;AACjCE,IAAAA,MAAM,CAACQ,WAAP,0BAAqCV,SAArC;AACD;;AAED,MAAIQ,cAAc,GAAG,CAArB,EAAwB;AACtBN,IAAAA,MAAM,CAACS,eAAP,GAAyB,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 promptEnabled: true,\n rationaleEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n strokeWidth: 5,\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 +1 @@
1
- {"version":3,"sources":["../src/utils.js"],"names":["getCorrectResponse","choices","filter","c","correct","map","id","sort","isResponseCorrect","question","session","shapes","rectangles","polygons","correctResponseIds","answers","length","answerIds","a"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAEO,IAAMA,kBAAkB,GAAG,SAArBA,kBAAqB,CAACC,OAAD;AAAA,SAAaA,OAAO,CACnDC,MAD4C,CACrC,UAAAC,CAAC;AAAA,WAAIA,CAAC,CAACC,OAAN;AAAA,GADoC,EAE5CC,GAF4C,CAExC,UAAAF,CAAC;AAAA,WAAIA,CAAC,CAACG,EAAN;AAAA,GAFuC,EAG5CC,IAH4C,EAAb;AAAA,CAA3B;;;;AAKA,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,QAAD,EAAWC,OAAX,EAAuB;AACtD,yBAA6CD,QAA7C,CAAQE,MAAR;AAAA,MAAkBC,UAAlB,oBAAkBA,UAAlB;AAAA,MAA8BC,QAA9B,oBAA8BA,QAA9B;AACA,MAAMZ,OAAO,iDAAOW,UAAP,uCAAsBC,QAAtB,EAAb;AACA,MAAIC,kBAAkB,GAAGd,kBAAkB,CAACC,OAAD,CAA3C;;AAEA,MAAI,CAACS,OAAD,IAAY,yBAAQA,OAAR,CAAhB,EAAkC;AAChC,WAAO,KAAP;AACD;;AAED,MAAIA,OAAO,CAACK,OAAR,IAAmBL,OAAO,CAACK,OAAR,CAAgBC,MAAvC,EAA+C;AAC7C,QAAIC,SAAS,GAAG,CAACP,OAAO,CAACK,OAAR,IAAmB,EAApB,EAAwBV,GAAxB,CAA4B,UAAAa,CAAC;AAAA,aAAIA,CAAC,CAACZ,EAAN;AAAA,KAA7B,CAAhB;AAEA,WAAO,yBAAQW,SAAS,CAACV,IAAV,EAAR,EAA0BO,kBAA1B,CAAP;AACD,GAJD,MAIO,IAAI,EAAEA,kBAAkB,IAAIA,kBAAkB,CAACE,MAA3C,CAAJ,EAAwD;AAC7D,WAAO,IAAP;AACD;;AAED,SAAO,KAAP;AACD,CAlBM","sourcesContent":["import isEqual from 'lodash/isEqual';\nimport isEmpty from 'lodash/isEmpty';\n\nexport const getCorrectResponse = (choices) => choices\n .filter(c => c.correct)\n .map(c => c.id)\n .sort();\n\nexport const isResponseCorrect = (question, session) => {\n const { shapes: { rectangles, polygons } } = question;\n const choices = [...rectangles, ...polygons];\n let correctResponseIds = getCorrectResponse(choices);\n\n if (!session || isEmpty(session)) {\n return false;\n }\n\n if (session.answers && session.answers.length) {\n let answerIds = (session.answers || []).map(a => a.id);\n\n return isEqual(answerIds.sort(), correctResponseIds);\n } else if (!(correctResponseIds && correctResponseIds.length)) {\n return true;\n }\n\n return false;\n};\n"],"file":"utils.js"}
1
+ {"version":3,"sources":["../src/utils.js"],"names":["getCorrectResponse","choices","filter","c","correct","map","id","sort","isResponseCorrect","question","session","shapes","rectangles","polygons","correctResponseIds","answers","length","answerIds","a"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAEO,IAAMA,kBAAkB,GAAG,SAArBA,kBAAqB,CAACC,OAAD;AAAA,SAChCA,OAAO,CACJC,MADH,CACU,UAACC,CAAD;AAAA,WAAOA,CAAC,CAACC,OAAT;AAAA,GADV,EAEGC,GAFH,CAEO,UAACF,CAAD;AAAA,WAAOA,CAAC,CAACG,EAAT;AAAA,GAFP,EAGGC,IAHH,EADgC;AAAA,CAA3B;;;;AAMA,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,QAAD,EAAWC,OAAX,EAAuB;AACtD,yBAEID,QAFJ,CACEE,MADF;AAAA,MACYC,UADZ,oBACYA,UADZ;AAAA,MACwBC,QADxB,oBACwBA,QADxB;AAGA,MAAMZ,OAAO,iDAAOW,UAAP,uCAAsBC,QAAtB,EAAb;AACA,MAAIC,kBAAkB,GAAGd,kBAAkB,CAACC,OAAD,CAA3C;;AAEA,MAAI,CAACS,OAAD,IAAY,yBAAQA,OAAR,CAAhB,EAAkC;AAChC,WAAO,KAAP;AACD;;AAED,MAAIA,OAAO,CAACK,OAAR,IAAmBL,OAAO,CAACK,OAAR,CAAgBC,MAAvC,EAA+C;AAC7C,QAAIC,SAAS,GAAG,CAACP,OAAO,CAACK,OAAR,IAAmB,EAApB,EAAwBV,GAAxB,CAA4B,UAACa,CAAD;AAAA,aAAOA,CAAC,CAACZ,EAAT;AAAA,KAA5B,CAAhB;AAEA,WAAO,yBAAQW,SAAS,CAACV,IAAV,EAAR,EAA0BO,kBAA1B,CAAP;AACD,GAJD,MAIO,IAAI,EAAEA,kBAAkB,IAAIA,kBAAkB,CAACE,MAA3C,CAAJ,EAAwD;AAC7D,WAAO,IAAP;AACD;;AAED,SAAO,KAAP;AACD,CApBM","sourcesContent":["import isEqual from 'lodash/isEqual';\nimport isEmpty from 'lodash/isEmpty';\n\nexport const getCorrectResponse = (choices) =>\n choices\n .filter((c) => c.correct)\n .map((c) => c.id)\n .sort();\n\nexport const isResponseCorrect = (question, session) => {\n const {\n shapes: { rectangles, polygons },\n } = question;\n const choices = [...rectangles, ...polygons];\n let correctResponseIds = getCorrectResponse(choices);\n\n if (!session || isEmpty(session)) {\n return false;\n }\n\n if (session.answers && session.answers.length) {\n let answerIds = (session.answers || []).map((a) => a.id);\n\n return isEqual(answerIds.sort(), correctResponseIds);\n } else if (!(correctResponseIds && correctResponseIds.length)) {\n return true;\n }\n\n return false;\n};\n"],"file":"utils.js"}
@@ -11,7 +11,7 @@
11
11
  "main": "lib/index.js",
12
12
  "module": "src/index.js",
13
13
  "dependencies": {
14
- "@pie-lib/controller-utils": "^0.2.26",
14
+ "@pie-lib/controller-utils": "^0.2.27",
15
15
  "debug": "^4.1.1",
16
16
  "lodash": "^4.17.15"
17
17
  }
@@ -41,20 +41,17 @@ describe('controller', () => {
41
41
  });
42
42
 
43
43
  describe('outcome partialScoring test', () => {
44
-
45
- describe('hanging controller', ()=> {
46
-
44
+ describe('hanging controller', () => {
47
45
  it('doesnt hang if answers is missing', async () => {
48
- const response = await outcome({}, {id: "1"}, {});
49
- expect(response).toEqual({score: 0, empty: true});
46
+ const response = await outcome({}, { id: '1' }, {});
47
+ expect(response).toEqual({ score: 0, empty: true });
50
48
  });
51
49
 
52
50
  it('doesnt hang if the rest is missing', async () => {
53
- const response = await outcome({}, {id: "1", answers: {}}, {});
54
- expect(response).toEqual({score: 0 });
51
+ const response = await outcome({}, { id: '1', answers: {} }, {});
52
+ expect(response).toEqual({ score: 0 });
55
53
  });
56
-
57
- })
54
+ });
58
55
 
59
56
  beforeEach(() => {
60
57
  const rectangles = question.shapes.rectangles.concat({
@@ -72,11 +69,7 @@ describe('controller', () => {
72
69
 
73
70
  const assertOutcome = (message, extra, sessionValue, env, expected) => {
74
71
  it(message, async () => {
75
- const result = await outcome(
76
- { ...question, ...extra },
77
- sessionValue,
78
- env
79
- );
72
+ const result = await outcome({ ...question, ...extra }, sessionValue, env);
80
73
  expect(result).toEqual(expect.objectContaining(expected));
81
74
  });
82
75
  };
@@ -86,7 +79,7 @@ describe('controller', () => {
86
79
  { partialScoring: true },
87
80
  { answers: [{ id: '2' }] },
88
81
  { mode: 'evaluate' },
89
- { score: 0 }
82
+ { score: 0 },
90
83
  );
91
84
 
92
85
  assertOutcome(
@@ -94,7 +87,7 @@ describe('controller', () => {
94
87
  { partialScoring: false },
95
88
  { answers: [{ id: '2' }] },
96
89
  { mode: 'evaluate' },
97
- { score: 0 }
90
+ { score: 0 },
98
91
  );
99
92
 
100
93
  assertOutcome(
@@ -102,7 +95,7 @@ describe('controller', () => {
102
95
  { partialScoring: false },
103
96
  { answers: [{ id: '2' }] },
104
97
  { mode: 'evaluate', partialScoring: true },
105
- { score: 0 }
98
+ { score: 0 },
106
99
  );
107
100
 
108
101
  assertOutcome(
@@ -110,7 +103,7 @@ describe('controller', () => {
110
103
  { partialScoring: true },
111
104
  { answers: [{ id: '2' }] },
112
105
  { mode: 'evaluate', partialScoring: false },
113
- { score: 0 }
106
+ { score: 0 },
114
107
  );
115
108
  });
116
109
 
@@ -136,13 +129,16 @@ describe('controller', () => {
136
129
 
137
130
  describe('partial scoring', () => {
138
131
  beforeEach(() => {
139
- const rectangles = question.shapes.rectangles.concat({
140
- id: '5',
141
- correct: true,
142
- }, {
143
- id: '6',
144
- correct: true,
145
- });
132
+ const rectangles = question.shapes.rectangles.concat(
133
+ {
134
+ id: '5',
135
+ correct: true,
136
+ },
137
+ {
138
+ id: '6',
139
+ correct: true,
140
+ },
141
+ );
146
142
  question = {
147
143
  ...question,
148
144
  partialScoring: true,
@@ -172,13 +168,12 @@ describe('controller', () => {
172
168
  });
173
169
 
174
170
  it('returns a score of 0.5 for 2/4 correct answers and 0 incorrect answers', async () => {
175
- const result = await outcome(question, { answers: [{ id: '5' }, { id: '4'}] });
171
+ const result = await outcome(question, { answers: [{ id: '5' }, { id: '4' }] });
176
172
  expect(result.score).toEqual(0.5);
177
173
  });
178
174
 
179
-
180
175
  it('returns a score of 0.75 for 3/4 correct answers and 0 incorrect answers', async () => {
181
- const result = await outcome(question, { answers: [{ id: '1' }, { id: '5' }, { id: '4'}] });
176
+ const result = await outcome(question, { answers: [{ id: '1' }, { id: '5' }, { id: '4' }] });
182
177
  expect(result.score).toEqual(0.75);
183
178
  });
184
179
 
@@ -247,9 +242,7 @@ describe('controller', () => {
247
242
  });
248
243
 
249
244
  const returnOutcome = (session) => {
250
- it(`returns empty: true when session is ${JSON.stringify(
251
- session
252
- )}`, async () => {
245
+ it(`returns empty: true when session is ${JSON.stringify(session)}`, async () => {
253
246
  const result = await outcome(question, session);
254
247
  expect(result).toEqual({ score: 0, empty: true });
255
248
  });
@@ -298,15 +291,9 @@ describe('controller', () => {
298
291
 
299
292
  it('returns shapes', () => {
300
293
  expect(result.shapes.rectangles).toEqual(
301
- expect.arrayContaining([
302
- { id: '1', correct: true },
303
- { id: '2' },
304
- { id: '3' },
305
- ])
306
- );
307
- expect(result.shapes.polygons).toEqual(
308
- expect.arrayContaining([{ id: '4', correct: true }])
294
+ expect.arrayContaining([{ id: '1', correct: true }, { id: '2' }, { id: '3' }]),
309
295
  );
296
+ expect(result.shapes.polygons).toEqual(expect.arrayContaining([{ id: '4', correct: true }]));
310
297
  });
311
298
 
312
299
  it('does not return responseCorrect', () => {
@@ -336,15 +323,9 @@ describe('controller', () => {
336
323
 
337
324
  it('returns choices w/ correct', () => {
338
325
  expect(result.shapes.rectangles).toEqual(
339
- expect.arrayContaining([
340
- { id: '1', correct: true },
341
- { id: '2' },
342
- { id: '3' },
343
- ])
344
- );
345
- expect(result.shapes.polygons).toEqual(
346
- expect.arrayContaining([{ id: '4', correct: true }])
326
+ expect.arrayContaining([{ id: '1', correct: true }, { id: '2' }, { id: '3' }]),
347
327
  );
328
+ expect(result.shapes.polygons).toEqual(expect.arrayContaining([{ id: '4', correct: true }]));
348
329
  });
349
330
 
350
331
  it('returns is response correct', () => {
@@ -355,9 +336,7 @@ describe('controller', () => {
355
336
 
356
337
  describe('isResponseCorrect', () => {
357
338
  const returnIsResponseCorect = (session) => {
358
- it(`response is not correct if session is ${JSON.stringify(
359
- session
360
- )}`, () => {
339
+ it(`response is not correct if session is ${JSON.stringify(session)}`, () => {
361
340
  expect(isResponseCorrect(question, session)).toEqual(false);
362
341
  });
363
342
  };
@@ -3,20 +3,16 @@ export default {
3
3
  imageUrl: '',
4
4
  shapes: {
5
5
  rectangles: [],
6
- polygons: []
6
+ polygons: [],
7
7
  },
8
8
  multipleCorrect: true,
9
9
  partialScoring: false,
10
10
  dimensions: {
11
11
  height: 0,
12
- width: 0
12
+ width: 0,
13
13
  },
14
14
  hotspotColor: 'rgba(137, 183, 244, 0.65)',
15
- hotspotList: [
16
- 'rgba(137, 183, 244, 0.65)'
17
- ],
15
+ hotspotList: ['rgba(137, 183, 244, 0.65)'],
18
16
  outlineColor: 'blue',
19
- outlineList: [
20
- 'blue'
21
- ]
17
+ outlineList: ['blue'],
22
18
  };
@@ -8,7 +8,7 @@ import defaults from './defaults';
8
8
 
9
9
  const log = debug('pie-elements:hotspot:controller');
10
10
 
11
- export const normalize = question => ({
11
+ export const normalize = (question) => ({
12
12
  promptEnabled: true,
13
13
  rationaleEnabled: true,
14
14
  teacherInstructionsEnabled: true,
@@ -19,19 +19,11 @@ export const normalize = question => ({
19
19
 
20
20
  export function model(question, session, env) {
21
21
  const normalizedQuestion = normalize(question);
22
- const {
23
- imageUrl,
24
- dimensions,
25
- hotspotColor,
26
- multipleCorrect,
27
- outlineColor,
28
- partialScoring,
29
- prompt,
30
- shapes
31
- } = normalizedQuestion;
22
+ const { imageUrl, dimensions, hotspotColor, multipleCorrect, outlineColor, partialScoring, prompt, shapes } =
23
+ normalizedQuestion;
32
24
  const { rectangles, polygons } = shapes || {};
33
25
 
34
- return new Promise(resolve => {
26
+ return new Promise((resolve) => {
35
27
  const out = {
36
28
  disabled: env.mode !== 'gather',
37
29
  mode: env.mode,
@@ -46,17 +38,16 @@ export function model(question, session, env) {
46
38
  // eslint-disable-next-line no-unused-vars
47
39
  rectangles: (rectangles || []).map(({ index, ...rectProps }) => ({ ...rectProps })),
48
40
  // eslint-disable-next-line no-unused-vars
49
- polygons: (polygons || []).map(({ index, ...polyProps }) => ({ ...polyProps }))
41
+ polygons: (polygons || []).map(({ index, ...polyProps }) => ({ ...polyProps })),
50
42
  },
51
- responseCorrect:
52
- env.mode === 'evaluate'
53
- ? isResponseCorrect(normalizedQuestion, session)
54
- : undefined
43
+ responseCorrect: env.mode === 'evaluate' ? isResponseCorrect(normalizedQuestion, session) : undefined,
55
44
  };
56
45
 
57
46
  if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {
58
47
  out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;
59
- out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled ? normalizedQuestion.teacherInstructions : null;
48
+ out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled
49
+ ? normalizedQuestion.teacherInstructions
50
+ : null;
60
51
  } else {
61
52
  out.rationale = null;
62
53
  out.teacherInstructions = null;
@@ -71,7 +62,7 @@ export function model(question, session, env) {
71
62
  }
72
63
 
73
64
  export const createDefaultModel = (model = {}) =>
74
- new Promise(resolve => {
65
+ new Promise((resolve) => {
75
66
  resolve({
76
67
  ...defaults,
77
68
  ...model,
@@ -97,14 +88,14 @@ const getScore = (config, session, env = {}) => {
97
88
 
98
89
  const choices = [...rectangles, ...polygons];
99
90
 
100
- const correctChoices = choices.filter(choice => choice.correct);
91
+ const correctChoices = choices.filter((choice) => choice.correct);
101
92
 
102
- choices.forEach(shape => {
103
- const selected = answers && answers.filter(answer => answer.id === shape.id)[0];
93
+ choices.forEach((shape) => {
94
+ const selected = answers && answers.filter((answer) => answer.id === shape.id)[0];
104
95
  const correctlySelected = shape.correct && selected;
105
96
 
106
- if(selected) {
107
- selectedChoices +=1;
97
+ if (selected) {
98
+ selectedChoices += 1;
108
99
  }
109
100
 
110
101
  if (correctlySelected) {
@@ -121,7 +112,7 @@ const getScore = (config, session, env = {}) => {
121
112
  };
122
113
 
123
114
  export function outcome(config, session, env = {}) {
124
- return new Promise(resolve => {
115
+ return new Promise((resolve) => {
125
116
  log('outcome...');
126
117
 
127
118
  if (!session || isEmpty(session)) {
@@ -132,7 +123,7 @@ export function outcome(config, session, env = {}) {
132
123
  const score = getScore(config, session, env);
133
124
  resolve({ score });
134
125
  } else {
135
- resolve({score: 0, empty: true})
126
+ resolve({ score: 0, empty: true });
136
127
  }
137
128
  });
138
129
  }
@@ -140,7 +131,7 @@ export function outcome(config, session, env = {}) {
140
131
  const returnShapesCorrect = (shapes) => {
141
132
  let answers = [];
142
133
 
143
- shapes.forEach(i => {
134
+ shapes.forEach((i) => {
144
135
  const { correct, id } = i;
145
136
  if (correct) {
146
137
  answers.push({ id });
@@ -150,7 +141,7 @@ const returnShapesCorrect = (shapes) => {
150
141
  };
151
142
 
152
143
  export const createCorrectResponseSession = (question, env) => {
153
- return new Promise(resolve => {
144
+ return new Promise((resolve) => {
154
145
  if (env.mode !== 'evaluate' && env.role === 'instructor') {
155
146
  const { shapes: { rectangles = [], polygons = {} } = {} } = question;
156
147
 
@@ -158,11 +149,8 @@ export const createCorrectResponseSession = (question, env) => {
158
149
  const polygonsCorrect = returnShapesCorrect(polygons);
159
150
 
160
151
  resolve({
161
- answers: [
162
- ...rectangleCorrect,
163
- ...polygonsCorrect
164
- ],
165
- id: '1'
152
+ answers: [...rectangleCorrect, ...polygonsCorrect],
153
+ id: '1',
166
154
  });
167
155
  } else {
168
156
  resolve(null);
@@ -177,7 +165,7 @@ export const validate = (model = {}, config = {}) => {
177
165
 
178
166
  const allShapes = Object.values(shapes || {}).reduce((acc, shape) => [...acc, ...shape], []);
179
167
 
180
- const nbOfSelections = (allShapes || []).reduce((acc, shape) => shape.correct ? acc + 1 : acc, 0);
168
+ const nbOfSelections = (allShapes || []).reduce((acc, shape) => (shape.correct ? acc + 1 : acc), 0);
181
169
 
182
170
  const nbOfShapes = (allShapes || []).length;
183
171
 
@@ -1,13 +1,16 @@
1
1
  import isEqual from 'lodash/isEqual';
2
2
  import isEmpty from 'lodash/isEmpty';
3
3
 
4
- export const getCorrectResponse = (choices) => choices
5
- .filter(c => c.correct)
6
- .map(c => c.id)
7
- .sort();
4
+ export const getCorrectResponse = (choices) =>
5
+ choices
6
+ .filter((c) => c.correct)
7
+ .map((c) => c.id)
8
+ .sort();
8
9
 
9
10
  export const isResponseCorrect = (question, session) => {
10
- const { shapes: { rectangles, polygons } } = question;
11
+ const {
12
+ shapes: { rectangles, polygons },
13
+ } = question;
11
14
  const choices = [...rectangles, ...polygons];
12
15
  let correctResponseIds = getCorrectResponse(choices);
13
16
 
@@ -16,7 +19,7 @@ export const isResponseCorrect = (question, session) => {
16
19
  }
17
20
 
18
21
  if (session.answers && session.answers.length) {
19
- let answerIds = (session.answers || []).map(a => a.id);
22
+ let answerIds = (session.answers || []).map((a) => a.id);
20
23
 
21
24
  return isEqual(answerIds.sort(), correctResponseIds);
22
25
  } else if (!(correctResponseIds && correctResponseIds.length)) {
@@ -162,4 +162,4 @@ Indicates the max dimension for images in prompt - this is also the default dime
162
162
 
163
163
  ### `rationale` (number)
164
164
 
165
- Indicates the max dimension for images in rationale
165
+ Indicates the max dimension for images in rationale
@@ -2,7 +2,7 @@ const { model } = require('./generate');
2
2
 
3
3
  module.exports = {
4
4
  elements: {
5
- 'hotspot-element': '../..'
5
+ 'hotspot-element': '../..',
6
6
  },
7
- models: [model('1', 'hotspot-element')]
7
+ models: [model('1', 'hotspot-element')],
8
8
  };
@@ -4,13 +4,10 @@ exports.model = (id, element) => ({
4
4
  disabled: false,
5
5
  mode: 'gather',
6
6
  dimensions: { height: 291, width: 410 },
7
- imageUrl: 'https://store-images.s-microsoft.com/image/apps.2544.13768621950225582.167ba0c8-6eb8-47bb-96fe-278c89bf0dc9.ea440c13-fd1d-4705-b62c-9bfd9054b8b3?w=672&h=378&q=80&mode=letterbox&background=%23FFE4E4E4&format=jpg',
7
+ imageUrl:
8
+ 'https://store-images.s-microsoft.com/image/apps.2544.13768621950225582.167ba0c8-6eb8-47bb-96fe-278c89bf0dc9.ea440c13-fd1d-4705-b62c-9bfd9054b8b3?w=672&h=378&q=80&mode=letterbox&background=%23FFE4E4E4&format=jpg',
8
9
  hotspotColor: 'rgba(137, 183, 244, 0.65)',
9
- hotspotList: [
10
- 'rgba(137, 183, 244, 0.65)',
11
- 'rgba(217, 30, 24, 0.65)',
12
- 'rgba(254, 241, 96, 0.65)'
13
- ],
10
+ hotspotList: ['rgba(137, 183, 244, 0.65)', 'rgba(217, 30, 24, 0.65)', 'rgba(254, 241, 96, 0.65)'],
14
11
  outlineColor: 'blue',
15
12
  outlineList: ['blue', 'red', 'yellow'],
16
13
  multipleCorrect: true,
@@ -22,48 +19,63 @@ exports.model = (id, element) => ({
22
19
  width: 130,
23
20
  x: 1,
24
21
  y: 1,
25
- correct: true
26
- }, {
22
+ correct: true,
23
+ },
24
+ {
27
25
  id: 'd41',
28
26
  height: 140,
29
27
  width: 130,
30
28
  x: 140,
31
- y: 1
32
- }, {
29
+ y: 1,
30
+ },
31
+ {
33
32
  id: 'aaaa42',
34
33
  height: 140,
35
34
  width: 130,
36
35
  x: 280,
37
- y: 1
38
- }
36
+ y: 1,
37
+ },
38
+ ],
39
+ polygons: [
40
+ {
41
+ // triangle
42
+ id: '3',
43
+ points: [
44
+ { x: 65, y: 148 },
45
+ { x: 1, y: 288 },
46
+ { y: 288, x: 129 },
47
+ ],
48
+ correct: true,
49
+ },
50
+ {
51
+ // triangle
52
+ id: 'g74',
53
+ points: [
54
+ { y: 151, x: 141 },
55
+ { y: 289, x: 205 },
56
+ { x: 269, y: 151 },
57
+ ],
58
+ correct: false,
59
+ },
60
+ {
61
+ // hexagon
62
+ id: 'j35',
63
+ points: [
64
+ { x: 300, y: 150 },
65
+ { x: 279, y: 220 },
66
+ { x: 300, y: 289 },
67
+ { x: 386, y: 289 },
68
+ { x: 407, y: 220 },
69
+ { x: 386, y: 150 },
70
+ ],
71
+ correct: false,
72
+ },
39
73
  ],
40
- polygons: [{
41
- // triangle
42
- id: '3',
43
- points: [{ x: 65, y: 148 }, { x: 1, y: 288 }, { y: 288, x: 129 }],
44
- correct: true
45
- }, {
46
- // triangle
47
- id: 'g74',
48
- points: [{ y: 151, x: 141 }, { y: 289, x: 205 }, { x: 269, y: 151 }],
49
- correct: false
50
- }, {
51
- // hexagon
52
- id: 'j35',
53
- points: [
54
- { x: 300, y: 150 },
55
- { x: 279, y: 220 },
56
- { x: 300, y: 289 },
57
- { x: 386, y: 289 },
58
- { x: 407, y: 220 },
59
- { x: 386, y: 150 }
60
- ],
61
- correct: false
62
- }]
63
74
  },
64
75
  rationale: null,
65
76
  teacherInstructions: null,
66
77
  toolbarEditorPosition: 'bottom',
67
- prompt: '<div><audio controls="controls" src="https://storage.googleapis.com/pie-prod-221718-assets/audio/77f3f61e-5f2d-425f-80a5-fb814dfa5e4c"></audio><br><br>Choose ALL of the words with the long /o/ sound.</div>',
68
- rubricEnabled: false
78
+ prompt:
79
+ '<div><audio controls="controls" src="https://storage.googleapis.com/pie-prod-221718-assets/audio/77f3f61e-5f2d-425f-80a5-fb814dfa5e4c"></audio><br><br>Choose ALL of the words with the long /o/ sound.</div>',
80
+ rubricEnabled: false,
69
81
  });
@@ -6,6 +6,6 @@ module.exports = [
6
6
  // {
7
7
  // id: '1'
8
8
  // }
9
- ]
10
- }
9
+ ],
10
+ },
11
11
  ];
@@ -353,4 +353,4 @@ the height of the section
353
353
 
354
354
  ### `width` (number, required)
355
355
 
356
- the width of the section
356
+ the width of the section