@pie-element/charting 2.7.29 → 4.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 +42 -0
- package/configure/CHANGELOG.md +42 -0
- package/configure/lib/charting-config.js +23 -4
- package/configure/lib/charting-config.js.map +1 -1
- package/configure/lib/configure.js +21 -13
- package/configure/lib/configure.js.map +1 -1
- package/configure/lib/correct-response.js +161 -41
- package/configure/lib/correct-response.js.map +1 -1
- package/configure/lib/defaults.js +11 -4
- package/configure/lib/defaults.js.map +1 -1
- package/configure/package.json +4 -4
- package/controller/CHANGELOG.md +16 -0
- package/controller/lib/index.js +24 -20
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +1 -1
- package/docs/config-schema.json +63 -0
- package/docs/config-schema.json.md +49 -1
- package/docs/demo/generate.js +6 -26
- package/docs/demo/session.js +3 -9
- package/docs/pie-schema.json +21 -48
- package/docs/pie-schema.json.md +16 -8
- package/lib/main.js +0 -3
- package/lib/main.js.map +1 -1
- package/package.json +6 -6
- package/configure/lib/chart-type.js +0 -72
- package/configure/lib/chart-type.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/correct-response.jsx"],"names":["styles","theme","container","border","borderRadius","padding","spacing","unit","background","button","marginTop","cursor","width","CorrectResponse","data","props","model","onChange","correctAnswer","value","editCategoryEnabled","addCategoryEnabled","classes","charts","name","chartType","graph","domain","range","title","changeData","categoryDefaultLabel","e","changeEditable","target","checked","changeAddRemoveEnabled","React","Component","PropTypes","object","isRequired","func","array"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;AAAA,SAAK;AACvBC,IAAAA,SAAS,EAAE;AACTC,MAAAA,MAAM,EAAE,mBADC;AAETC,MAAAA,YAAY,EAAE,KAFL;AAGTC,MAA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CADF;AAyCD;;;EArEkCE,KAAK,CAACC,S;;;iCAA9BzB,e,eACQ;AACjBS,EAAAA,OAAO,EAAEiB,sBAAUC,MAAV,CAAiBC,UADT;AAEjBzB,EAAAA,KAAK,EAAEuB,sBAAUC,MAAV,CAAiBC,UAFP;AAGjBxB,EAAAA,QAAQ,EAAEsB,sBAAUG,IAAV,CAAeD,UAHR;AAIjBlB,EAAAA,MAAM,EAAEgB,sBAAUI;AAJD,C;;eAuEN,wBAAW3C,MAAX,EAAmBa,eAAnB,C","sourcesContent":["import * as React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport Checkbox from '@material-ui/core/Checkbox';\nimport { Chart } from '@pie-lib/charting';\n\nconst styles = theme => ({\n container: {\n border: '2px solid #ababab',\n borderRadius: '4px',\n padding: `${theme.spacing.unit * 2}px ${theme.spacing.unit * 4}px`,\n background: '#fafafa'\n },\n button: {\n marginTop: theme.spacing.unit * 3,\n cursor: 'pointer',\n background: '#eee',\n padding: theme.spacing.unit * 2,\n width: 'fit-content',\n borderRadius: '4px'\n }\n});\n\nexport class CorrectResponse extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n model: PropTypes.object.isRequired,\n onChange: PropTypes.func.isRequired,\n charts: PropTypes.array\n };\n\n changeData = data => {\n const { model, onChange } = this.props;\n const { correctAnswer } = model || {};\n\n onChange({\n ...model,\n correctAnswer: {\n ...correctAnswer,\n data\n }\n });\n };\n\n changeEditable = value => this.props.onChange({ ...this.props.model, editCategoryEnabled: value });\n\n changeAddRemoveEnabled = value => this.props.onChange({ ...this.props.model, addCategoryEnabled: value });\n\n render() {\n const { classes, model, charts } = this.props;\n\n return (\n <div>\n Define Correct Response\n <div className={classes.container}>\n <div key={`correct-response-graph-${model.correctAnswer.name}`}>\n <p>{model.correctAnswer.name}</p>\n <Chart\n chartType={model.chartType}\n size={model.graph}\n domain={model.domain}\n range={model.range}\n charts={charts}\n data={model.correctAnswer.data || []}\n title={model.title}\n onDataChange={(data) => this.changeData(data)}\n editCategoryEnabled={true}\n addCategoryEnabled={true}\n categoryDefaultLabel={model.categoryDefaultLabel}\n />\n <div>\n <Checkbox\n checked={model.editCategoryEnabled}\n onChange={(e) => {\n this.changeEditable(e.target.checked)\n }}\n />\n Student can edit category labels\n </div>\n <div>\n <Checkbox\n checked={model.addCategoryEnabled}\n onChange={(e) => {\n this.changeAddRemoveEnabled(e.target.checked)\n }}\n />\n Student can add/remove category labels\n </div>\n </div>\n </div>\n </div>\n );\n }\n}\n\nexport default withStyles(styles)(CorrectResponse);\n"],"file":"correct-response.js"}
|
|
1
|
+
{"version":3,"sources":["../src/correct-response.jsx"],"names":["styles","theme","container","border","borderRadius","padding","spacing","unit","background","button","marginTop","cursor","width","addCategoryProps","correctAnswer","data","map","correct","index","editable","length","interactive","deletable","updateCorrectResponseData","correctAnswerData","correctResponseDefinition","forEach","category","currentIndex","label","value","missingCategories","slice","concat","insertCategory","positionToInsert","categoryToInsert","splice","removeCategory","positionToRemove","CorrectResponse","props","model","onChange","keepAttrs","state","categories","nextProps","nextData","nextCorrectAnswerData","nextCategories","removedIndex","answer","dataExists","setState","charts","name","chartType","graph","domain","range","title","changeData","addCategoryEnabled","categoryDefaultLabel","React","Component","classes","PropTypes","object","isRequired","func","array"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBC,IAAAA,SAAS,EAAE;AACTC,MAAAA,MAAM,EAAE,mBADC;AAETC,MAAAA,YAAY,EAAE,KAFL;AAGTC,MAAAA,OAAO,YAAKJ,KAAK,CAACK,OAAN,CAAcC,IAAd,GAAqB,CAA1B,gBAAiCN,KAAK,CAACK,OAAN,CAAcC,IAAd,GAAqB,CAAtD,OAHE;AAITC,MAAAA,UAAU,EAAE;AAJH,KADc;AAOzBC,IAA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,eACQ;AACjB2B,EAAAA,OAAO,EAAEC,sBAAUC,MAAV,CAAiBC,UADT;AAEjB5B,EAAAA,KAAK,EAAE0B,sBAAUC,MAAV,CAAiBC,UAFP;AAGjB3B,EAAAA,QAAQ,EAAEyB,sBAAUG,IAAV,CAAeD,UAHR;AAIjBf,EAAAA,MAAM,EAAEa,sBAAUI;AAJD,C;;eAiIN,wBAAWxE,MAAX,EAAmBwC,eAAnB,C","sourcesContent":["import * as React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport { Chart } from '@pie-lib/charting';\nimport isEqual from 'lodash/isEqual';\nimport isEmpty from 'lodash/isEmpty';\n\nconst styles = (theme) => ({\n container: {\n border: '2px solid #ababab',\n borderRadius: '4px',\n padding: `${theme.spacing.unit * 2}px ${theme.spacing.unit * 4}px`,\n background: '#fafafa',\n },\n button: {\n marginTop: theme.spacing.unit * 3,\n cursor: 'pointer',\n background: '#eee',\n padding: theme.spacing.unit * 2,\n width: 'fit-content',\n borderRadius: '4px',\n },\n});\n\nconst addCategoryProps = (correctAnswer, data) => correctAnswer.map((correct, index) => ({ ...correct, editable: index < data.length ? data[index].editable : true, interactive: index < data.length ? data[index].interactive : true, deletable: index >= data.length ? true : false }));\n\nconst updateCorrectResponseData = (correctAnswer, data) => {\n if (!correctAnswer) {\n return data;\n }\n\n const correctAnswerData = [...correctAnswer];\n\n let correctResponseDefinition = [];\n\n data.forEach((category, currentIndex) => {\n const editable = category.editable;\n const interactive = category.interactive;\n\n const label = (editable && correctAnswer[currentIndex]?.label)\n ? correctAnswer[currentIndex].label\n : category.label\n\n const value = (interactive && correctAnswer[currentIndex]?.value)\n ? correctAnswer[currentIndex].value\n : category.value\n\n correctResponseDefinition[currentIndex] = {\n label: label,\n value: value,\n editable: category.editable,\n interactive: category.interactive,\n };\n });\n\n if (correctResponseDefinition.length < correctAnswer.length) {\n const missingCategories = correctAnswerData.slice(correctResponseDefinition.length, correctAnswer.length)\n\n return addCategoryProps(correctResponseDefinition.concat(missingCategories), data);\n }\n\n return correctResponseDefinition;\n};\n\nconst insertCategory = (correctAnswer, data) => {\n const positionToInsert = data.length - 1;\n const { editable, interactive, deletable, ...categoryToInsert } = data[data.length - 1];\n\n correctAnswer.splice(positionToInsert, 0, categoryToInsert);\n const correctAnswerData = [...correctAnswer];\n\n return addCategoryProps(correctAnswerData, data);\n}\n\nconst removeCategory = (correctAnswer, data, positionToRemove) => {\n correctAnswer.splice(positionToRemove, 1);\n\n const correctAnswerData = [...correctAnswer];\n\n return addCategoryProps(correctAnswerData, data);\n}\nexport class CorrectResponse extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n model: PropTypes.object.isRequired,\n onChange: PropTypes.func.isRequired,\n charts: PropTypes.array,\n };\n\n constructor(props) {\n super(props);\n this.state = {\n categories: updateCorrectResponseData(\n props.model.correctAnswer.data,\n props.model.data\n )\n };\n }\n\n changeData = (data) => {\n const { model, onChange } = this.props;\n const { correctAnswer } = model || {};\n\n onChange({\n ...model,\n correctAnswer: {\n ...correctAnswer,\n data: data.map(({ interactive, editable, index, ...keepAttrs }) => keepAttrs),\n },\n });\n };\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n const {\n model: {\n data: nextData = [],\n correctAnswer: { data: nextCorrectAnswerData = [] },\n } = {},\n } = nextProps;\n\n const {\n model: {\n data = [],\n } = {},\n } = this.props;\n\n const { categories } = this.state;\n let nextCategories = [];\n\n if (nextData.length > data.length && nextCorrectAnswerData.length > data.length) {\n nextCategories = insertCategory(nextCorrectAnswerData, nextData);\n }\n\n if (nextData.length < data.length) {\n let removedIndex = nextData.length;\n\n // we need to remove the category from the correct answer data and categories, from the same index it was removed from the data\n // index is a property of the nextData category\n for (let index = 0; index < nextData.length; index++) {\n if (nextData[index].index !== index) {\n removedIndex = index;\n break;\n }\n }\n\n this.props.model.correctAnswer.data.splice(removedIndex, 1);\n nextCategories = removeCategory(categories, nextData, removedIndex);\n }\n\n if (!isEqual(nextCorrectAnswerData, this.props.model.correctAnswer.data)) {\n nextCategories = nextCorrectAnswerData.map((correct, index) => ({ ...correct, editable: index < data.length ? data[index].editable : true, interactive: index < data.length ? data[index].interactive : true }));\n }else if (isEmpty(nextCategories)) {\n nextCategories = updateCorrectResponseData(\n nextCorrectAnswerData,\n nextData\n );\n\n nextCorrectAnswerData.map((answer, currentIndex) => {\n const dataExists = currentIndex < nextData.length;\n let label;\n let value;\n let deletable;\n\n if (dataExists) {\n label = nextData[currentIndex].editable ? answer.label : nextData[currentIndex].label;\n value = nextData[currentIndex].interactive ? answer.value : nextData[currentIndex].value;\n } else {\n label = answer.label;\n value = answer.value;\n deletable = true;\n }\n\n nextCorrectAnswerData[currentIndex] = {\n label: label,\n value: value,\n };\n });\n }\n\n if (!isEqual(nextCategories, data)) {\n this.setState({ categories: nextCategories });\n }\n }\n\n render() {\n const { model, charts } = this.props;\n const { categories } = this.state;\n\n return (\n <div>\n Define Correct Response\n <div key={`correct-response-graph-${model.correctAnswer.name}`}>\n <p>{model.correctAnswer.name}</p>\n <Chart\n chartType={model.chartType}\n size={model.graph}\n domain={model.domain}\n range={model.range}\n charts={charts}\n data={categories}\n title={model.title}\n onDataChange={(data) => this.changeData(data)}\n addCategoryEnabled={model.addCategoryEnabled}\n categoryDefaultLabel={model.categoryDefaultLabel}\n />\n </div>\n </div>\n );\n }\n}\n\nexport default withStyles(styles)(CorrectResponse);\n"],"file":"correct-response.js"}
|
|
@@ -13,10 +13,8 @@ exports["default"] = void 0;
|
|
|
13
13
|
// const createCategory = (label, value) => ({
|
|
14
14
|
// label,
|
|
15
15
|
// value,
|
|
16
|
-
// initial: true,
|
|
17
16
|
// interactive: true,
|
|
18
|
-
// editable: true
|
|
19
|
-
// deletable: true
|
|
17
|
+
// editable: true
|
|
20
18
|
// });
|
|
21
19
|
var _default = {
|
|
22
20
|
model: {
|
|
@@ -28,7 +26,6 @@ var _default = {
|
|
|
28
26
|
domain: {
|
|
29
27
|
label: 'Fruits'
|
|
30
28
|
},
|
|
31
|
-
editCategoryEnabled: true,
|
|
32
29
|
graph: {
|
|
33
30
|
width: 480,
|
|
34
31
|
height: 480
|
|
@@ -76,6 +73,16 @@ var _default = {
|
|
|
76
73
|
title: {
|
|
77
74
|
settings: false,
|
|
78
75
|
label: 'Graph Title'
|
|
76
|
+
},
|
|
77
|
+
maxImageWidth: {
|
|
78
|
+
teacherInstructions: 300,
|
|
79
|
+
prompt: 300,
|
|
80
|
+
rationale: 300
|
|
81
|
+
},
|
|
82
|
+
maxImageHeight: {
|
|
83
|
+
teacherInstructions: 300,
|
|
84
|
+
prompt: 300,
|
|
85
|
+
rationale: 300
|
|
79
86
|
}
|
|
80
87
|
}
|
|
81
88
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/defaults.js"],"names":["model","addCategoryEnabled","categoryDefaultLabel","chartType","correctAnswer","data","domain","label","
|
|
1
|
+
{"version":3,"sources":["../src/defaults.js"],"names":["model","addCategoryEnabled","categoryDefaultLabel","chartType","correctAnswer","data","domain","label","graph","width","height","prompt","promptEnabled","rationale","range","max","min","scoringType","title","rationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","configuration","spellCheck","settings","enabled","studentInstructions","teacherInstructions","maxImageWidth","maxImageHeight"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;eAEe;AACbA,EAAAA,KAAK,EAAE;AACLC,IAAAA,kBAAkB,EAAE,IADf;AAELC,IAAAA,oBAAoB,EAAE,UAFjB;AAGLC,IAAAA,SAAS,EAAE,WAHN;AAILC,IAAAA,aAAa,EAAE,EAJV;AAKLC,IAAAA,IAAI,EAAE,EALD;AAMLC,IAAAA,MAAM,EAAE;AACNC,MAAAA,KAAK,EAAE;AADD,KANH;AASLC,IAAAA,KAAK,EAAE;AACLC,MAAAA,KAAK,EAAE,GADF;AAELC,MAAAA,MAAM,EAAE;AAFH,KATF;AAaLC,IAAAA,MAAM,EAAE,s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AE,GAFK;AAGbE,MAAAA,SAAS,EAAE;AAHE,KA9BF;AAmCbgB,IAAAA,cAAc,EAAE;AACdF,MAAAA,mBAAmB,EAAE,GADP;AAEdhB,MAAAA,MAAM,EAAE,GAFM;AAGdE,MAAAA,SAAS,EAAE;AAHG;AAnCH;AA5BF,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\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 categoryDefaultLabel: 'Category',\n chartType: 'lineCross',\n correctAnswer: {},\n data: [],\n domain: {\n label: 'Fruits',\n },\n graph: {\n width: 480,\n height: 480\n },\n prompt: 'Here goes item stem!',\n promptEnabled: true,\n rationale: 'Rationale goes here!',\n range: {\n label: 'Amount',\n max: 5.5,\n min: 0,\n },\n scoringType: 'all or nothing',\n title: 'This is a chart!',\n rationaleEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n },\n configuration: {\n spellCheck: {\n label: 'Spellcheck',\n settings:false,\n enabled:true\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 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: 'Graph Title'\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 }\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": "4.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.2.0",
|
|
12
|
-
"@pie-lib/charting": "^
|
|
13
|
-
"@pie-lib/config-ui": "^
|
|
14
|
-
"@pie-lib/editable-html": "^
|
|
12
|
+
"@pie-lib/charting": "^5.1.0",
|
|
13
|
+
"@pie-lib/config-ui": "^11.0.1",
|
|
14
|
+
"@pie-lib/editable-html": "^8.1.0",
|
|
15
15
|
"classnames": "^2.2.5",
|
|
16
16
|
"debug": "^4.1.1",
|
|
17
17
|
"prop-types": "^15.6.2",
|
package/controller/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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
|
+
## [2.2.24](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-controller@2.2.23...@pie-element/charting-controller@2.2.24) (2022-06-13)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-element/charting-controller
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [2.2.23](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-controller@2.2.22...@pie-element/charting-controller@2.2.23) (2022-05-30)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @pie-element/charting-controller
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## [2.2.22](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-controller@2.2.21...@pie-element/charting-controller@2.2.22) (2022-01-10)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @pie-element/charting-controller
|
package/controller/lib/index.js
CHANGED
|
@@ -23,7 +23,8 @@ var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
|
23
23
|
|
|
24
24
|
var _controllerUtils = require("@pie-lib/controller-utils");
|
|
25
25
|
|
|
26
|
-
var _excluded = ["
|
|
26
|
+
var _excluded = ["deletable"],
|
|
27
|
+
_excluded2 = ["correctness"];
|
|
27
28
|
|
|
28
29
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
29
30
|
|
|
@@ -57,7 +58,6 @@ exports.setCorrectness = setCorrectness;
|
|
|
57
58
|
var normalize = function normalize(question) {
|
|
58
59
|
return _objectSpread({
|
|
59
60
|
addCategoryEnabled: true,
|
|
60
|
-
editCategoryEnabled: true,
|
|
61
61
|
promptEnabled: true,
|
|
62
62
|
rationaleEnabled: true,
|
|
63
63
|
teacherInstructionsEnabled: true,
|
|
@@ -72,8 +72,7 @@ var getScore = function getScore(question, session) {
|
|
|
72
72
|
var correctAnswer = question.correctAnswer,
|
|
73
73
|
_question$data = question.data,
|
|
74
74
|
initialData = _question$data === void 0 ? [] : _question$data,
|
|
75
|
-
scoringType = question.scoringType
|
|
76
|
-
editCategoryEnabled = question.editCategoryEnabled;
|
|
75
|
+
scoringType = question.scoringType;
|
|
77
76
|
|
|
78
77
|
var isPartialScoring = _controllerUtils.partialScoring.enabled({
|
|
79
78
|
partialScoring: scoringType !== undefined ? scoringType === 'partial scoring' : scoringType
|
|
@@ -83,7 +82,7 @@ var getScore = function getScore(question, session) {
|
|
|
83
82
|
_ref$data = _ref.data,
|
|
84
83
|
correctAnswers = _ref$data === void 0 ? [] : _ref$data;
|
|
85
84
|
|
|
86
|
-
var defaultAnswers = filterCategories(initialData
|
|
85
|
+
var defaultAnswers = filterCategories(initialData);
|
|
87
86
|
var answers = setCorrectness(session && session.answer || defaultAnswers, isPartialScoring);
|
|
88
87
|
var result = 0;
|
|
89
88
|
|
|
@@ -183,13 +182,11 @@ var getScore = function getScore(question, session) {
|
|
|
183
182
|
|
|
184
183
|
exports.getScore = getScore;
|
|
185
184
|
|
|
186
|
-
var filterCategories = function filterCategories(categories
|
|
187
|
-
return categories ? categories.map(function (
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
initial: true
|
|
192
|
-
});
|
|
185
|
+
var filterCategories = function filterCategories(categories) {
|
|
186
|
+
return categories ? categories.map(function (_ref2) {
|
|
187
|
+
var deletable = _ref2.deletable,
|
|
188
|
+
rest = (0, _objectWithoutProperties2["default"])(_ref2, _excluded);
|
|
189
|
+
return rest;
|
|
193
190
|
}) : [];
|
|
194
191
|
};
|
|
195
192
|
|
|
@@ -203,7 +200,6 @@ function model(question, session, env) {
|
|
|
203
200
|
chartType = normalizedQuestion.chartType,
|
|
204
201
|
data = normalizedQuestion.data,
|
|
205
202
|
domain = normalizedQuestion.domain,
|
|
206
|
-
editCategoryEnabled = normalizedQuestion.editCategoryEnabled,
|
|
207
203
|
graph = normalizedQuestion.graph,
|
|
208
204
|
prompt = normalizedQuestion.prompt,
|
|
209
205
|
promptEnabled = normalizedQuestion.promptEnabled,
|
|
@@ -223,9 +219,8 @@ function model(question, session, env) {
|
|
|
223
219
|
addCategoryEnabled: addCategoryEnabled,
|
|
224
220
|
categoryDefaultLabel: categoryDefaultLabel,
|
|
225
221
|
chartType: chartType,
|
|
226
|
-
data: filterCategories(data
|
|
222
|
+
data: filterCategories(data),
|
|
227
223
|
domain: domain,
|
|
228
|
-
editCategoryEnabled: editCategoryEnabled,
|
|
229
224
|
graph: graph,
|
|
230
225
|
prompt: promptEnabled ? prompt : null,
|
|
231
226
|
range: range,
|
|
@@ -236,12 +231,12 @@ function model(question, session, env) {
|
|
|
236
231
|
disabled: env.mode !== 'gather',
|
|
237
232
|
scoringType: scoringType
|
|
238
233
|
};
|
|
239
|
-
var answers = filterCategories(getScore(normalizedQuestion, session, env).answers
|
|
234
|
+
var answers = filterCategories(getScore(normalizedQuestion, session, env).answers);
|
|
240
235
|
|
|
241
236
|
if (env.mode === 'view') {
|
|
242
|
-
base.correctedAnswer = answers.map(function (
|
|
243
|
-
var correctness =
|
|
244
|
-
rest = (0, _objectWithoutProperties2["default"])(
|
|
237
|
+
base.correctedAnswer = answers.map(function (_ref3) {
|
|
238
|
+
var correctness = _ref3.correctness,
|
|
239
|
+
rest = (0, _objectWithoutProperties2["default"])(_ref3, _excluded2);
|
|
245
240
|
return _objectSpread(_objectSpread({}, rest), {}, {
|
|
246
241
|
interactive: false
|
|
247
242
|
});
|
|
@@ -281,8 +276,17 @@ var createCorrectResponseSession = function createCorrectResponseSession(questio
|
|
|
281
276
|
return new Promise(function (resolve) {
|
|
282
277
|
if (env.mode !== 'evaluate' && env.role === 'instructor') {
|
|
283
278
|
var correctAnswer = question.correctAnswer;
|
|
279
|
+
var answers = correctAnswer && correctAnswer.data; // for IBX preview mode
|
|
280
|
+
|
|
281
|
+
if (env.mode === 'gather') {
|
|
282
|
+
var data = question.data;
|
|
283
|
+
answers = (correctAnswer && correctAnswer.data || []).map(function (answer, index) {
|
|
284
|
+
return _objectSpread(_objectSpread({}, data[index]), answer);
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
|
|
284
288
|
resolve({
|
|
285
|
-
answer:
|
|
289
|
+
answer: answers,
|
|
286
290
|
id: '1'
|
|
287
291
|
});
|
|
288
292
|
} else {
|
|
@@ -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","editCategoryEnabled","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","category","deletable","initial","model","Promise","resolve","normalizedQuestion","categoryDefaultLabel","chartType","domain","graph","prompt","range","rationale","title","teacherInstructions","correctInfo","base","size","disabled","mode","correctedAnswer","rest","role","outcome","empty","createCorrectResponseSession","id"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,kCAAN,CAAZ;;AAEA,IAAMC,SAAS,GAAG,SAAZA,SAAY,CAAAC,MAAM;AAAA,SAAI,CAACA,MAAM,IAAI,EAAX,EAAeC,WAAf,EAAJ;AAAA,CAAxB;;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,CAACC,OAAD,EAAUC,cAAV;AAAA,SAA6BD,OAAO,GAAGA,OAAO,CAACE,GAAR,CAAY,UAAAC,MAAM;AAAA,2CAClFA,MADkF;AAErFC,MAAAA,WAAW,EAAE;AACXC,QAAAA,KAAK,EAAEJ,cAAc,GAAG,WAAH,GAAiB,SAD3B;AAEXK,QAAAA,KAAK,EAAEL,cAAc,GAAG,WAAH,GAAiB;AAF3B;AAFwE;AAAA,GAAlB,CAAH,GAM5D,EANwB;AAAA,CAAvB;;;;AASA,IAAMM,SAAS,GAAG,SAAZA,SAAY,CAAAC,QAAQ;AAAA;AAC/BC,IAAAA,kBAAkB,EAAE,IADW;AAE/BC,IAAAA,mBAAmB,EAAE,IAFU;AAG/BC,IAAAA,aAAa,EAAE,IAHgB;AAI/BC,IAAAA,gBAAgB,EAAE,IAJa;AAK/BC,IAAAA,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Y,UAAAC,OAAO,EAAI;AAC5BA,IAAAA,OAAO,CAAC;AACNlB,MAAAA,KAAK,EAAEf,QAAQ,CAAC+B,KAAD,EAAQ9B,OAAR,EAAiBC,GAAjB,CAAR,CAA8Ba,KAD/B;AAENsC,MAAAA,KAAK,EAAE,CAACpD,OAAD,IAAY,yBAAQA,OAAR;AAFb,KAAD,CAAP;AAID,GALM,CAAP;AAMD;;AAEM,IAAMqD,4BAA4B,GAAG,SAA/BA,4BAA+B,CAAC7D,QAAD,EAAWS,GAAX,EAAmB;AAC7D,SAAO,IAAI8B,OAAJ,CAAY,UAAAC,OAAO,EAAI;AAC5B,QAAI/B,GAAG,CAAC8C,IAAJ,KAAa,UAAb,IAA2B9C,GAAG,CAACiD,IAAJ,KAAa,YAA5C,EAA0D;AACxD,UAAQhD,aAAR,GAA0BV,QAA1B,CAAQU,aAAR;AAEA8B,MAAAA,OAAO,CAAC;AACN7C,QAAAA,MAAM,EAAEe,aAAa,IAAIA,aAAa,CAACC,IADjC;AAENmD,QAAAA,EAAE,EAAE;AAFE,OAAD,CAAP;AAID,KAPD,MAOO;AACL,aAAOtB,OAAO,CAAC,IAAD,CAAd;AACD;AACF,GAXM,CAAP;AAYD,CAbM","sourcesContent":["import debug from 'debug';\nimport isEmpty from 'lodash/isEmpty';\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) => answers ? 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 editCategoryEnabled: 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, editCategoryEnabled } = 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, editCategoryEnabled);\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\nexport const filterCategories = (categories, editable) => categories ? categories.map(category => ({\n ...category,\n deletable: false,\n editable,\n initial: true\n})) : [];\n\nexport function model(question, session, env) {\n return new Promise(resolve => {\n const normalizedQuestion = normalize(question);\n const {\n addCategoryEnabled,\n categoryDefaultLabel,\n chartType,\n data,\n domain,\n editCategoryEnabled,\n graph,\n prompt,\n promptEnabled,\n range,\n rationale,\n title,\n rationaleEnabled,\n teacherInstructions,\n teacherInstructionsEnabled,\n correctAnswer,\n scoringType\n } = normalizedQuestion;\n\n const correctInfo = { correctness: 'incorrect', score: '0%' };\n\n const base = {\n addCategoryEnabled,\n categoryDefaultLabel,\n chartType,\n data: filterCategories(data, editCategoryEnabled),\n domain,\n editCategoryEnabled,\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 };\n\n const answers = filterCategories(getScore(normalizedQuestion, session, env).answers, false);\n\n if (env.mode === 'view') {\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 resolve({\n answer: correctAnswer && correctAnswer.data,\n id: '1'\n });\n } else {\n return resolve(null);\n }\n });\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","categoryDefaultLabel","chartType","domain","graph","prompt","range","rationale","title","teacherInstructions","correctInfo","base","size","disabled","mode","correctedAnswer","role","outcome","empty","createCorrectResponseSession","id"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,kCAAN,CAAZ;;AAEA,IAAMC,SAAS,GAAG,SAAZA,SAAY,CAAAC,MAAM;AAAA,SAAI,CAACA,MAAM,IAAI,EAAX,EAAeC,WAAf,EAAJ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EAA4ChB,GAA5C,CAAgD,UAACC,MAAD,EAAS8B,KAAT,EAAmB;AAC3E,iDACKf,IAAI,CAACe,KAAD,CADT,GAEK9B,MAFL;AAID,SALS,CAAV;AAMD;;AAED2C,MAAAA,OAAO,CAAC;AACN3C,QAAAA,MAAM,EAAEH,OADF;AAENmE,QAAAA,EAAE,EAAE;AAFE,OAAD,CAAP;AAID,KArBD,MAqBO;AACL,aAAOrB,OAAO,CAAC,IAAD,CAAd;AACD;AACF,GAzBM,CAAP;AA0BD,CA3BM","sourcesContent":["import debug from 'debug';\nimport isEmpty from 'lodash/isEmpty';\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) => answers ? 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\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 categoryDefaultLabel,\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 } = normalizedQuestion;\n\n const correctInfo = { correctness: 'incorrect', score: '0%' };\n\n const base = {\n addCategoryEnabled,\n categoryDefaultLabel,\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 };\n\n const answers = filterCategories(getScore(normalizedQuestion, session, env).answers);\n\n if (env.mode === 'view') {\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"],"file":"index.js"}
|
package/controller/package.json
CHANGED
package/docs/config-schema.json
CHANGED
|
@@ -120,6 +120,48 @@
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
},
|
|
123
|
+
"maxImageWidth": {
|
|
124
|
+
"title": "ConfigureMaxImageDimensionsProp",
|
|
125
|
+
"type": "object",
|
|
126
|
+
"properties": {
|
|
127
|
+
"teacherInstructions": {
|
|
128
|
+
"description": "Indicates the max dimension for images in teacher instructions",
|
|
129
|
+
"type": "number",
|
|
130
|
+
"title": "teacherInstructions"
|
|
131
|
+
},
|
|
132
|
+
"prompt": {
|
|
133
|
+
"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",
|
|
134
|
+
"type": "number",
|
|
135
|
+
"title": "prompt"
|
|
136
|
+
},
|
|
137
|
+
"rationale": {
|
|
138
|
+
"description": "Indicates the max dimension for images in rationale",
|
|
139
|
+
"type": "number",
|
|
140
|
+
"title": "rationale"
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
"maxImageHeight": {
|
|
145
|
+
"title": "ConfigureMaxImageDimensionsProp",
|
|
146
|
+
"type": "object",
|
|
147
|
+
"properties": {
|
|
148
|
+
"teacherInstructions": {
|
|
149
|
+
"description": "Indicates the max dimension for images in teacher instructions",
|
|
150
|
+
"type": "number",
|
|
151
|
+
"title": "teacherInstructions"
|
|
152
|
+
},
|
|
153
|
+
"prompt": {
|
|
154
|
+
"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",
|
|
155
|
+
"type": "number",
|
|
156
|
+
"title": "prompt"
|
|
157
|
+
},
|
|
158
|
+
"rationale": {
|
|
159
|
+
"description": "Indicates the max dimension for images in rationale",
|
|
160
|
+
"type": "number",
|
|
161
|
+
"title": "rationale"
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
},
|
|
123
165
|
"showPrompt": {
|
|
124
166
|
"description": "Determines whether prompt field will be displayed or not",
|
|
125
167
|
"default": true,
|
|
@@ -176,6 +218,27 @@
|
|
|
176
218
|
"title": "enabled"
|
|
177
219
|
}
|
|
178
220
|
}
|
|
221
|
+
},
|
|
222
|
+
"ConfigureMaxImageDimensionsProp": {
|
|
223
|
+
"title": "ConfigureMaxImageDimensionsProp",
|
|
224
|
+
"type": "object",
|
|
225
|
+
"properties": {
|
|
226
|
+
"teacherInstructions": {
|
|
227
|
+
"description": "Indicates the max dimension for images in teacher instructions",
|
|
228
|
+
"type": "number",
|
|
229
|
+
"title": "teacherInstructions"
|
|
230
|
+
},
|
|
231
|
+
"prompt": {
|
|
232
|
+
"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",
|
|
233
|
+
"type": "number",
|
|
234
|
+
"title": "prompt"
|
|
235
|
+
},
|
|
236
|
+
"rationale": {
|
|
237
|
+
"description": "Indicates the max dimension for images in rationale",
|
|
238
|
+
"type": "number",
|
|
239
|
+
"title": "rationale"
|
|
240
|
+
}
|
|
241
|
+
}
|
|
179
242
|
}
|
|
180
243
|
},
|
|
181
244
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
@@ -91,6 +91,38 @@ Indicates the label for the item that has to be displayed in the Settings Panel
|
|
|
91
91
|
Indicates the value of the item if it affects config-ui
|
|
92
92
|
(eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
|
|
93
93
|
|
|
94
|
+
# `maxImageWidth` (object)
|
|
95
|
+
|
|
96
|
+
Properties of the `maxImageWidth` object:
|
|
97
|
+
|
|
98
|
+
## `teacherInstructions` (number)
|
|
99
|
+
|
|
100
|
+
Indicates the max dimension for images in teacher instructions
|
|
101
|
+
|
|
102
|
+
## `prompt` (number)
|
|
103
|
+
|
|
104
|
+
Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
|
|
105
|
+
|
|
106
|
+
## `rationale` (number)
|
|
107
|
+
|
|
108
|
+
Indicates the max dimension for images in rationale
|
|
109
|
+
|
|
110
|
+
# `maxImageHeight` (object)
|
|
111
|
+
|
|
112
|
+
Properties of the `maxImageHeight` object:
|
|
113
|
+
|
|
114
|
+
## `teacherInstructions` (number)
|
|
115
|
+
|
|
116
|
+
Indicates the max dimension for images in teacher instructions
|
|
117
|
+
|
|
118
|
+
## `prompt` (number)
|
|
119
|
+
|
|
120
|
+
Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
|
|
121
|
+
|
|
122
|
+
## `rationale` (number)
|
|
123
|
+
|
|
124
|
+
Indicates the max dimension for images in rationale
|
|
125
|
+
|
|
94
126
|
# `showPrompt` (boolean)
|
|
95
127
|
|
|
96
128
|
Determines whether prompt field will be displayed or not
|
|
@@ -142,4 +174,20 @@ Indicates the label for the item that has to be displayed in the Settings Panel
|
|
|
142
174
|
### `enabled` (boolean)
|
|
143
175
|
|
|
144
176
|
Indicates the value of the item if it affects config-ui
|
|
145
|
-
(eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
|
|
177
|
+
(eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
|
|
178
|
+
|
|
179
|
+
## `ConfigureMaxImageDimensionsProp` (object)
|
|
180
|
+
|
|
181
|
+
Properties of the `ConfigureMaxImageDimensionsProp` object:
|
|
182
|
+
|
|
183
|
+
### `teacherInstructions` (number)
|
|
184
|
+
|
|
185
|
+
Indicates the max dimension for images in teacher instructions
|
|
186
|
+
|
|
187
|
+
### `prompt` (number)
|
|
188
|
+
|
|
189
|
+
Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
|
|
190
|
+
|
|
191
|
+
### `rationale` (number)
|
|
192
|
+
|
|
193
|
+
Indicates the max dimension for images in rationale
|
package/docs/demo/generate.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
exports.model = (id, element) => ({
|
|
2
2
|
id,
|
|
3
3
|
element,
|
|
4
|
-
|
|
5
4
|
addCategoryEnabled: true,
|
|
6
5
|
categoryDefaultLabel: 'Category',
|
|
7
6
|
chartType: 'bar',
|
|
@@ -9,27 +8,15 @@ exports.model = (id, element) => ({
|
|
|
9
8
|
data: [
|
|
10
9
|
{
|
|
11
10
|
label: 'A',
|
|
12
|
-
value: 1
|
|
13
|
-
initial: true,
|
|
14
|
-
interactive: false,
|
|
15
|
-
editable: true,
|
|
16
|
-
deletable: true
|
|
11
|
+
value: 1
|
|
17
12
|
},
|
|
18
13
|
{
|
|
19
14
|
label: 'B',
|
|
20
|
-
value: 1
|
|
21
|
-
initial: true,
|
|
22
|
-
interactive: true,
|
|
23
|
-
editable: true,
|
|
24
|
-
deletable: true
|
|
15
|
+
value: 1
|
|
25
16
|
},
|
|
26
17
|
{
|
|
27
18
|
label: 'C',
|
|
28
|
-
value: 1
|
|
29
|
-
initial: true,
|
|
30
|
-
interactive: true,
|
|
31
|
-
editable: true,
|
|
32
|
-
deletable: true
|
|
19
|
+
value: 1
|
|
33
20
|
},
|
|
34
21
|
]
|
|
35
22
|
},
|
|
@@ -37,32 +24,25 @@ exports.model = (id, element) => ({
|
|
|
37
24
|
{
|
|
38
25
|
label: 'A',
|
|
39
26
|
value: 1,
|
|
40
|
-
initial: true,
|
|
41
27
|
interactive: false,
|
|
42
|
-
editable:
|
|
43
|
-
deletable: true
|
|
28
|
+
editable: false
|
|
44
29
|
},
|
|
45
30
|
{
|
|
46
31
|
label: 'B',
|
|
47
32
|
value: 1,
|
|
48
|
-
initial: true,
|
|
49
33
|
interactive: true,
|
|
50
|
-
editable:
|
|
51
|
-
deletable: true
|
|
34
|
+
editable: false
|
|
52
35
|
},
|
|
53
36
|
{
|
|
54
37
|
label: 'D',
|
|
55
38
|
value: 2,
|
|
56
|
-
initial: true,
|
|
57
39
|
interactive: true,
|
|
58
|
-
editable:
|
|
59
|
-
deletable: true
|
|
40
|
+
editable: false
|
|
60
41
|
},
|
|
61
42
|
],
|
|
62
43
|
domain: {
|
|
63
44
|
label: 'Characters',
|
|
64
45
|
},
|
|
65
|
-
editCategoryEnabled: true,
|
|
66
46
|
graph: {
|
|
67
47
|
width: 480,
|
|
68
48
|
height: 480
|
package/docs/demo/session.js
CHANGED
|
@@ -6,26 +6,20 @@ module.exports = [
|
|
|
6
6
|
// {
|
|
7
7
|
// label: 'A',
|
|
8
8
|
// value: 1,
|
|
9
|
-
// initial: true,
|
|
10
9
|
// interactive: false,
|
|
11
|
-
// editable: true
|
|
12
|
-
// deletable: true
|
|
10
|
+
// editable: true
|
|
13
11
|
// },
|
|
14
12
|
// {
|
|
15
13
|
// label: 'B',
|
|
16
14
|
// value: 1,
|
|
17
|
-
// initial: true,
|
|
18
15
|
// interactive: true,
|
|
19
|
-
// editable: true
|
|
20
|
-
// deletable: true
|
|
16
|
+
// editable: true
|
|
21
17
|
// },
|
|
22
18
|
// {
|
|
23
19
|
// label: 'C',
|
|
24
20
|
// value: 1,
|
|
25
|
-
// initial: true,
|
|
26
21
|
// interactive: true,
|
|
27
|
-
// editable: true
|
|
28
|
-
// deletable: true
|
|
22
|
+
// editable: true
|
|
29
23
|
// }
|
|
30
24
|
// ]
|
|
31
25
|
},
|