@pie-element/charting 5.11.3-next.93 → 6.0.0
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 +56 -0
- package/configure/CHANGELOG.md +53 -0
- package/configure/lib/charting-config.js +11 -5
- package/configure/lib/charting-config.js.map +1 -1
- package/configure/lib/configure.js +23 -7
- package/configure/lib/configure.js.map +1 -1
- package/configure/lib/correct-response.js +2 -2
- package/configure/lib/correct-response.js.map +1 -1
- package/configure/lib/defaults.js +31 -1
- package/configure/lib/defaults.js.map +1 -1
- package/configure/package.json +4 -4
- package/controller/CHANGELOG.md +22 -0
- package/controller/lib/index.js +2 -2
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +1 -1
- package/docs/config-schema.json +253 -17
- package/docs/config-schema.json.md +181 -13
- package/docs/pie-schema.json +158 -0
- package/docs/pie-schema.json.md +112 -0
- package/lib/main.js +3 -3
- package/lib/main.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/defaults.js"],"names":["model","addCategoryEnabled","chartType","correctAnswer","data","domain","graph","width","height","prompt","promptEnabled","rationale","range","label","max","min","scoringType","title","rationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","configuration","spellCheck","settings","enabled","chartDimensions","showInConfigPanel","step","authorNewCategoryDefaults","interactive","editable","
|
|
1
|
+
{"version":3,"sources":["../src/defaults.js"],"names":["model","addCategoryEnabled","chartType","correctAnswer","data","domain","graph","width","height","prompt","promptEnabled","rationale","range","label","max","min","scoringType","title","rationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","studentNewCategoryDefaultLabel","changeInteractiveEnabled","changeEditableEnabled","changeAddCategoryEnabled","configuration","spellCheck","settings","enabled","chartDimensions","showInConfigPanel","step","authorNewCategoryDefaults","interactive","editable","availableChartTypes","bar","histogram","lineDot","lineCross","dotPlot","linePlot","chartTypeLabel","settingsPanelDisabled","studentInstructions","teacherInstructions","titlePlaceholder","labelsPlaceholders","left","right","top","bottom","maxImageWidth","maxImageHeight","withRubric","chartingOptions","changeInteractive","authoringLabel","settingsLabel","changeEditable","addCategory"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;eAEe;AACbA,EAAAA,KAAK,EAAE;AACLC,IAAAA,kBAAkB,EAAE,IADf;AAELC,IAAAA,SAAS,EAAE,WAFN;AAGLC,IAAAA,aAAa,EAAE,EAHV;AAILC,IAAAA,IAAI,EAAE,EAJD;AAKLC,IAAAA,MAAM,EAAE,EALH;AAMLC,IAAAA,KAAK,EAAE;AACLC,MAAAA,KAAK,EAAE,GADF;AAELC,MAAAA,MAAM,EAAE;AAFH,KANF;AAULC,IAAAA,MAAM,EAAE,EAVH;AAWLC,IAAAA,aAAa,EAAE,IAXV;AAYLC,IAAAA,SAAS,EAAE,EAZN;AAaLC,IAAAA,KAAK,EAAE;AACLC,MAAAA,KAAK,EAAE,EADF;AAELC,MAAAA,GAAG,EAAE,CAFA;AAGLC,MAAAA,GAAG,EAAE;AAHA,KAbF;AAkBLC,IAAAA,WAAW,EAAE,gBAlBR;AAmBLC,IAAAA,KAAK,EAAE,EAnBF;AAoBLC,IAAAA,gBAAgB,EAAE,IApBb;AAqBLC,IAAAA,0BAA0B,EAAE,IArBvB;AAsBLC,IAAAA,0BAA0B,EAAE,IAtBvB;AAuBLC,IAAAA,8BAA8B,EAAE,cAvB3B;AAwBLC,IAAAA,wBAAwB,EAAE,IAxBrB;AAyBLC,IAAAA,qBAAqB,EAAE,IAzBlB;AA0BLC,IAAAA,wBAAwB,EAAE;AA1BrB,GADM;AA6BbC,EAAAA,aAAa,EAAE;AACbC,IAAAA,UAAU,EAAE;AACVb,MAAAA,KAAK,EAAE,YADG;AAEVc,MAAAA,QAAQ,EAAE,KAFA;AAGVC,MAAAA,OAAO,EAAE;AAHC,KADC;AAMbC,IAAAA,eAAe,EAAE;AACfF,MAAAA,QA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AA,aAAa,EAAE;AAHD,OAND;AAWfE,MAAAA,WAAW,EAAE;AACXjC,QAAAA,QAAQ,EAAE,KADC;AAEX8B,QAAAA,cAAc,EAAE,4BAFL;AAGXC,QAAAA,aAAa,EAAE;AAHJ;AAXE;AAzFJ;AA7BF,C","sourcesContent":["/**\n * NOTE: There's no functionality described for graphTitle,\n * rationale, scoringType, studentInstructions, teacherInstructions\n * so there's no implementation (they are only added in model)\n */\n\n// const createCategory = (label, value) => ({\n// label,\n// value,\n// interactive: true,\n// editable: true\n// });\n\nexport default {\n model: {\n addCategoryEnabled: true,\n chartType: 'lineCross',\n correctAnswer: {},\n data: [],\n domain: {},\n graph: {\n width: 480,\n height: 480,\n },\n prompt: '',\n promptEnabled: true,\n rationale: '',\n range: {\n label: '',\n max: 1,\n min: 0,\n },\n scoringType: 'all or nothing',\n title: '',\n rationaleEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n studentNewCategoryDefaultLabel: 'New Category',\n changeInteractiveEnabled: true,\n changeEditableEnabled: true,\n changeAddCategoryEnabled: true,\n },\n configuration: {\n spellCheck: {\n label: 'Spellcheck',\n settings: false,\n enabled: true,\n },\n chartDimensions: {\n settings: false,\n label: 'Chart Dimensions',\n showInConfigPanel: true,\n width: {\n min: 50,\n max: 700,\n step: 20,\n },\n height: {\n min: 400,\n max: 700,\n step: 20,\n },\n },\n authorNewCategoryDefaults: {\n settings: false,\n label: 'Category',\n interactive: true,\n editable: false,\n },\n availableChartTypes: {\n bar: 'Bar Chart',\n histogram: 'Histogram',\n lineDot: 'Line Chart ●',\n lineCross: 'Line Chart x',\n dotPlot: 'Dot/Line Plot ⬤',\n linePlot: 'Dot/Line Plot X',\n },\n chartTypeLabel: 'ChartType',\n studentNewCategoryDefaultLabel: {\n settings: false,\n label: 'Category',\n },\n prompt: {\n settings: true,\n label: 'Item Stem',\n },\n rationale: {\n settings: true,\n label: 'Rationale',\n },\n scoringType: {\n settings: false,\n label: 'Scoring Type',\n },\n settingsPanelDisabled: false,\n studentInstructions: {\n settings: false,\n label: 'Student Instructions',\n },\n teacherInstructions: {\n settings: true,\n label: 'Teacher Instructions',\n },\n title: {\n settings: false,\n label: 'Chart Title',\n },\n titlePlaceholder: {\n settings: false,\n label: 'Click here to add a title',\n },\n labelsPlaceholders: {\n left: 'Click here to add a label for this axis',\n right: '',\n top: '',\n bottom: 'Click here to add a label for this axis',\n },\n maxImageWidth: {\n teacherInstructions: 300,\n prompt: 300,\n rationale: 300,\n },\n maxImageHeight: {\n teacherInstructions: 300,\n prompt: 300,\n rationale: 300,\n },\n withRubric: {\n settings: false,\n label: 'Add Rubric',\n },\n chartingOptions: {\n changeInteractive: {\n settings: false,\n authoringLabel: 'Student can set value',\n settingsLabel: 'Allow non-interactive categories',\n },\n changeEditable: {\n settings: false,\n authoringLabel: 'Student can edit name',\n settingsLabel: 'Allow editable category names',\n },\n addCategory: {\n settings: false,\n authoringLabel: 'Student can add categories',\n settingsLabel: 'Allow changes to whether students can add categories',\n },\n },\n },\n};\n"],"file":"defaults.js"}
|
package/configure/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/charting-configure",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "6.0.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "src/index.js",
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@material-ui/core": "^3.9.2",
|
|
11
11
|
"@pie-framework/pie-configure-events": "^1.3.0",
|
|
12
|
-
"@pie-lib/charting": "^5.
|
|
13
|
-
"@pie-lib/config-ui": "^11.6.
|
|
14
|
-
"@pie-lib/editable-html": "^9.6.
|
|
12
|
+
"@pie-lib/charting": "^5.12.0",
|
|
13
|
+
"@pie-lib/config-ui": "^11.6.10",
|
|
14
|
+
"@pie-lib/editable-html": "^9.6.2",
|
|
15
15
|
"@pie-lib/math-rendering": "^2.5.14",
|
|
16
16
|
"classnames": "^2.2.5",
|
|
17
17
|
"debug": "^4.1.1",
|
package/controller/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.0.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-controller@2.4.2...@pie-element/charting-controller@3.0.0) (2023-05-23)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **charting:** move studentNewCategoryDefaultLabel from config to model, since it is needed in player ([60154f2](https://github.com/pie-framework/pie-elements/commit/60154f25ff1046b0cbcb3e65ccdb1126de85337f))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* **charting:** add authoring view settings for authorNewCategoryDefaults and studentNewCategoryDefaultLabel PD-2774 ([6b1d0dc](https://github.com/pie-framework/pie-elements/commit/6b1d0dc6f55779781ffeb50a69569a5ec8acf25a))
|
|
17
|
+
* **charting:** remove categoryDefaultLabel from model ([f1af01e](https://github.com/pie-framework/pie-elements/commit/f1af01e171e17b9e22a95025e0aef873bd4969a9))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### BREAKING CHANGES
|
|
21
|
+
|
|
22
|
+
* **charting:** The categoryDefaultLabel property has been removed. authorNewCategoryDefaults and studentNewCategoryDefaultLabel from configuration will be used as category default label.
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
## [2.4.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-controller@2.4.1...@pie-element/charting-controller@2.4.2) (2023-04-25)
|
|
7
29
|
|
|
8
30
|
|
package/controller/lib/index.js
CHANGED
|
@@ -215,7 +215,7 @@ function model(question, session, env) {
|
|
|
215
215
|
teacherInstructionsEnabled = normalizedQuestion.teacherInstructionsEnabled,
|
|
216
216
|
correctAnswer = normalizedQuestion.correctAnswer,
|
|
217
217
|
scoringType = normalizedQuestion.scoringType,
|
|
218
|
-
|
|
218
|
+
studentNewCategoryDefaultLabel = normalizedQuestion.studentNewCategoryDefaultLabel;
|
|
219
219
|
var correctInfo = {
|
|
220
220
|
correctness: 'incorrect',
|
|
221
221
|
score: '0%'
|
|
@@ -234,7 +234,7 @@ function model(question, session, env) {
|
|
|
234
234
|
correctness: correctInfo,
|
|
235
235
|
disabled: env.mode !== 'gather',
|
|
236
236
|
scoringType: scoringType,
|
|
237
|
-
|
|
237
|
+
studentNewCategoryDefaultLabel: studentNewCategoryDefaultLabel
|
|
238
238
|
};
|
|
239
239
|
var answers = filterCategories(getScore(normalizedQuestion, session, env).answers);
|
|
240
240
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":["log","lowerCase","string","toLowerCase","checkLabelsEquality","givenAnswerLabel","correctAnswerLabel","setCorrectness","answers","partialScoring","map","answer","correctness","value","label","normalize","question","addCategoryEnabled","promptEnabled","rationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","getScore","session","env","correctAnswer","data","initialData","scoringType","isPartialScoring","enabled","undefined","correctAnswers","defaultAnswers","filterCategories","result","maxScore","score","scoreForLabelAndValueEditable","corrAnswer","forEach","index","defaultAnswer","editable","interactive","length","slice","parseFloat","toFixed","categories","deletable","rest","model","Promise","resolve","normalizedQuestion","chartType","domain","graph","prompt","range","rationale","title","teacherInstructions","studentCategoryDefaultLabel","correctInfo","base","size","disabled","mode","correctedAnswer","role","outcome","empty","createCorrectResponseSession","id","validate","correctData","errors","correctAnswerErrors","categoryErrors","category","identicalAnswer","some","c","categoriesError","identicalError"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,kCAAN,CAAZ;;AAEA,IAA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AACtE,KAAF,KAAYA,KAAnB;AAAA,OAAjC,CAAxB;;AAEA,UAAIoE,eAAJ,EAAqB;AACnBF,QAAAA,cAAc,CAACvC,KAAK,GAAG,CAAT,CAAd,GAA4B,2BAA5B;AACD;AACF;AACF,GAZD;;AAcA,MAAIQ,UAAU,CAACJ,MAAX,GAAoB,CAApB,IAAyBI,UAAU,CAACJ,MAAX,GAAoB,EAAjD,EAAqD;AACnDkC,IAAAA,mBAAmB,CAACM,eAApB,GAAsC,gEAAtC;AACD,GAFD,MAEO,IACL,yBACE3D,IAAI,CAAChB,GAAL,CAAS,UAACuE,QAAD;AAAA,WAAc,sBAAKA,QAAL,EAAe,OAAf,EAAwB,OAAxB,CAAd;AAAA,GAAT,CADF,EAEEJ,WAAW,CAACnE,GAAZ,CAAgB,UAACuE,QAAD;AAAA,WAAc,sBAAKA,QAAL,EAAe,OAAf,EAAwB,OAAxB,CAAd;AAAA,GAAhB,CAFF,CADK,EAKL;AACAF,IAAAA,mBAAmB,CAACO,cAApB,GAAqC,qEAArC;AACD;;AAED,MAAI,CAAC,yBAAQN,cAAR,CAAL,EAA8B;AAC5BF,IAAAA,MAAM,CAACE,cAAP,GAAwBA,cAAxB;AACD;;AAED,MAAI,CAAC,yBAAQD,mBAAR,CAAL,EAAmC;AACjCD,IAAAA,MAAM,CAACC,mBAAP,GAA6BA,mBAA7B;AACD;;AAED,SAAOD,MAAP;AACD,CA3CM","sourcesContent":["import debug from 'debug';\nimport isEqual from 'lodash/isEqual';\nimport isEmpty from 'lodash/isEmpty';\nimport pick from 'lodash/pick';\n\nimport { partialScoring } from '@pie-lib/controller-utils';\n\nconst log = debug('@pie-element:graphing:controller');\n\nconst lowerCase = (string) => (string || '').toLowerCase();\n\nexport const checkLabelsEquality = (givenAnswerLabel, correctAnswerLabel) =>\n lowerCase(givenAnswerLabel) === lowerCase(correctAnswerLabel);\n\nexport const setCorrectness = (answers, partialScoring) =>\n answers\n ? answers.map((answer) => ({\n ...answer,\n correctness: {\n value: partialScoring ? 'incorrect' : 'correct',\n label: partialScoring ? 'incorrect' : 'correct',\n },\n }))\n : [];\n\nexport const normalize = (question) => ({\n addCategoryEnabled: true,\n promptEnabled: true,\n rationaleEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n ...question,\n});\n\nexport const getScore = (question, session, env = {}) => {\n const { correctAnswer, data: initialData = [], scoringType } = question;\n\n const isPartialScoring = partialScoring.enabled(\n { partialScoring: scoringType !== undefined ? scoringType === 'partial scoring' : scoringType },\n env,\n );\n\n const { data: correctAnswers = [] } = correctAnswer || {};\n const defaultAnswers = filterCategories(initialData);\n\n let answers = setCorrectness((session && session.answer) || defaultAnswers, isPartialScoring);\n\n let result = 0;\n\n if (isPartialScoring) {\n // if score type is \"partial scoring\"\n // maxScore is calculated based on the correct response\n // score is calculated based on the given response\n let maxScore = 0;\n let score = 0;\n\n const scoreForLabelAndValueEditable = (answer, corrAnswer) => {\n const { value, label } = answer;\n\n maxScore += 2;\n\n if (value === corrAnswer.value) {\n score += 1;\n answer.correctness.value = 'correct';\n }\n\n if (checkLabelsEquality(label, corrAnswer.label)) {\n score += 1;\n answer.correctness.label = 'correct';\n }\n };\n\n // if given answer has more categories than the correct answers, the \"extra\" will be ignored\n correctAnswers.forEach((corrAnswer, index) => {\n const defaultAnswer = defaultAnswers[index];\n const answer = answers[index];\n\n // if there is a corresponding category at the same position in the given answer\n if (answer) {\n // if there is a corresponding category at the same position in the default answer\n if (defaultAnswer) {\n // if category's label (in default answer) was not editable\n // it means that this category values only one point (only the value can be changed)\n if (!defaultAnswer.editable && answer.interactive) {\n maxScore += 1;\n\n if (answer.value === corrAnswer.value) {\n score += 1;\n answer.correctness.value = 'correct';\n }\n answer.correctness.label = 'correct';\n\n // if category's label (in default answer) was editable\n // it means that this category values 2 points (both label and value can be changed)\n } else if (defaultAnswer.editable && answer.interactive) {\n scoreForLabelAndValueEditable(answer, corrAnswer);\n } else if (!answer.interactive) {\n answer.correctness.value = 'correct';\n answer.correctness.label = 'correct';\n }\n } else {\n // if there is not a corresponding category at the same position in the default answer\n scoreForLabelAndValueEditable(answer, corrAnswer);\n }\n } else {\n // if there is not a corresponding category at the same position in the given answer\n // it means that the given answer has less categories than the correct answer\n maxScore += 2;\n }\n });\n\n result = maxScore ? score / maxScore : 0;\n } else {\n // if scoring type is \"all or nothing\"\n // the length on correct answers and length of given answer have to match\n result = correctAnswers.length === answers.length ? 1 : 0;\n\n if (result) {\n // if there is at least one difference between the correct answer and the given answer\n // the result will be incorrect\n correctAnswers.forEach((corrAnswer, index) => {\n const { value, label } = answers[index];\n\n if (value !== corrAnswer.value) {\n result = 0;\n answers[index].correctness.value = 'incorrect';\n }\n if (lowerCase(label) !== lowerCase(corrAnswer.label)) {\n result = 0;\n answers[index].correctness.label = 'incorrect';\n }\n });\n } else {\n answers = [\n ...answers.slice(0, correctAnswers.length),\n ...setCorrectness(answers.slice(correctAnswers.length), true),\n ];\n }\n }\n\n return {\n score: parseFloat(result.toFixed(2)),\n answers,\n };\n};\n\n// eslint-disable-next-line no-unused-vars\nexport const filterCategories = (categories) => (categories ? categories.map(({ deletable, ...rest }) => rest) : []);\n\nexport function model(question, session, env) {\n return new Promise((resolve) => {\n const normalizedQuestion = normalize(question);\n const {\n addCategoryEnabled,\n chartType,\n data,\n domain,\n graph,\n prompt,\n promptEnabled,\n range,\n rationale,\n title,\n rationaleEnabled,\n teacherInstructions,\n teacherInstructionsEnabled,\n correctAnswer,\n scoringType,\n studentCategoryDefaultLabel,\n } = normalizedQuestion;\n\n const correctInfo = { correctness: 'incorrect', score: '0%' };\n\n const base = {\n addCategoryEnabled,\n chartType,\n data: filterCategories(data),\n domain,\n graph,\n prompt: promptEnabled ? prompt : null,\n range,\n rationale,\n title,\n size: graph,\n correctness: correctInfo,\n disabled: env.mode !== 'gather',\n scoringType,\n studentCategoryDefaultLabel,\n };\n\n const answers = filterCategories(getScore(normalizedQuestion, session, env).answers);\n\n if (env.mode === 'view') {\n // eslint-disable-next-line no-unused-vars\n base.correctedAnswer = answers.map(({ correctness, ...rest }) => {\n return { ...rest, interactive: false };\n });\n\n base.addCategoryEnabled = false;\n }\n\n if (env.mode === 'evaluate') {\n base.correctedAnswer = answers;\n base.correctAnswer = correctAnswer;\n base.addCategoryEnabled = false;\n }\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n base.rationale = rationaleEnabled ? rationale : null;\n base.teacherInstructions = teacherInstructionsEnabled ? teacherInstructions : null;\n } else {\n base.rationale = null;\n base.teacherInstructions = null;\n }\n\n log('base: ', base);\n resolve(base);\n });\n}\n\nexport function outcome(model, session, env) {\n return new Promise((resolve) => {\n resolve({\n score: getScore(model, session, env).score,\n empty: !session || isEmpty(session),\n });\n });\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { correctAnswer } = question;\n\n let answers = correctAnswer && correctAnswer.data;\n\n // for IBX preview mode\n if (env.mode === 'gather') {\n const { data } = question;\n\n answers = ((correctAnswer && correctAnswer.data) || []).map((answer, index) => {\n return {\n ...data[index],\n ...answer,\n };\n });\n }\n\n resolve({\n answer: answers,\n id: '1',\n });\n } else {\n return resolve(null);\n }\n });\n};\n\nexport const validate = (model = {}) => {\n const { correctAnswer, data } = model || {};\n const { data: correctData } = correctAnswer || {};\n const categories = correctData || [];\n\n const errors = {};\n const correctAnswerErrors = {};\n const categoryErrors = {};\n\n categories.forEach((category, index) => {\n const { label } = category;\n\n if (label === '' || label === '<div></div>') {\n categoryErrors[index] = 'Content should not be empty.';\n } else {\n const identicalAnswer = categories.slice(index + 1).some((c) => c.label === label);\n\n if (identicalAnswer) {\n categoryErrors[index + 1] = 'Content should be unique.';\n }\n }\n });\n\n if (categories.length < 1 || categories.length > 20) {\n correctAnswerErrors.categoriesError = 'The correct answer should include between 1 and 20 categories.';\n } else if (\n isEqual(\n data.map((category) => pick(category, 'value', 'label')),\n correctData.map((category) => pick(category, 'value', 'label')),\n )\n ) {\n correctAnswerErrors.identicalError = 'Correct answer should not be identical to the chart’s initial state';\n }\n\n if (!isEmpty(categoryErrors)) {\n errors.categoryErrors = categoryErrors;\n }\n\n if (!isEmpty(correctAnswerErrors)) {\n errors.correctAnswerErrors = correctAnswerErrors;\n }\n\n return errors;\n};\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":["log","lowerCase","string","toLowerCase","checkLabelsEquality","givenAnswerLabel","correctAnswerLabel","setCorrectness","answers","partialScoring","map","answer","correctness","value","label","normalize","question","addCategoryEnabled","promptEnabled","rationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","getScore","session","env","correctAnswer","data","initialData","scoringType","isPartialScoring","enabled","undefined","correctAnswers","defaultAnswers","filterCategories","result","maxScore","score","scoreForLabelAndValueEditable","corrAnswer","forEach","index","defaultAnswer","editable","interactive","length","slice","parseFloat","toFixed","categories","deletable","rest","model","Promise","resolve","normalizedQuestion","chartType","domain","graph","prompt","range","rationale","title","teacherInstructions","studentNewCategoryDefaultLabel","correctInfo","base","size","disabled","mode","correctedAnswer","role","outcome","empty","createCorrectResponseSession","id","validate","correctData","errors","correctAnswerErrors","categoryErrors","category","identicalAnswer","some","c","categoriesError","identicalError"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,kCAAN,CAAZ;;AAEA,IAAMC,SAAS,GAAG,SAAZA,SAAY,CAACC,MAAD;AAAA,SAAY,CAACA,MAAM,IAAI,EAAX,EAAeC,WAAf,EAAZ;AAAA,CAAlB;;AAEO,IAAMC,mBAAmB,GAAG,SAAtBA,mBAAsB,CAACC,gBAAD,EAAmBC,kBAAnB;AAAA,SACjCL,SAAS,CAACI,gBAAD,CAAT,KAAgCJ,SAAS,CAACK,kBAAD,CADR;AAAA,CAA5B;;;;AAGA,IAAMC,cAAc,GAAG,SAAjBA,cAAiB,CA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GAFD,MAEO,IACL,yBACE3D,IAAI,CAAChB,GAAL,CAAS,UAACuE,QAAD;AAAA,WAAc,sBAAKA,QAAL,EAAe,OAAf,EAAwB,OAAxB,CAAd;AAAA,GAAT,CADF,EAEEJ,WAAW,CAACnE,GAAZ,CAAgB,UAACuE,QAAD;AAAA,WAAc,sBAAKA,QAAL,EAAe,OAAf,EAAwB,OAAxB,CAAd;AAAA,GAAhB,CAFF,CADK,EAKL;AACAF,IAAAA,mBAAmB,CAACO,cAApB,GAAqC,qEAArC;AACD;;AAED,MAAI,CAAC,yBAAQN,cAAR,CAAL,EAA8B;AAC5BF,IAAAA,MAAM,CAACE,cAAP,GAAwBA,cAAxB;AACD;;AAED,MAAI,CAAC,yBAAQD,mBAAR,CAAL,EAAmC;AACjCD,IAAAA,MAAM,CAACC,mBAAP,GAA6BA,mBAA7B;AACD;;AAED,SAAOD,MAAP;AACD,CA3CM","sourcesContent":["import debug from 'debug';\nimport isEqual from 'lodash/isEqual';\nimport isEmpty from 'lodash/isEmpty';\nimport pick from 'lodash/pick';\n\nimport { partialScoring } from '@pie-lib/controller-utils';\n\nconst log = debug('@pie-element:graphing:controller');\n\nconst lowerCase = (string) => (string || '').toLowerCase();\n\nexport const checkLabelsEquality = (givenAnswerLabel, correctAnswerLabel) =>\n lowerCase(givenAnswerLabel) === lowerCase(correctAnswerLabel);\n\nexport const setCorrectness = (answers, partialScoring) =>\n answers\n ? answers.map((answer) => ({\n ...answer,\n correctness: {\n value: partialScoring ? 'incorrect' : 'correct',\n label: partialScoring ? 'incorrect' : 'correct',\n },\n }))\n : [];\n\nexport const normalize = (question) => ({\n addCategoryEnabled: true,\n promptEnabled: true,\n rationaleEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n ...question,\n});\n\nexport const getScore = (question, session, env = {}) => {\n const { correctAnswer, data: initialData = [], scoringType } = question;\n\n const isPartialScoring = partialScoring.enabled(\n { partialScoring: scoringType !== undefined ? scoringType === 'partial scoring' : scoringType },\n env,\n );\n\n const { data: correctAnswers = [] } = correctAnswer || {};\n const defaultAnswers = filterCategories(initialData);\n\n let answers = setCorrectness((session && session.answer) || defaultAnswers, isPartialScoring);\n\n let result = 0;\n\n if (isPartialScoring) {\n // if score type is \"partial scoring\"\n // maxScore is calculated based on the correct response\n // score is calculated based on the given response\n let maxScore = 0;\n let score = 0;\n\n const scoreForLabelAndValueEditable = (answer, corrAnswer) => {\n const { value, label } = answer;\n\n maxScore += 2;\n\n if (value === corrAnswer.value) {\n score += 1;\n answer.correctness.value = 'correct';\n }\n\n if (checkLabelsEquality(label, corrAnswer.label)) {\n score += 1;\n answer.correctness.label = 'correct';\n }\n };\n\n // if given answer has more categories than the correct answers, the \"extra\" will be ignored\n correctAnswers.forEach((corrAnswer, index) => {\n const defaultAnswer = defaultAnswers[index];\n const answer = answers[index];\n\n // if there is a corresponding category at the same position in the given answer\n if (answer) {\n // if there is a corresponding category at the same position in the default answer\n if (defaultAnswer) {\n // if category's label (in default answer) was not editable\n // it means that this category values only one point (only the value can be changed)\n if (!defaultAnswer.editable && answer.interactive) {\n maxScore += 1;\n\n if (answer.value === corrAnswer.value) {\n score += 1;\n answer.correctness.value = 'correct';\n }\n answer.correctness.label = 'correct';\n\n // if category's label (in default answer) was editable\n // it means that this category values 2 points (both label and value can be changed)\n } else if (defaultAnswer.editable && answer.interactive) {\n scoreForLabelAndValueEditable(answer, corrAnswer);\n } else if (!answer.interactive) {\n answer.correctness.value = 'correct';\n answer.correctness.label = 'correct';\n }\n } else {\n // if there is not a corresponding category at the same position in the default answer\n scoreForLabelAndValueEditable(answer, corrAnswer);\n }\n } else {\n // if there is not a corresponding category at the same position in the given answer\n // it means that the given answer has less categories than the correct answer\n maxScore += 2;\n }\n });\n\n result = maxScore ? score / maxScore : 0;\n } else {\n // if scoring type is \"all or nothing\"\n // the length on correct answers and length of given answer have to match\n result = correctAnswers.length === answers.length ? 1 : 0;\n\n if (result) {\n // if there is at least one difference between the correct answer and the given answer\n // the result will be incorrect\n correctAnswers.forEach((corrAnswer, index) => {\n const { value, label } = answers[index];\n\n if (value !== corrAnswer.value) {\n result = 0;\n answers[index].correctness.value = 'incorrect';\n }\n if (lowerCase(label) !== lowerCase(corrAnswer.label)) {\n result = 0;\n answers[index].correctness.label = 'incorrect';\n }\n });\n } else {\n answers = [\n ...answers.slice(0, correctAnswers.length),\n ...setCorrectness(answers.slice(correctAnswers.length), true),\n ];\n }\n }\n\n return {\n score: parseFloat(result.toFixed(2)),\n answers,\n };\n};\n\n// eslint-disable-next-line no-unused-vars\nexport const filterCategories = (categories) => (categories ? categories.map(({ deletable, ...rest }) => rest) : []);\n\nexport function model(question, session, env) {\n return new Promise((resolve) => {\n const normalizedQuestion = normalize(question);\n const {\n addCategoryEnabled,\n chartType,\n data,\n domain,\n graph,\n prompt,\n promptEnabled,\n range,\n rationale,\n title,\n rationaleEnabled,\n teacherInstructions,\n teacherInstructionsEnabled,\n correctAnswer,\n scoringType,\n studentNewCategoryDefaultLabel,\n } = normalizedQuestion;\n\n const correctInfo = { correctness: 'incorrect', score: '0%' };\n\n const base = {\n addCategoryEnabled,\n chartType,\n data: filterCategories(data),\n domain,\n graph,\n prompt: promptEnabled ? prompt : null,\n range,\n rationale,\n title,\n size: graph,\n correctness: correctInfo,\n disabled: env.mode !== 'gather',\n scoringType,\n studentNewCategoryDefaultLabel,\n };\n\n const answers = filterCategories(getScore(normalizedQuestion, session, env).answers);\n\n if (env.mode === 'view') {\n // eslint-disable-next-line no-unused-vars\n base.correctedAnswer = answers.map(({ correctness, ...rest }) => {\n return { ...rest, interactive: false };\n });\n\n base.addCategoryEnabled = false;\n }\n\n if (env.mode === 'evaluate') {\n base.correctedAnswer = answers;\n base.correctAnswer = correctAnswer;\n base.addCategoryEnabled = false;\n }\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n base.rationale = rationaleEnabled ? rationale : null;\n base.teacherInstructions = teacherInstructionsEnabled ? teacherInstructions : null;\n } else {\n base.rationale = null;\n base.teacherInstructions = null;\n }\n\n log('base: ', base);\n resolve(base);\n });\n}\n\nexport function outcome(model, session, env) {\n return new Promise((resolve) => {\n resolve({\n score: getScore(model, session, env).score,\n empty: !session || isEmpty(session),\n });\n });\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { correctAnswer } = question;\n\n let answers = correctAnswer && correctAnswer.data;\n\n // for IBX preview mode\n if (env.mode === 'gather') {\n const { data } = question;\n\n answers = ((correctAnswer && correctAnswer.data) || []).map((answer, index) => {\n return {\n ...data[index],\n ...answer,\n };\n });\n }\n\n resolve({\n answer: answers,\n id: '1',\n });\n } else {\n return resolve(null);\n }\n });\n};\n\nexport const validate = (model = {}) => {\n const { correctAnswer, data } = model || {};\n const { data: correctData } = correctAnswer || {};\n const categories = correctData || [];\n\n const errors = {};\n const correctAnswerErrors = {};\n const categoryErrors = {};\n\n categories.forEach((category, index) => {\n const { label } = category;\n\n if (label === '' || label === '<div></div>') {\n categoryErrors[index] = 'Content should not be empty.';\n } else {\n const identicalAnswer = categories.slice(index + 1).some((c) => c.label === label);\n\n if (identicalAnswer) {\n categoryErrors[index + 1] = 'Content should be unique.';\n }\n }\n });\n\n if (categories.length < 1 || categories.length > 20) {\n correctAnswerErrors.categoriesError = 'The correct answer should include between 1 and 20 categories.';\n } else if (\n isEqual(\n data.map((category) => pick(category, 'value', 'label')),\n correctData.map((category) => pick(category, 'value', 'label')),\n )\n ) {\n correctAnswerErrors.identicalError = 'Correct answer should not be identical to the chart’s initial state';\n }\n\n if (!isEmpty(categoryErrors)) {\n errors.categoryErrors = categoryErrors;\n }\n\n if (!isEmpty(correctAnswerErrors)) {\n errors.correctAnswerErrors = correctAnswerErrors;\n }\n\n return errors;\n};\n"],"file":"index.js"}
|
package/controller/package.json
CHANGED
package/docs/config-schema.json
CHANGED
|
@@ -208,22 +208,6 @@
|
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
210
|
},
|
|
211
|
-
"studentNewCategoryDefaultLabel": {
|
|
212
|
-
"title": "ConfigureProp",
|
|
213
|
-
"type": "object",
|
|
214
|
-
"properties": {
|
|
215
|
-
"settings": {
|
|
216
|
-
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
217
|
-
"type": "boolean",
|
|
218
|
-
"title": "settings"
|
|
219
|
-
},
|
|
220
|
-
"label": {
|
|
221
|
-
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
222
|
-
"type": "string",
|
|
223
|
-
"title": "label"
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
},
|
|
227
211
|
"maxImageWidth": {
|
|
228
212
|
"title": "ConfigureMaxImageDimensionsProp",
|
|
229
213
|
"type": "object",
|
|
@@ -282,6 +266,124 @@
|
|
|
282
266
|
}
|
|
283
267
|
}
|
|
284
268
|
},
|
|
269
|
+
"chartingOptions": {
|
|
270
|
+
"title": "ChartingOptions",
|
|
271
|
+
"type": "object",
|
|
272
|
+
"properties": {
|
|
273
|
+
"changeInteractive": {
|
|
274
|
+
"title": "ChartingOption",
|
|
275
|
+
"type": "object",
|
|
276
|
+
"properties": {
|
|
277
|
+
"settings": {
|
|
278
|
+
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
279
|
+
"type": "boolean",
|
|
280
|
+
"title": "settings"
|
|
281
|
+
},
|
|
282
|
+
"authoringLabel": {
|
|
283
|
+
"description": "Indicates the label for the option",
|
|
284
|
+
"type": "string",
|
|
285
|
+
"title": "authoringLabel"
|
|
286
|
+
},
|
|
287
|
+
"settingsLabel": {
|
|
288
|
+
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
289
|
+
"type": "string",
|
|
290
|
+
"title": "settingsLabel"
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
"changeEditable": {
|
|
295
|
+
"title": "ChartingOption",
|
|
296
|
+
"type": "object",
|
|
297
|
+
"properties": {
|
|
298
|
+
"settings": {
|
|
299
|
+
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
300
|
+
"type": "boolean",
|
|
301
|
+
"title": "settings"
|
|
302
|
+
},
|
|
303
|
+
"authoringLabel": {
|
|
304
|
+
"description": "Indicates the label for the option",
|
|
305
|
+
"type": "string",
|
|
306
|
+
"title": "authoringLabel"
|
|
307
|
+
},
|
|
308
|
+
"settingsLabel": {
|
|
309
|
+
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
310
|
+
"type": "string",
|
|
311
|
+
"title": "settingsLabel"
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
"addCategory": {
|
|
316
|
+
"title": "ChartingOption",
|
|
317
|
+
"type": "object",
|
|
318
|
+
"properties": {
|
|
319
|
+
"settings": {
|
|
320
|
+
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
321
|
+
"type": "boolean",
|
|
322
|
+
"title": "settings"
|
|
323
|
+
},
|
|
324
|
+
"authoringLabel": {
|
|
325
|
+
"description": "Indicates the label for the option",
|
|
326
|
+
"type": "string",
|
|
327
|
+
"title": "authoringLabel"
|
|
328
|
+
},
|
|
329
|
+
"settingsLabel": {
|
|
330
|
+
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
331
|
+
"type": "string",
|
|
332
|
+
"title": "settingsLabel"
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
"availableChartTypes": {
|
|
339
|
+
"title": "AvailableChartTypes",
|
|
340
|
+
"type": "object",
|
|
341
|
+
"properties": {
|
|
342
|
+
"bar": {
|
|
343
|
+
"description": "Indicates if bar chart is available and the label used for it.",
|
|
344
|
+
"type": "string",
|
|
345
|
+
"title": "bar"
|
|
346
|
+
},
|
|
347
|
+
"histogram": {
|
|
348
|
+
"description": "Indicates if histogram is available and the label used for it.",
|
|
349
|
+
"type": "string",
|
|
350
|
+
"title": "histogram"
|
|
351
|
+
},
|
|
352
|
+
"lineDot": {
|
|
353
|
+
"description": "Indicates if line chart with dots is available and the label used for it.",
|
|
354
|
+
"type": "string",
|
|
355
|
+
"title": "lineDot"
|
|
356
|
+
},
|
|
357
|
+
"lineCross": {
|
|
358
|
+
"description": "Indicates if line chart with crosses is available and the label used for it.",
|
|
359
|
+
"type": "string",
|
|
360
|
+
"title": "lineCross"
|
|
361
|
+
},
|
|
362
|
+
"dotPlot": {
|
|
363
|
+
"description": "Indicates if dot plot is available and the label used for it.",
|
|
364
|
+
"type": "string",
|
|
365
|
+
"title": "dotPlot"
|
|
366
|
+
},
|
|
367
|
+
"linePlot": {
|
|
368
|
+
"description": "Indicates if line plot is available and the label used for it.",
|
|
369
|
+
"type": "string",
|
|
370
|
+
"title": "linePlot"
|
|
371
|
+
}
|
|
372
|
+
},
|
|
373
|
+
"required": [
|
|
374
|
+
"bar",
|
|
375
|
+
"dotPlot",
|
|
376
|
+
"histogram",
|
|
377
|
+
"lineCross",
|
|
378
|
+
"lineDot",
|
|
379
|
+
"linePlot"
|
|
380
|
+
]
|
|
381
|
+
},
|
|
382
|
+
"chartTypeLabel": {
|
|
383
|
+
"description": "Indicates the label for the chart type",
|
|
384
|
+
"type": "string",
|
|
385
|
+
"title": "chartTypeLabel"
|
|
386
|
+
},
|
|
285
387
|
"showPrompt": {
|
|
286
388
|
"description": "Determines whether prompt field will be displayed or not",
|
|
287
389
|
"default": true,
|
|
@@ -347,7 +449,7 @@
|
|
|
347
449
|
},
|
|
348
450
|
"required": [
|
|
349
451
|
"authorNewCategoryDefaults",
|
|
350
|
-
"
|
|
452
|
+
"chartTypeLabel"
|
|
351
453
|
],
|
|
352
454
|
"definitions": {
|
|
353
455
|
"ConfigureProp": {
|
|
@@ -474,6 +576,140 @@
|
|
|
474
576
|
"title": "rationale"
|
|
475
577
|
}
|
|
476
578
|
}
|
|
579
|
+
},
|
|
580
|
+
"ChartingOptions": {
|
|
581
|
+
"title": "ChartingOptions",
|
|
582
|
+
"type": "object",
|
|
583
|
+
"properties": {
|
|
584
|
+
"changeInteractive": {
|
|
585
|
+
"title": "ChartingOption",
|
|
586
|
+
"type": "object",
|
|
587
|
+
"properties": {
|
|
588
|
+
"settings": {
|
|
589
|
+
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
590
|
+
"type": "boolean",
|
|
591
|
+
"title": "settings"
|
|
592
|
+
},
|
|
593
|
+
"authoringLabel": {
|
|
594
|
+
"description": "Indicates the label for the option",
|
|
595
|
+
"type": "string",
|
|
596
|
+
"title": "authoringLabel"
|
|
597
|
+
},
|
|
598
|
+
"settingsLabel": {
|
|
599
|
+
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
600
|
+
"type": "string",
|
|
601
|
+
"title": "settingsLabel"
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
},
|
|
605
|
+
"changeEditable": {
|
|
606
|
+
"title": "ChartingOption",
|
|
607
|
+
"type": "object",
|
|
608
|
+
"properties": {
|
|
609
|
+
"settings": {
|
|
610
|
+
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
611
|
+
"type": "boolean",
|
|
612
|
+
"title": "settings"
|
|
613
|
+
},
|
|
614
|
+
"authoringLabel": {
|
|
615
|
+
"description": "Indicates the label for the option",
|
|
616
|
+
"type": "string",
|
|
617
|
+
"title": "authoringLabel"
|
|
618
|
+
},
|
|
619
|
+
"settingsLabel": {
|
|
620
|
+
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
621
|
+
"type": "string",
|
|
622
|
+
"title": "settingsLabel"
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
},
|
|
626
|
+
"addCategory": {
|
|
627
|
+
"title": "ChartingOption",
|
|
628
|
+
"type": "object",
|
|
629
|
+
"properties": {
|
|
630
|
+
"settings": {
|
|
631
|
+
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
632
|
+
"type": "boolean",
|
|
633
|
+
"title": "settings"
|
|
634
|
+
},
|
|
635
|
+
"authoringLabel": {
|
|
636
|
+
"description": "Indicates the label for the option",
|
|
637
|
+
"type": "string",
|
|
638
|
+
"title": "authoringLabel"
|
|
639
|
+
},
|
|
640
|
+
"settingsLabel": {
|
|
641
|
+
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
642
|
+
"type": "string",
|
|
643
|
+
"title": "settingsLabel"
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
},
|
|
649
|
+
"ChartingOption": {
|
|
650
|
+
"title": "ChartingOption",
|
|
651
|
+
"type": "object",
|
|
652
|
+
"properties": {
|
|
653
|
+
"settings": {
|
|
654
|
+
"description": "Indicates if the item has to be displayed in the Settings Panel",
|
|
655
|
+
"type": "boolean",
|
|
656
|
+
"title": "settings"
|
|
657
|
+
},
|
|
658
|
+
"authoringLabel": {
|
|
659
|
+
"description": "Indicates the label for the option",
|
|
660
|
+
"type": "string",
|
|
661
|
+
"title": "authoringLabel"
|
|
662
|
+
},
|
|
663
|
+
"settingsLabel": {
|
|
664
|
+
"description": "Indicates the label for the item that has to be displayed in the Settings Panel",
|
|
665
|
+
"type": "string",
|
|
666
|
+
"title": "settingsLabel"
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
},
|
|
670
|
+
"AvailableChartTypes": {
|
|
671
|
+
"title": "AvailableChartTypes",
|
|
672
|
+
"type": "object",
|
|
673
|
+
"properties": {
|
|
674
|
+
"bar": {
|
|
675
|
+
"description": "Indicates if bar chart is available and the label used for it.",
|
|
676
|
+
"type": "string",
|
|
677
|
+
"title": "bar"
|
|
678
|
+
},
|
|
679
|
+
"histogram": {
|
|
680
|
+
"description": "Indicates if histogram is available and the label used for it.",
|
|
681
|
+
"type": "string",
|
|
682
|
+
"title": "histogram"
|
|
683
|
+
},
|
|
684
|
+
"lineDot": {
|
|
685
|
+
"description": "Indicates if line chart with dots is available and the label used for it.",
|
|
686
|
+
"type": "string",
|
|
687
|
+
"title": "lineDot"
|
|
688
|
+
},
|
|
689
|
+
"lineCross": {
|
|
690
|
+
"description": "Indicates if line chart with crosses is available and the label used for it.",
|
|
691
|
+
"type": "string",
|
|
692
|
+
"title": "lineCross"
|
|
693
|
+
},
|
|
694
|
+
"dotPlot": {
|
|
695
|
+
"description": "Indicates if dot plot is available and the label used for it.",
|
|
696
|
+
"type": "string",
|
|
697
|
+
"title": "dotPlot"
|
|
698
|
+
},
|
|
699
|
+
"linePlot": {
|
|
700
|
+
"description": "Indicates if line plot is available and the label used for it.",
|
|
701
|
+
"type": "string",
|
|
702
|
+
"title": "linePlot"
|
|
703
|
+
}
|
|
704
|
+
},
|
|
705
|
+
"required": [
|
|
706
|
+
"bar",
|
|
707
|
+
"dotPlot",
|
|
708
|
+
"histogram",
|
|
709
|
+
"lineCross",
|
|
710
|
+
"lineDot",
|
|
711
|
+
"linePlot"
|
|
712
|
+
]
|
|
477
713
|
}
|
|
478
714
|
},
|
|
479
715
|
"$schema": "http://json-schema.org/draft-07/schema#"
|