@pie-element/explicit-constructed-response 3.7.19-next.85 → 3.8.1-beta.587
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/CHANGELOG.md +541 -0
- package/configure/CHANGELOG.md +482 -0
- package/configure/lib/alternateResponses.js +45 -12
- package/configure/lib/alternateResponses.js.map +1 -1
- package/configure/lib/alternateSection.js +116 -19
- package/configure/lib/alternateSection.js.map +1 -1
- package/configure/lib/defaults.js +35 -0
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/ecr-toolbar.js +35 -19
- package/configure/lib/ecr-toolbar.js.map +1 -1
- package/configure/lib/index.js +17 -3
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/main.js +291 -58
- package/configure/lib/main.js.map +1 -1
- package/configure/lib/markupUtils.js +29 -3
- package/configure/lib/markupUtils.js.map +1 -1
- package/configure/lib/utils.js +15 -0
- package/configure/lib/utils.js.map +1 -0
- package/configure/package.json +23 -5
- package/controller/CHANGELOG.md +107 -0
- package/controller/lib/defaults.js +1 -0
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +109 -6
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +2 -2
- package/docs/config-schema.json +137 -0
- package/docs/config-schema.json.md +105 -1
- package/docs/demo/config.js +2 -2
- package/docs/demo/generate.js +6 -2
- package/docs/pie-schema.json +68 -0
- package/docs/pie-schema.json.md +53 -0
- package/lib/index.js +8 -1
- package/lib/index.js.map +1 -1
- package/lib/main.js +95 -25
- package/lib/main.js.map +1 -1
- package/lib/print.js +115 -0
- package/lib/print.js.map +1 -0
- package/package.json +14 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":["log","prepareChoice","mode","defaultFeedback","choice","out","label","value","correct","feedbackType","feedback","type","getFeedback","normalize","question","rationaleEnabled","promptEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","model","session","env","Promise","resolve","choices","Object","keys","forEach","key","map","item","index","normalizedQuestion","assign","incorrect","preparChoiceFn","obj","area","respArea","chosenValue","val","c","prepareVal","disabled","prompt","markup","responseCorrect","getScore","undefined","role","rationale","teacherInstructions","getTextFromHTML","html","replace","trim","config","responseAreas","match","maxScore","length","correctCount","total","str","toFixed","parseFloat","outcome","partialScoringEnabled","partialScoring","enabled","score","empty","createCorrectResponseSession","i","id"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,0CAAN,CAAZ;;AAEO,IAAMC,aAAa,GAAG,SAAhBA,aAAgB,CAACC,IAAD,EAAOC,eAAP;AAAA,SAA2B,UAAAC,MAAM,EAAI;AAChE,QAAMC,GAAG,GAAG;AACVC,MAAAA,KAAK,EAAEF,MAAM,CAACE,KADJ;AAEVC,MAAAA,KAAK,EAAEH,MAAM,CAACG;AAFJ,KAAZ;;AAKA,QAAIL,IAAI,KAAK,UAAb,EAAyB;AACvBG,MAAAA,GAAG,CAACG,OAAJ,GAAc,IAAd;AAEA,UAAMC,YAAY,GAAIL,MAAM,CAACM,QAAP,IAAmBN,MAAM,CAACM,QAAP,CAAgBC,IAApC,IAA6C,MAAlE;;AAEA,UAAIF,YAAY,KAAK,SAArB,EAAgC;AAC9BJ,QAAAA,GAAG,CAACK,QAAJ,GAAeP,eAAe,CAAC,SAAD,CAA9B;AACD,OAFD,MAEO,IAAIM,YAAY,KAAK,QAArB,EAA+B;AACpCJ,QAAAA,GAAG,CAACK,QAAJ,GAAeN,MAAM,CAACM,QAAP,CAAgBH,KAA/B;AACD;AACF;;AAED,WAAOF,GAAP;AACD,GAnB4B;AAAA,CAAtB;;;;AAqBP,IAAMO,WAAW,GAAG,SAAdA,WAAc,CAAAL,KAAK,EAAI;AAC3B,MAAIA,KAAJ,EAAW;AACT,WAAO,SAAP;AACD;;AAED,SAAO,WAAP;AACD,CAND;;AAQO,IAAMM,SAAS,GAAG,SAAZA,SAAY,C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AAGC,gCAAeC,OAAf,CAAuBlD,KAAvB,EAA8BE,GAA9B,CAA9B;;AACA,QAAMiD,KAAK,GAAGvB,QAAQ,CAAC5B,KAAD,EAAQC,OAAR,CAAtB;AAEAG,IAAAA,OAAO,CAAC;AAAE+C,MAAAA,KAAK,EAAEH,qBAAqB,GAAGG,KAAH,GAAWA,KAAK,KAAK,CAAV,GAAc,CAAd,GAAkB,CAA3D;AAA8DC,MAAAA,KAAK,EAAE,yBAAQnD,OAAR;AAArE,KAAD,CAAP;AACD,GALM,CAAP;AAMD;;AAEM,IAAMoD,4BAA4B,GAAG,SAA/BA,4BAA+B,CAAC1D,QAAD,EAAWO,GAAX,EAAmB;AAC7D,SAAO,IAAIC,OAAJ,CAAY,UAAAC,OAAO,EAAI;AAC5B,QAAIF,GAAG,CAACnB,IAAJ,KAAa,UAAb,IAA2BmB,GAAG,CAAC4B,IAAJ,KAAa,YAA5C,EAA0D;AAAA,UAChDzB,OADgD,GACpCV,QADoC,CAChDU,OADgD;AAExD,UAAMjB,KAAK,GAAG,EAAd;AAEAkB,MAAAA,MAAM,CAACC,IAAP,CAAYF,OAAZ,EAAqBG,OAArB,CAA6B,UAACC,GAAD,EAAM6C,CAAN,EAAY;AACvClE,QAAAA,KAAK,CAACkE,CAAD,CAAL,GAAWjD,OAAO,CAACI,GAAD,CAAP,CAAa,CAAb,EAAgBtB,KAA3B;AACD,OAFD;AAIAiB,MAAAA,OAAO,CAAC;AACNmD,QAAAA,EAAE,EAAE,GADE;AAENnE,QAAAA,KAAK,EAALA;AAFM,OAAD,CAAP;AAID,KAZD,MAYO;AACLgB,MAAAA,OAAO,CAAC,IAAD,CAAP;AACD;AACF,GAhBM,CAAP;AAiBD,CAlBM","sourcesContent":["import map from 'lodash/map';\nimport reduce from 'lodash/reduce';\nimport find from 'lodash/find';\nimport isEmpty from 'lodash/isEmpty';\nimport debug from 'debug';\nimport { partialScoring } from '@pie-lib/controller-utils';\n\nconst log = debug('explicit-constructed-response:controller');\n\nexport const prepareChoice = (mode, defaultFeedback) => choice => {\n const out = {\n label: choice.label,\n value: choice.value\n };\n\n if (mode === 'evaluate') {\n out.correct = true;\n\n const feedbackType = (choice.feedback && choice.feedback.type) || 'none';\n\n if (feedbackType === 'default') {\n out.feedback = defaultFeedback['correct'];\n } else if (feedbackType === 'custom') {\n out.feedback = choice.feedback.value;\n }\n }\n\n return out;\n};\n\nconst getFeedback = value => {\n if (value) {\n return 'correct';\n }\n\n return 'incorrect';\n};\n\nexport const normalize = question => ({\n rationaleEnabled: true,\n promptEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n ...question,\n});\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n */\nexport function model(question, session, env) {\n return new Promise(async resolve => {\n // this was added to treat an exception, when the model has choices without the \"value\" property\n // like: { label: 'test' }\n if (question.choices) {\n Object.keys(question.choices).forEach(key => {\n question.choices[key] = question.choices[key].map((item, index) => {\n if (!item.value) {\n log('Choice does not contain \"value\" property, which is required.', item);\n return { value: `${index}`, ...item };\n }\n\n return item;\n })\n });\n }\n\n const normalizedQuestion = normalize(question);\n const defaultFeedback = Object.assign(\n { correct: 'Correct', incorrect: 'Incorrect' },\n normalizedQuestion.defaultFeedback\n );\n\n const { value = {} } = session || {};\n\n const preparChoiceFn = prepareChoice(env.mode, defaultFeedback);\n\n let choices = reduce(\n normalizedQuestion.choices,\n (obj, area, key) => {\n obj[key] = map(area, preparChoiceFn);\n\n return obj;\n },\n {}\n );\n let feedback = {};\n\n if (env.mode === 'evaluate') {\n feedback = reduce(normalizedQuestion.choices, (obj, respArea, key) => {\n const chosenValue = value && value[key];\n const val = !isEmpty(chosenValue) && find(respArea, c => prepareVal(c.label) === prepareVal(chosenValue));\n\n obj[key] = getFeedback(val);\n\n return obj;\n }, {});\n }\n\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n markup: normalizedQuestion.markup,\n choices,\n feedback,\n responseCorrect:\n env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : undefined\n };\n\n if (\n env.role === 'instructor' &&\n (env.mode === 'view' || env.mode === 'evaluate')\n ) {\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 resolve(out);\n });\n}\n\nconst getTextFromHTML = (html) => {\n return (html || '').replace(/<\\/?[^>]+(>|$)/g, '');\n};\n\nexport const prepareVal = html => {\n const value = getTextFromHTML(html);\n\n return value.trim();\n};\n\nexport const getScore = (config, session) => {\n const { value } = session || {};\n\n if (!session || isEmpty(session) || !value) {\n return 0;\n }\n\n const responseAreas = config.markup && config.markup.match(/\\{\\{(.)\\}\\}/g);\n const maxScore = responseAreas ? responseAreas.length : 0;\n const correctCount = reduce(config.choices, (total, respArea, key) => {\n const chosenValue = value && value[key];\n\n if (isEmpty(chosenValue) || !find(respArea, c => prepareVal(c.label) === prepareVal(chosenValue))) {\n return total;\n }\n\n return total + 1;\n }, 0);\n\n const str = maxScore ? (correctCount / maxScore).toFixed(2) : 0;\n\n return parseFloat(str);\n};\n\n/**\n *\n * The score is partial by default for checkbox mode, allOrNothing for radio mode.\n * To disable partial scoring for checkbox mode you either set model.partialScoring = false or env.partialScoring =\n * false. the value in `env` will override the value in `model`.\n * @param {Object} model - the main model\n * @param {boolean} model.partialScoring - is partial scoring enabled (if undefined set to to true)\n * @param {*} session\n * @param {Object} env\n * @param {boolean} env.partialScoring - is partial scoring enabled (if undefined default to true) This overrides\n * `model.partialScoring`.\n */\nexport function outcome(model, session, env = {}) {\n return new Promise(resolve => {\n const partialScoringEnabled = partialScoring.enabled(model, env);\n const score = getScore(model, session);\n\n resolve({ score: partialScoringEnabled ? score : score === 1 ? 1 : 0, empty: isEmpty(session) });\n });\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise(resolve => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { choices } = question;\n const value = {};\n\n Object.keys(choices).forEach((key, i) => {\n value[i] = choices[key][0].label;\n });\n\n resolve({\n id: '1',\n value\n });\n } else {\n resolve(null);\n }\n });\n};\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":["log","prepareChoice","mode","defaultFeedback","choice","out","label","value","correct","feedbackType","feedback","type","getFeedback","getAdjustedLength","length","normalize","question","rationaleEnabled","promptEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","model","session","env","Promise","resolve","choices","Object","keys","forEach","key","map","item","index","normalizedQuestion","assign","incorrect","preparChoiceFn","obj","area","respArea","chosenValue","val","c","prepareVal","showNote","values","maxLengthPerChoice","maxLengthPerChoiceEnabled","undefinedLengths","labelLengthsArr","Math","max","disabled","prompt","markup","note","displayType","playerSpellCheckEnabled","responseCorrect","getScore","undefined","role","rationale","teacherInstructions","getTextFromHTML","html","replace","trim","config","responseAreas","match","maxScore","correctCount","total","str","toFixed","parseFloat","outcome","partialScoringEnabled","partialScoring","enabled","score","empty","createCorrectResponseSession","i","id","validate","maxResponseAreas","allChoicesErrors","entries","reversedChoices","reverse","choicesErrors","identicalAnswer","slice","some","errors","nbOfResponseAreas","responseAreasError"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,0CAAN,CAAZ;;AAEO,IAAMC,aAAa,GAAG,SAAhBA,aAAgB,CAACC,IAAD,EAAOC,eAAP;AAAA,SAA2B,UAACC,MAAD,EAAY;AAClE,QAAMC,GAAG,GAAG;AACVC,MAAAA,KAAK,EAAEF,MAAM,CAACE,KADJ;AAEVC,MAAAA,KAAK,EAAEH,MAAM,CAACG;AAFJ,KAAZ;;AAKA,QAAIL,IAAI,KAAK,UAAb,EAAyB;AACvBG,MAAAA,GAAG,CAACG,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AAA,MAAM,CAACE,kBAAP,0BAA4CX,gBAA5C;AACD,GAFD,MAEO,IAAIU,iBAAiB,GAAG,CAAxB,EAA2B;AAChCD,IAAAA,MAAM,CAACE,kBAAP,GAA4B,mDAA5B;AACD;;AAED,MAAI,CAAC,yBAAQV,gBAAR,CAAL,EAAgC;AAC9BQ,IAAAA,MAAM,CAACJ,aAAP,GAAuBJ,gBAAvB;AACD;;AAED,SAAOQ,MAAP;AACD,CA1CM","sourcesContent":["import map from 'lodash/map';\nimport reduce from 'lodash/reduce';\nimport find from 'lodash/find';\nimport isEmpty from 'lodash/isEmpty';\nimport debug from 'debug';\nimport { partialScoring } from '@pie-lib/controller-utils';\n\nconst log = debug('explicit-constructed-response:controller');\n\nexport const prepareChoice = (mode, defaultFeedback) => (choice) => {\n const out = {\n label: choice.label,\n value: choice.value,\n };\n\n if (mode === 'evaluate') {\n out.correct = true;\n\n const feedbackType = (choice.feedback && choice.feedback.type) || 'none';\n\n if (feedbackType === 'default') {\n out.feedback = defaultFeedback['correct'];\n } else if (feedbackType === 'custom') {\n out.feedback = choice.feedback.value;\n }\n }\n\n return out;\n};\n\nconst getFeedback = (value) => {\n if (value) {\n return 'correct';\n }\n\n return 'incorrect';\n};\n\n// also used in configure/src/markupUtils.js\nconst getAdjustedLength = (length) => {\n if (length <= 2) {\n return length + 2;\n }\n\n if (length <= 4) {\n return length + 3;\n }\n\n if (length <= 6) {\n return length + 4;\n }\n\n return length + 5;\n};\n\nexport const normalize = (question) => ({\n rationaleEnabled: true,\n promptEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n ...question,\n});\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n */\nexport function model(question, session, env) {\n return new Promise(async (resolve) => {\n // this was added to treat an exception, when the model has choices without the \"value\" property\n // like: { label: 'test' }\n if (question.choices) {\n Object.keys(question.choices).forEach((key) => {\n question.choices[key] = (question.choices[key] || []).map((item, index) => {\n if (!item.value) {\n log('Choice does not contain \"value\" property, which is required.', item);\n return { value: `${index}`, ...item };\n }\n\n return item;\n });\n });\n }\n\n const normalizedQuestion = normalize(question);\n const defaultFeedback = Object.assign(\n { correct: 'Correct', incorrect: 'Incorrect' },\n normalizedQuestion.defaultFeedback,\n );\n\n const { value = {} } = session || {};\n\n const preparChoiceFn = prepareChoice(env.mode, defaultFeedback);\n\n let choices = reduce(\n normalizedQuestion.choices,\n (obj, area, key) => {\n obj[key] = map(area, preparChoiceFn);\n\n return obj;\n },\n {},\n );\n let feedback = {};\n\n if (env.mode === 'evaluate') {\n feedback = reduce(\n normalizedQuestion.choices,\n (obj, respArea, key) => {\n const chosenValue = value && value[key];\n const val = !isEmpty(chosenValue) && find(respArea, (c) => prepareVal(c.label) === prepareVal(chosenValue));\n\n obj[key] = getFeedback(val);\n\n return obj;\n },\n {},\n );\n }\n\n let showNote = false;\n // check if a choice has an alternate\n Object.values(choices).forEach((choice) => {\n if (choice && choice.length > 1) {\n showNote = true;\n }\n });\n\n const { maxLengthPerChoice = [], maxLengthPerChoiceEnabled } = normalizedQuestion;\n const undefinedLengths = !maxLengthPerChoice.length;\n\n // calculate maxLengthPerChoice array if it is not defined or defined incorrectly\n Object.values(choices).forEach((choice, index) => {\n const labelLengthsArr = (choice || []).map((choice) => (choice.label || '').length);\n const length = Math.max(...labelLengthsArr);\n\n if (\n undefinedLengths ||\n !maxLengthPerChoice[index] ||\n maxLengthPerChoice[index] < length ||\n maxLengthPerChoice[index] > length + 10\n ) {\n maxLengthPerChoice[index] = getAdjustedLength(length);\n }\n });\n\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n markup: normalizedQuestion.markup,\n choices,\n feedback,\n env,\n note: normalizedQuestion.note,\n showNote,\n maxLengthPerChoice,\n maxLengthPerChoiceEnabled,\n displayType: normalizedQuestion.displayType,\n playerSpellCheckEnabled: normalizedQuestion.playerSpellCheckEnabled,\n responseCorrect: env.mode === 'evaluate' ? getScore(normalizedQuestion, session) === 1 : 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 resolve(out);\n });\n}\n\nconst getTextFromHTML = (html) => {\n return (html || '').replace(/<\\/?[^>]+(>|$)/g, '');\n};\n\nexport const prepareVal = (html) => {\n const value = getTextFromHTML(html);\n\n return value.trim();\n};\n\nexport const getScore = (config, session) => {\n const { value } = session || {};\n\n if (!session || isEmpty(session) || !value) {\n return 0;\n }\n\n const responseAreas = config.markup && config.markup.match(/\\{\\{(.)\\}\\}/g);\n const maxScore = responseAreas ? responseAreas.length : 0;\n const correctCount = reduce(\n config.choices,\n (total, respArea, key) => {\n const chosenValue = value && value[key];\n\n if (isEmpty(chosenValue) || !find(respArea, (c) => prepareVal(c.label) === prepareVal(chosenValue))) {\n return total;\n }\n\n return total + 1;\n },\n 0,\n );\n\n const str = maxScore ? (correctCount / maxScore).toFixed(2) : 0;\n\n return parseFloat(str);\n};\n\n/**\n *\n * The score is partial by default for checkbox mode, allOrNothing for radio mode.\n * To disable partial scoring for checkbox mode you either set model.partialScoring = false or env.partialScoring =\n * false. the value in `env` will override the value in `model`.\n * @param {Object} model - the main model\n * @param {boolean} model.partialScoring - is partial scoring enabled (if undefined set to to true)\n * @param {*} session\n * @param {Object} env\n * @param {boolean} env.partialScoring - is partial scoring enabled (if undefined default to true) This overrides\n * `model.partialScoring`.\n */\nexport function outcome(model, session, env = {}) {\n return new Promise((resolve) => {\n const partialScoringEnabled = partialScoring.enabled(model, env);\n const score = getScore(model, session);\n\n resolve({ score: partialScoringEnabled ? score : score === 1 ? 1 : 0, empty: isEmpty(session) });\n });\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { choices } = question;\n const value = {};\n\n Object.keys(choices).forEach((key, i) => {\n value[i] = choices[key][0].label;\n });\n\n resolve({\n id: '1',\n value,\n });\n } else {\n resolve(null);\n }\n });\n};\n\nexport const validate = (model = {}, config = {}) => {\n const { choices, markup } = model;\n const { maxResponseAreas } = config;\n const allChoicesErrors = {};\n\n Object.entries(choices || {}).forEach(([key, values]) => {\n const reversedChoices = [...(values || [])].reverse();\n const choicesErrors = {};\n\n reversedChoices.forEach((choice, index) => {\n const { value, label } = choice;\n\n if (label === '' || label === '<div></div>') {\n choicesErrors[value] = 'Content should not be empty.';\n } else {\n const identicalAnswer = reversedChoices.slice(index + 1).some((c) => c.label === label);\n\n if (identicalAnswer) {\n choicesErrors[value] = 'Content should be unique.';\n }\n }\n });\n\n if (!isEmpty(choicesErrors)) {\n allChoicesErrors[key] = choicesErrors;\n }\n });\n\n const errors = {};\n const nbOfResponseAreas = (markup.match(/\\{\\{(\\d+)\\}\\}/g) || []).length;\n\n if (nbOfResponseAreas > maxResponseAreas) {\n errors.responseAreasError = `No more than ${maxResponseAreas} response areas should be defined.`;\n } else if (nbOfResponseAreas < 1) {\n errors.responseAreasError = 'There should be at least 1 response area defined.';\n }\n\n if (!isEmpty(allChoicesErrors)) {\n errors.choicesErrors = allChoicesErrors;\n }\n\n return errors;\n};\n"],"file":"index.js"}
|
package/controller/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/explicit-constructed-response-controller",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.5.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "src/index.js",
|
|
8
8
|
"author": "",
|
|
9
9
|
"license": "ISC",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@pie-lib/controller-utils": "^0.2.
|
|
11
|
+
"@pie-lib/controller-utils": "^0.2.42",
|
|
12
12
|
"debug": "^3.1.0",
|
|
13
13
|
"lodash": "^4.17.15",
|
|
14
14
|
"type-of": "^2.0.1"
|
package/docs/config-schema.json
CHANGED
|
@@ -51,6 +51,43 @@
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
|
+
"settingsPanelDisabled": {
|
|
55
|
+
"description": "Indicates if the settings panel is not available",
|
|
56
|
+
"type": "boolean",
|
|
57
|
+
"title": "settingsPanelDisabled"
|
|
58
|
+
},
|
|
59
|
+
"spellCheck": {
|
|
60
|
+
"title": "ConfigureProp",
|
|
61
|
+
"type": "object",
|
|
62
|
+
"properties": {
|
|
63
|
+
"settings": {
|
|
64
|
+
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
65
|
+
"type": "boolean",
|
|
66
|
+
"title": "settings"
|
|
67
|
+
},
|
|
68
|
+
"label": {
|
|
69
|
+
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
70
|
+
"type": "string",
|
|
71
|
+
"title": "label"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"playerSpellCheck": {
|
|
76
|
+
"title": "ConfigureProp",
|
|
77
|
+
"type": "object",
|
|
78
|
+
"properties": {
|
|
79
|
+
"settings": {
|
|
80
|
+
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
81
|
+
"type": "boolean",
|
|
82
|
+
"title": "settings"
|
|
83
|
+
},
|
|
84
|
+
"label": {
|
|
85
|
+
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
86
|
+
"type": "string",
|
|
87
|
+
"title": "label"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
54
91
|
"autoScoring": {
|
|
55
92
|
"title": "ConfigureProp",
|
|
56
93
|
"type": "object",
|
|
@@ -131,6 +168,85 @@
|
|
|
131
168
|
}
|
|
132
169
|
}
|
|
133
170
|
},
|
|
171
|
+
"maxLengthPerChoice": {
|
|
172
|
+
"title": "ConfigureProp",
|
|
173
|
+
"type": "object",
|
|
174
|
+
"properties": {
|
|
175
|
+
"settings": {
|
|
176
|
+
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
177
|
+
"type": "boolean",
|
|
178
|
+
"title": "settings"
|
|
179
|
+
},
|
|
180
|
+
"label": {
|
|
181
|
+
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
182
|
+
"type": "string",
|
|
183
|
+
"title": "label"
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
"maxResponseAreas": {
|
|
188
|
+
"description": "Maximum number of response areas",
|
|
189
|
+
"type": "number",
|
|
190
|
+
"title": "maxResponseAreas"
|
|
191
|
+
},
|
|
192
|
+
"maxImageWidth": {
|
|
193
|
+
"title": "ConfigureMaxImageDimensionsProp",
|
|
194
|
+
"type": "object",
|
|
195
|
+
"properties": {
|
|
196
|
+
"teacherInstructions": {
|
|
197
|
+
"description": "Indicates the max dimension for images in teacher instructions",
|
|
198
|
+
"type": "number",
|
|
199
|
+
"title": "teacherInstructions"
|
|
200
|
+
},
|
|
201
|
+
"prompt": {
|
|
202
|
+
"description": "Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified",
|
|
203
|
+
"type": "number",
|
|
204
|
+
"title": "prompt"
|
|
205
|
+
},
|
|
206
|
+
"rationale": {
|
|
207
|
+
"description": "Indicates the max dimension for images in rationale",
|
|
208
|
+
"type": "number",
|
|
209
|
+
"title": "rationale"
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
"maxImageHeight": {
|
|
214
|
+
"title": "ConfigureMaxImageDimensionsProp",
|
|
215
|
+
"type": "object",
|
|
216
|
+
"properties": {
|
|
217
|
+
"teacherInstructions": {
|
|
218
|
+
"description": "Indicates the max dimension for images in teacher instructions",
|
|
219
|
+
"type": "number",
|
|
220
|
+
"title": "teacherInstructions"
|
|
221
|
+
},
|
|
222
|
+
"prompt": {
|
|
223
|
+
"description": "Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified",
|
|
224
|
+
"type": "number",
|
|
225
|
+
"title": "prompt"
|
|
226
|
+
},
|
|
227
|
+
"rationale": {
|
|
228
|
+
"description": "Indicates the max dimension for images in rationale",
|
|
229
|
+
"type": "number",
|
|
230
|
+
"title": "rationale"
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
"withRubric": {
|
|
235
|
+
"title": "ConfigureProp",
|
|
236
|
+
"type": "object",
|
|
237
|
+
"properties": {
|
|
238
|
+
"settings": {
|
|
239
|
+
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
240
|
+
"type": "boolean",
|
|
241
|
+
"title": "settings"
|
|
242
|
+
},
|
|
243
|
+
"label": {
|
|
244
|
+
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
245
|
+
"type": "string",
|
|
246
|
+
"title": "label"
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
},
|
|
134
250
|
"showPrompt": {
|
|
135
251
|
"description": "Determines whether prompt field will be displayed or not",
|
|
136
252
|
"default": true,
|
|
@@ -166,6 +282,27 @@
|
|
|
166
282
|
"title": "label"
|
|
167
283
|
}
|
|
168
284
|
}
|
|
285
|
+
},
|
|
286
|
+
"ConfigureMaxImageDimensionsProp": {
|
|
287
|
+
"title": "ConfigureMaxImageDimensionsProp",
|
|
288
|
+
"type": "object",
|
|
289
|
+
"properties": {
|
|
290
|
+
"teacherInstructions": {
|
|
291
|
+
"description": "Indicates the max dimension for images in teacher instructions",
|
|
292
|
+
"type": "number",
|
|
293
|
+
"title": "teacherInstructions"
|
|
294
|
+
},
|
|
295
|
+
"prompt": {
|
|
296
|
+
"description": "Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified",
|
|
297
|
+
"type": "number",
|
|
298
|
+
"title": "prompt"
|
|
299
|
+
},
|
|
300
|
+
"rationale": {
|
|
301
|
+
"description": "Indicates the max dimension for images in rationale",
|
|
302
|
+
"type": "number",
|
|
303
|
+
"title": "rationale"
|
|
304
|
+
}
|
|
305
|
+
}
|
|
169
306
|
}
|
|
170
307
|
},
|
|
171
308
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
@@ -38,6 +38,34 @@ Indicates if the item has to be displayed in the Settings Panel
|
|
|
38
38
|
|
|
39
39
|
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
40
40
|
|
|
41
|
+
# `settingsPanelDisabled` (boolean)
|
|
42
|
+
|
|
43
|
+
Indicates if the settings panel is not available
|
|
44
|
+
|
|
45
|
+
# `spellCheck` (object)
|
|
46
|
+
|
|
47
|
+
Properties of the `spellCheck` object:
|
|
48
|
+
|
|
49
|
+
## `settings` (boolean)
|
|
50
|
+
|
|
51
|
+
Indicates if the item has to be displayed in the Settings Panel
|
|
52
|
+
|
|
53
|
+
## `label` (string)
|
|
54
|
+
|
|
55
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
56
|
+
|
|
57
|
+
# `playerSpellCheck` (object)
|
|
58
|
+
|
|
59
|
+
Properties of the `playerSpellCheck` object:
|
|
60
|
+
|
|
61
|
+
## `settings` (boolean)
|
|
62
|
+
|
|
63
|
+
Indicates if the item has to be displayed in the Settings Panel
|
|
64
|
+
|
|
65
|
+
## `label` (string)
|
|
66
|
+
|
|
67
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
68
|
+
|
|
41
69
|
# `autoScoring` (object)
|
|
42
70
|
|
|
43
71
|
Properties of the `autoScoring` object:
|
|
@@ -98,6 +126,66 @@ Indicates if the item has to be displayed in the Settings Panel
|
|
|
98
126
|
|
|
99
127
|
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
100
128
|
|
|
129
|
+
# `maxLengthPerChoice` (object)
|
|
130
|
+
|
|
131
|
+
Properties of the `maxLengthPerChoice` object:
|
|
132
|
+
|
|
133
|
+
## `settings` (boolean)
|
|
134
|
+
|
|
135
|
+
Indicates if the item has to be displayed in the Settings Panel
|
|
136
|
+
|
|
137
|
+
## `label` (string)
|
|
138
|
+
|
|
139
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
140
|
+
|
|
141
|
+
# `maxResponseAreas` (number)
|
|
142
|
+
|
|
143
|
+
Maximum number of response areas
|
|
144
|
+
|
|
145
|
+
# `maxImageWidth` (object)
|
|
146
|
+
|
|
147
|
+
Properties of the `maxImageWidth` object:
|
|
148
|
+
|
|
149
|
+
## `teacherInstructions` (number)
|
|
150
|
+
|
|
151
|
+
Indicates the max dimension for images in teacher instructions
|
|
152
|
+
|
|
153
|
+
## `prompt` (number)
|
|
154
|
+
|
|
155
|
+
Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
|
|
156
|
+
|
|
157
|
+
## `rationale` (number)
|
|
158
|
+
|
|
159
|
+
Indicates the max dimension for images in rationale
|
|
160
|
+
|
|
161
|
+
# `maxImageHeight` (object)
|
|
162
|
+
|
|
163
|
+
Properties of the `maxImageHeight` object:
|
|
164
|
+
|
|
165
|
+
## `teacherInstructions` (number)
|
|
166
|
+
|
|
167
|
+
Indicates the max dimension for images in teacher instructions
|
|
168
|
+
|
|
169
|
+
## `prompt` (number)
|
|
170
|
+
|
|
171
|
+
Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
|
|
172
|
+
|
|
173
|
+
## `rationale` (number)
|
|
174
|
+
|
|
175
|
+
Indicates the max dimension for images in rationale
|
|
176
|
+
|
|
177
|
+
# `withRubric` (object)
|
|
178
|
+
|
|
179
|
+
Properties of the `withRubric` object:
|
|
180
|
+
|
|
181
|
+
## `settings` (boolean)
|
|
182
|
+
|
|
183
|
+
Indicates if the item has to be displayed in the Settings Panel
|
|
184
|
+
|
|
185
|
+
## `label` (string)
|
|
186
|
+
|
|
187
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
188
|
+
|
|
101
189
|
# `showPrompt` (boolean)
|
|
102
190
|
|
|
103
191
|
Determines whether prompt field will be displayed or not
|
|
@@ -132,4 +220,20 @@ Indicates if the item has to be displayed in the Settings Panel
|
|
|
132
220
|
|
|
133
221
|
### `label` (string)
|
|
134
222
|
|
|
135
|
-
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
223
|
+
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
224
|
+
|
|
225
|
+
## `ConfigureMaxImageDimensionsProp` (object)
|
|
226
|
+
|
|
227
|
+
Properties of the `ConfigureMaxImageDimensionsProp` object:
|
|
228
|
+
|
|
229
|
+
### `teacherInstructions` (number)
|
|
230
|
+
|
|
231
|
+
Indicates the max dimension for images in teacher instructions
|
|
232
|
+
|
|
233
|
+
### `prompt` (number)
|
|
234
|
+
|
|
235
|
+
Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
|
|
236
|
+
|
|
237
|
+
### `rationale` (number)
|
|
238
|
+
|
|
239
|
+
Indicates the max dimension for images in rationale
|
package/docs/demo/config.js
CHANGED
|
@@ -2,7 +2,7 @@ const { model } = require('./generate');
|
|
|
2
2
|
|
|
3
3
|
module.exports = {
|
|
4
4
|
elements: {
|
|
5
|
-
'explicit-constructed-response': '../..'
|
|
5
|
+
'explicit-constructed-response': '../..',
|
|
6
6
|
},
|
|
7
|
-
models: [model('1', 'explicit-constructed-response')]
|
|
7
|
+
models: [model('1', 'explicit-constructed-response')],
|
|
8
8
|
};
|
package/docs/demo/generate.js
CHANGED
|
@@ -10,8 +10,12 @@ exports.model = (id, element) => ({
|
|
|
10
10
|
choices: {
|
|
11
11
|
0: [choice('cow', '0'), choice('cattle', '1'), choice('calf', '2')],
|
|
12
12
|
1: [choice('over', '0'), choice('past', '1'), choice('beyond', '2')],
|
|
13
|
-
2: [choice('moon', '0')]
|
|
13
|
+
2: [choice('moon', '0')],
|
|
14
14
|
},
|
|
15
|
+
maxLengthPerChoice: [7, 10, 4],
|
|
15
16
|
prompt: 'Complete the sentence',
|
|
16
|
-
|
|
17
|
+
note: 'The answer shown above is the most common correct answer for this item. One or more additional correct answers are also defined, and will also be recognized as correct.',
|
|
18
|
+
promptEnabled: true,
|
|
19
|
+
toolbarEditorPosition: 'bottom',
|
|
20
|
+
rubricEnabled: false,
|
|
17
21
|
});
|
package/docs/pie-schema.json
CHANGED
|
@@ -34,6 +34,11 @@
|
|
|
34
34
|
},
|
|
35
35
|
"title": "choices"
|
|
36
36
|
},
|
|
37
|
+
"displayType": {
|
|
38
|
+
"description": "The type of display the container of the pie-ui element will be used",
|
|
39
|
+
"type": "string",
|
|
40
|
+
"title": "displayType"
|
|
41
|
+
},
|
|
37
42
|
"markup": {
|
|
38
43
|
"description": "The markup for the pie-ui element",
|
|
39
44
|
"type": "string",
|
|
@@ -49,6 +54,16 @@
|
|
|
49
54
|
"type": "boolean",
|
|
50
55
|
"title": "promptEnabled"
|
|
51
56
|
},
|
|
57
|
+
"spellCheckEnabled": {
|
|
58
|
+
"description": "Indicates if spellcheck is enabled for the author. Default value is true",
|
|
59
|
+
"type": "boolean",
|
|
60
|
+
"title": "spellCheckEnabled"
|
|
61
|
+
},
|
|
62
|
+
"playerSpellCheckEnabled": {
|
|
63
|
+
"description": "Indicates if spellcheck is enabled for the player. Default value is true",
|
|
64
|
+
"type": "boolean",
|
|
65
|
+
"title": "playerSpellCheckEnabled"
|
|
66
|
+
},
|
|
52
67
|
"rationale": {
|
|
53
68
|
"description": "Indicates correct answer rationale",
|
|
54
69
|
"type": "string",
|
|
@@ -93,6 +108,34 @@
|
|
|
93
108
|
"type": "boolean",
|
|
94
109
|
"title": "teacherInstructionsEnabled"
|
|
95
110
|
},
|
|
111
|
+
"note": {
|
|
112
|
+
"description": "Indicates the note for the answer",
|
|
113
|
+
"type": "string",
|
|
114
|
+
"title": "note"
|
|
115
|
+
},
|
|
116
|
+
"toolbarEditorPosition": {
|
|
117
|
+
"description": "Indicates the editor's toolbar position which can be 'bottom' or 'top'",
|
|
118
|
+
"default": ": 'bottom'",
|
|
119
|
+
"enum": [
|
|
120
|
+
"bottom",
|
|
121
|
+
"top"
|
|
122
|
+
],
|
|
123
|
+
"type": "string",
|
|
124
|
+
"title": "toolbarEditorPosition"
|
|
125
|
+
},
|
|
126
|
+
"maxLengthPerChoice": {
|
|
127
|
+
"description": "Indicates the maximum length for each response area",
|
|
128
|
+
"type": "array",
|
|
129
|
+
"items": {
|
|
130
|
+
"type": "number"
|
|
131
|
+
},
|
|
132
|
+
"title": "maxLengthPerChoice"
|
|
133
|
+
},
|
|
134
|
+
"rubricEnabled": {
|
|
135
|
+
"description": "Indicates if Rubric is enabled",
|
|
136
|
+
"type": "boolean",
|
|
137
|
+
"title": "rubricEnabled"
|
|
138
|
+
},
|
|
96
139
|
"id": {
|
|
97
140
|
"description": "Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.",
|
|
98
141
|
"type": "string",
|
|
@@ -107,12 +150,16 @@
|
|
|
107
150
|
"required": [
|
|
108
151
|
"autoScoring",
|
|
109
152
|
"choices",
|
|
153
|
+
"displayType",
|
|
110
154
|
"element",
|
|
111
155
|
"id",
|
|
112
156
|
"markup",
|
|
157
|
+
"playerSpellCheckEnabled",
|
|
113
158
|
"rationale",
|
|
114
159
|
"rationaleEnabled",
|
|
115
160
|
"rubric",
|
|
161
|
+
"rubricEnabled",
|
|
162
|
+
"spellCheckEnabled",
|
|
116
163
|
"studentInstructionsEnabled",
|
|
117
164
|
"teacherInstructionsEnabled"
|
|
118
165
|
],
|
|
@@ -133,6 +180,27 @@
|
|
|
133
180
|
}
|
|
134
181
|
}
|
|
135
182
|
},
|
|
183
|
+
"ConfigureMaxImageDimensionsProp": {
|
|
184
|
+
"title": "ConfigureMaxImageDimensionsProp",
|
|
185
|
+
"type": "object",
|
|
186
|
+
"properties": {
|
|
187
|
+
"teacherInstructions": {
|
|
188
|
+
"description": "Indicates the max dimension for images in teacher instructions",
|
|
189
|
+
"type": "number",
|
|
190
|
+
"title": "teacherInstructions"
|
|
191
|
+
},
|
|
192
|
+
"prompt": {
|
|
193
|
+
"description": "Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified",
|
|
194
|
+
"type": "number",
|
|
195
|
+
"title": "prompt"
|
|
196
|
+
},
|
|
197
|
+
"rationale": {
|
|
198
|
+
"description": "Indicates the max dimension for images in rationale",
|
|
199
|
+
"type": "number",
|
|
200
|
+
"title": "rationale"
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
},
|
|
136
204
|
"Choice": {
|
|
137
205
|
"title": "Choice",
|
|
138
206
|
"type": "object",
|
package/docs/pie-schema.json.md
CHANGED
|
@@ -7,6 +7,10 @@ The schema defines the following properties:
|
|
|
7
7
|
* Object with all the available choices for each response area.
|
|
8
8
|
* Keys need to be integers from 0 to n - 1 (where n is the number of areas)
|
|
9
9
|
|
|
10
|
+
# `displayType` (string, required)
|
|
11
|
+
|
|
12
|
+
The type of display the container of the pie-ui element will be used
|
|
13
|
+
|
|
10
14
|
# `markup` (string, required)
|
|
11
15
|
|
|
12
16
|
The markup for the pie-ui element
|
|
@@ -19,6 +23,14 @@ The item stem for the question
|
|
|
19
23
|
|
|
20
24
|
Indicates if the prompt is enabled
|
|
21
25
|
|
|
26
|
+
# `spellCheckEnabled` (boolean, required)
|
|
27
|
+
|
|
28
|
+
Indicates if spellcheck is enabled for the author. Default value is true
|
|
29
|
+
|
|
30
|
+
# `playerSpellCheckEnabled` (boolean, required)
|
|
31
|
+
|
|
32
|
+
Indicates if spellcheck is enabled for the player. Default value is true
|
|
33
|
+
|
|
22
34
|
# `rationale` (string, required)
|
|
23
35
|
|
|
24
36
|
Indicates correct answer rationale
|
|
@@ -56,6 +68,31 @@ Indicates if Student Instructions are enabled
|
|
|
56
68
|
|
|
57
69
|
Indicates if Teacher Instructions are enabled
|
|
58
70
|
|
|
71
|
+
# `note` (string)
|
|
72
|
+
|
|
73
|
+
Indicates the note for the answer
|
|
74
|
+
|
|
75
|
+
# `toolbarEditorPosition` (string, enum)
|
|
76
|
+
|
|
77
|
+
Indicates the editor's toolbar position which can be 'bottom' or 'top'
|
|
78
|
+
|
|
79
|
+
This element must be one of the following enum values:
|
|
80
|
+
|
|
81
|
+
* `bottom`
|
|
82
|
+
* `top`
|
|
83
|
+
|
|
84
|
+
Default: `": 'bottom'"`
|
|
85
|
+
|
|
86
|
+
# `maxLengthPerChoice` (array)
|
|
87
|
+
|
|
88
|
+
Indicates the maximum length for each response area
|
|
89
|
+
|
|
90
|
+
The object is an array with all elements of the type `number`.
|
|
91
|
+
|
|
92
|
+
# `rubricEnabled` (boolean, required)
|
|
93
|
+
|
|
94
|
+
Indicates if Rubric is enabled
|
|
95
|
+
|
|
59
96
|
# `id` (string, required)
|
|
60
97
|
|
|
61
98
|
Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.
|
|
@@ -82,6 +119,22 @@ Indicates if the item has to be displayed in the Settings Panel
|
|
|
82
119
|
|
|
83
120
|
Indicates the label for the item that has to be displayed in the Settings Panel
|
|
84
121
|
|
|
122
|
+
## `ConfigureMaxImageDimensionsProp` (object)
|
|
123
|
+
|
|
124
|
+
Properties of the `ConfigureMaxImageDimensionsProp` object:
|
|
125
|
+
|
|
126
|
+
### `teacherInstructions` (number)
|
|
127
|
+
|
|
128
|
+
Indicates the max dimension for images in teacher instructions
|
|
129
|
+
|
|
130
|
+
### `prompt` (number)
|
|
131
|
+
|
|
132
|
+
Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
|
|
133
|
+
|
|
134
|
+
### `rationale` (number)
|
|
135
|
+
|
|
136
|
+
Indicates the max dimension for images in rationale
|
|
137
|
+
|
|
85
138
|
## `Choice` (object)
|
|
86
139
|
|
|
87
140
|
Properties of the `Choice` object:
|
package/lib/index.js
CHANGED
|
@@ -35,7 +35,7 @@ var _main = _interopRequireDefault(require("./main"));
|
|
|
35
35
|
|
|
36
36
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
37
37
|
|
|
38
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
38
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
39
39
|
|
|
40
40
|
var InlineDropdown = /*#__PURE__*/function (_HTMLElement) {
|
|
41
41
|
(0, _inherits2["default"])(InlineDropdown, _HTMLElement);
|
|
@@ -52,13 +52,20 @@ var InlineDropdown = /*#__PURE__*/function (_HTMLElement) {
|
|
|
52
52
|
var elem = /*#__PURE__*/_react["default"].createElement(_main["default"], {
|
|
53
53
|
teacherInstructions: _this._model.teacherInstructions,
|
|
54
54
|
prompt: _this._model.prompt,
|
|
55
|
+
note: _this._model.note,
|
|
56
|
+
showNote: _this._model.showNote,
|
|
57
|
+
env: _this._model.env,
|
|
55
58
|
rationale: _this._model.rationale,
|
|
56
59
|
disabled: _this._model.disabled,
|
|
57
60
|
choices: _this._model.choices,
|
|
58
61
|
markup: _this._model.markup,
|
|
59
62
|
mode: _this._model.mode,
|
|
63
|
+
maxLengthPerChoice: _this._model.maxLengthPerChoice,
|
|
64
|
+
maxLengthPerChoiceEnabled: _this._model.maxLengthPerChoiceEnabled,
|
|
65
|
+
playerSpellCheckEnabled: _this._model.playerSpellCheckEnabled,
|
|
60
66
|
value: _this._session.value,
|
|
61
67
|
feedback: _this._model.feedback,
|
|
68
|
+
displayType: _this._model.displayType,
|
|
62
69
|
onChange: _this.changeSession
|
|
63
70
|
});
|
|
64
71
|
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":["InlineDropdown","_model","_session","elem","React","createElement","Main","teacherInstructions","prompt","rationale","disabled","choices","markup","mode","value","feedback","onChange","changeSession","ReactDOM","render","dispatchEvent","SessionChangedEvent","tagName","toLowerCase","session","dispatchChangedEvent","_render","m","ModelSetEvent","s","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":["InlineDropdown","_model","_session","elem","React","createElement","Main","teacherInstructions","prompt","note","showNote","env","rationale","disabled","choices","markup","mode","maxLengthPerChoice","maxLengthPerChoiceEnabled","playerSpellCheckEnabled","value","feedback","displayType","onChange","changeSession","ReactDOM","render","dispatchEvent","SessionChangedEvent","tagName","toLowerCase","session","dispatchChangedEvent","_render","m","ModelSetEvent","s","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;;;;;IAEqBA,c;;;;;AACnB,4BAAc;AAAA;;AAAA;AACZ;AADY,gGAwBJ,YAAM;AACd,UAAI,MAAKC,MAAL,IAAe,MAAKC,QAAxB,EAAkC;AAChC,YAAIC,IAAI,gBAAGC,kBAAMC,aAAN,CAAoBC,gBAApB,EAA0B;AACnCC,UAAAA,mBAAmB,EAAE,MAAKN,MAAL,CAAYM,mBADE;AAEnCC,UAAAA,MAAM,EAAE,MAAKP,MAAL,CAAYO,MAFe;AAGnCC,UAAAA,IAAI,EAAE,MAAKR,MAAL,CAAYQ,IAHiB;AAInCC,UAAAA,QAAQ,EAAE,MAAKT,MAAL,CAAYS,QAJa;AAKnCC,UAAAA,GAAG,EAAE,MAAKV,MAAL,CAAYU,GALkB;AAMnCC,UAAAA,SAAS,EAAE,MAAKX,MAAL,CAAYW,SANY;AAOnCC,UAAAA,QAAQ,EAAE,MAAKZ,MAAL,CAAYY,QAPa;AAQnCC,UAAAA,OAAO,EAAE,MAAKb,MAAL,CAAYa,OARc;AASnCC,UAAAA,M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3F,CADF;;AAIA,WAAKgC,OAAL;AACD;;;SAOD,eAAc;AACZ,aAAO,KAAK/B,QAAZ;AACD,K;SAPD,aAAYkC,CAAZ,EAAe;AACb,WAAKlC,QAAL,GAAgBkC,CAAhB;;AACA,WAAKH,OAAL;AACD;;;WA4CD,6BAAoB;AAClB,WAAKA,OAAL;AACD;;;kDAjEyCI,W","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-events';\nimport { renderMath } from '@pie-lib/math-rendering';\n\nimport Main from './main';\n\nexport default class InlineDropdown extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._session = null;\n }\n\n set model(m) {\n this._model = m;\n this.dispatchEvent(\n new ModelSetEvent(this.tagName.toLowerCase(), this.session && !!this.session.value, !!this._model),\n );\n\n this._render();\n }\n\n set session(s) {\n this._session = s;\n this._render();\n }\n\n get session() {\n return this._session;\n }\n\n _render = () => {\n if (this._model && this._session) {\n let elem = React.createElement(Main, {\n teacherInstructions: this._model.teacherInstructions,\n prompt: this._model.prompt,\n note: this._model.note,\n showNote: this._model.showNote,\n env: this._model.env,\n rationale: this._model.rationale,\n disabled: this._model.disabled,\n choices: this._model.choices,\n markup: this._model.markup,\n mode: this._model.mode,\n maxLengthPerChoice: this._model.maxLengthPerChoice,\n maxLengthPerChoiceEnabled: this._model.maxLengthPerChoiceEnabled,\n playerSpellCheckEnabled: this._model.playerSpellCheckEnabled,\n value: this._session.value,\n feedback: this._model.feedback,\n displayType: this._model.displayType,\n onChange: this.changeSession,\n });\n\n ReactDOM.render(elem, this, () => {\n renderMath(this);\n });\n }\n };\n\n dispatchChangedEvent = () => {\n this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.session && !!this.session.value));\n };\n\n changeSession = (value) => {\n this.session.value = value;\n this.dispatchChangedEvent();\n this._render();\n };\n\n connectedCallback() {\n this._render();\n }\n}\n"],"file":"index.js"}
|