@pie-element/select-text 9.5.7-next.8 → 9.5.8-next.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 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
+ ## [9.5.7](https://github.com/pie-framework/pie-elements/compare/@pie-element/select-text@9.5.6...@pie-element/select-text@9.5.7) (2025-06-05)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * update pie-lib/pie-toolbox PD-4888, PD-3542, PD-4873, PD-4679 ([9c3bdef](https://github.com/pie-framework/pie-elements/commit/9c3bdef1b68f128ecc6338ef74f25fb74c482aa6))
12
+ * **math-inline, math-templated.number-line:** extend if fields also contai nmedia PD-3756 ([5340866](https://github.com/pie-framework/pie-elements/commit/53408664e7c25841253f47bfe36f836732fb4de7))
13
+ * add validation for audio content PD-4123 ([f0ce3f1](https://github.com/pie-framework/pie-elements/commit/f0ce3f19a12fd4cfe2d2159ca4af801d866dc8a9))
14
+ * update pie-lib pie-toolbox PD-3756 and revert changes for PD-4810 ([1e3030b](https://github.com/pie-framework/pie-elements/commit/1e3030bfdb13d0cce7b54ce0e9a109446c5ec2a2))
15
+ * update pie-lib-pie-toolbox PD-4810 ([6c81afc](https://github.com/pie-framework/pie-elements/commit/6c81afc6a8ad41e001bafb0bd1563164e9f32a10))
16
+ * update pie-lib-pie-toolbox PD-4810 ([0f9dd82](https://github.com/pie-framework/pie-elements/commit/0f9dd827c474e87770fd3bd146d870dd77d296df))
17
+
18
+
19
+
20
+
21
+
6
22
  ## [9.5.6](https://github.com/pie-framework/pie-elements/compare/@pie-element/select-text@9.5.5...@pie-element/select-text@9.5.6) (2025-05-22)
7
23
 
8
24
 
@@ -3,6 +3,20 @@
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
+ ## [8.4.7](https://github.com/pie-framework/pie-elements/compare/@pie-element/select-text-configure@8.4.6...@pie-element/select-text-configure@8.4.7) (2025-06-05)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * update pie-lib pie-toolbox PD-3756 and revert changes for PD-4810 ([1e3030b](https://github.com/pie-framework/pie-elements/commit/1e3030bfdb13d0cce7b54ce0e9a109446c5ec2a2))
12
+ * update pie-lib-pie-toolbox PD-4810 ([6c81afc](https://github.com/pie-framework/pie-elements/commit/6c81afc6a8ad41e001bafb0bd1563164e9f32a10))
13
+ * update pie-lib-pie-toolbox PD-4810 ([0f9dd82](https://github.com/pie-framework/pie-elements/commit/0f9dd827c474e87770fd3bd146d870dd77d296df))
14
+ * update pie-lib/pie-toolbox PD-4888, PD-3542, PD-4873, PD-4679 ([9c3bdef](https://github.com/pie-framework/pie-elements/commit/9c3bdef1b68f128ecc6338ef74f25fb74c482aa6))
15
+
16
+
17
+
18
+
19
+
6
20
  ## [8.4.6](https://github.com/pie-framework/pie-elements/compare/@pie-element/select-text-configure@8.4.5...@pie-element/select-text-configure@8.4.6) (2025-05-22)
7
21
 
8
22
 
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@pie-element/select-text-configure",
3
3
  "private": true,
4
- "version": "8.4.6",
4
+ "version": "8.4.7",
5
5
  "description": "",
6
6
  "main": "lib/index.js",
7
7
  "module": "src/index.js",
8
8
  "dependencies": {
9
9
  "@material-ui/core": "^3.9.2",
10
10
  "@pie-framework/pie-configure-events": "^1.3.0",
11
- "@pie-lib/pie-toolbox": "2.17.4",
11
+ "@pie-lib/pie-toolbox": "2.17.6",
12
12
  "debug": "^3.1.0",
13
13
  "lodash": "^4.17.15",
14
14
  "prop-types": "^15.6.2",
@@ -3,6 +3,21 @@
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
+ ## [6.2.7](https://github.com/pie-framework/pie-elements/compare/@pie-element/select-text-controller@6.2.6...@pie-element/select-text-controller@6.2.7) (2025-06-05)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * add validation for audio content PD-4123 ([f0ce3f1](https://github.com/pie-framework/pie-elements/commit/f0ce3f19a12fd4cfe2d2159ca4af801d866dc8a9))
12
+ * update pie-lib pie-toolbox PD-3756 and revert changes for PD-4810 ([1e3030b](https://github.com/pie-framework/pie-elements/commit/1e3030bfdb13d0cce7b54ce0e9a109446c5ec2a2))
13
+ * update pie-lib-pie-toolbox PD-4810 ([6c81afc](https://github.com/pie-framework/pie-elements/commit/6c81afc6a8ad41e001bafb0bd1563164e9f32a10))
14
+ * update pie-lib-pie-toolbox PD-4810 ([0f9dd82](https://github.com/pie-framework/pie-elements/commit/0f9dd827c474e87770fd3bd146d870dd77d296df))
15
+ * update pie-lib/pie-toolbox PD-4888, PD-3542, PD-4873, PD-4679 ([9c3bdef](https://github.com/pie-framework/pie-elements/commit/9c3bdef1b68f128ecc6338ef74f25fb74c482aa6))
16
+
17
+
18
+
19
+
20
+
6
21
  ## [6.2.6](https://github.com/pie-framework/pie-elements/compare/@pie-element/select-text-controller@6.2.5...@pie-element/select-text-controller@6.2.6) (2025-05-22)
7
22
 
8
23
 
@@ -224,11 +224,11 @@ exports.createCorrectResponseSession = createCorrectResponseSession;
224
224
 
225
225
  var getInnerText = function getInnerText(html) {
226
226
  return (html || '').replaceAll(/<[^>]*>/g, '');
227
- }; // remove all html tags except img and iframe
227
+ }; // remove all html tags except img, iframe and source tag for audio
228
228
 
229
229
 
230
230
  var getContent = function getContent(html) {
231
- return (html || '').replace(/(<(?!img|iframe)([^>]+)>)/gi, '');
231
+ return (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');
232
232
  };
233
233
 
234
234
  var validate = function validate() {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["log","equalTokens","token1","token2","start","end","oldStart","oldEnd","normalizeTokens","tokens","selectedTokens","evaluateMode","map","token","isCorrect","correct","isMissing","find","selectedToken","undefined","getCorrectness","selected","filter","t","length","correctSelected","getCorrectSelected","s","findIndex","getPartialScore","question","session","totalCorrect","correctCount","correctTokens","extraSelected","incorrectCount","count","positiveCount","parseFloat","toFixed","outcome","env","Promise","resolve","score","empty","normalizeSession","mode","completed","enabled","partialScoring","createDefaultModel","model","defaults","normalize","normalizedQuestion","correctness","fb","feedbackEnabled","feedback","then","out","highlightChoices","prompt","promptEnabled","text","disabled","maxSelections","incorrect","language","extraCSSRules","role","rationale","rationaleEnabled","teacherInstructions","teacherInstructionsEnabled","createCorrectResponseSession","id","getInnerText","html","replaceAll","getContent","replace","validate","config","minTokens","maxTokens","errors","nbOfTokens","forEach","field","required","nbOfSelections","reduce","acc","tokensError","selectionsError"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,qCAAN,CAAZ;;AAEA,IAAMC,WAAW,GAAG,SAAdA,WAAc;AAAA,MAACC,MAAD,uEAAU,EAAV;AAAA,MAAcC,MAAd,uEAAuB,EAAvB;AAAA,SACjB,CAAAD,MAAM,SAAN,IAAAA,MAAM,WAAN,YAAAA,MAAM,CAAEE,KAAR,OAAkBD,MAAlB,aAAkBA,MAAlB,uBAAkBA,MAAM,CAAEC,KAA1B,KAAmC,CAAAF,MAAM,SAAN,IAAAA,MAAM,WAAN,YAAAA,MAAM,CAAEG,GAAR,OAAgBF,MAAhB,aAAgBA,MAAhB,uBAAgBA,MAAM,CAAEE,GAAxB,CAApC,IACA;AACC,GAAAH,MAAM,SAAN,IAAAA,MAAM,WAAN,YAAAA,MAAM,CAAEE,KAAR,OAAkBD,MAAlB,aAAkBA,MAAlB,uBAAkBA,MAAM,CAAEG,QAA1B,KAAsC,CAAAJ,MAAM,SAAN,IAAAA,MAAM,WAAN,YAAAA,MAAM,CAAEG,GAAR,OAAgBF,MAAhB,aAAgBA,MAAhB,uBAAgBA,MAAM,CAAEI,MAAxB,CAHrB;AA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AP,GAAyB,4CAAzB;AACD,GAFD,MAEO,IAAIJ,cAAc,GAAGzB,aAArB,EAAoC;AACzCoB,IAAAA,MAAM,CAACS,eAAP,0BAAyC7B,aAAzC;AACD;;AAED,SAAOoB,MAAP;AACD,CA3BM","sourcesContent":["import debug from 'debug';\nimport isEmpty from 'lodash/isEmpty';\nimport { getFeedbackForCorrectness } from '@pie-lib/pie-toolbox/feedback';\nimport { partialScoring } from '@pie-lib/pie-toolbox/controller-utils';\nimport defaults from './defaults';\n\nconst log = debug('@pie-element:select-text:controller');\n\nconst equalTokens = (token1 = {}, token2 = {}) =>\n (token1?.start === token2?.start && token1?.end === token2?.end) ||\n // this case is used for the cases when the token's start & end were recalculated\n (token1?.start === token2?.oldStart && token1?.end === token2?.oldEnd);\n\nconst normalizeTokens = (tokens = [], selectedTokens = [], evaluateMode = false) =>\n (tokens || []).map((token) => {\n const isCorrect = !!token.correct;\n // search if correct token is missing from session\n const isMissing = isCorrect && !(selectedTokens || []).find((selectedToken) => equalTokens(token, selectedToken));\n\n return {\n ...token,\n correct: evaluateMode ? isCorrect : undefined,\n isMissing: evaluateMode ? isMissing : undefined,\n };\n });\n\nexport const getCorrectness = (tokens, selected) => {\n const correct = tokens.filter((t) => t.correct === true);\n\n if (correct.length === 0) {\n return 'unknown';\n }\n\n const correctSelected = getCorrectSelected(tokens, selected);\n\n if (correctSelected.length === selected.length) {\n if (correctSelected.length === correct.length) {\n return 'correct';\n } else if (correctSelected.length > 0) {\n return 'partially-correct';\n }\n }\n\n if (correctSelected.length > 0) {\n return 'partially-correct';\n }\n\n return 'incorrect';\n};\n\nconst getCorrectSelected = (tokens, selected) =>\n (selected || []).filter((s) => tokens.findIndex((token) => token.correct && equalTokens(token, s)) !== -1);\n\nexport const getPartialScore = (question, session, totalCorrect) => {\n if (!session || isEmpty(session)) {\n return 0;\n }\n\n const correctCount = getCorrectSelected(question.tokens, session.selectedTokens).length;\n const correctTokens = (question.tokens || []).filter((t) => t.correct === true);\n const extraSelected = session.selectedTokens ? session.selectedTokens.length > correctTokens.length : 0;\n const incorrectCount = extraSelected ? session.selectedTokens && session.selectedTokens.length - correctCount : 0;\n const count = correctCount - incorrectCount;\n const positiveCount = count < 0 ? 0 : count;\n\n return totalCorrect.length ? parseFloat((positiveCount / totalCorrect.length).toFixed(2)) : 0;\n};\n\nexport const outcome = (question, session, env) =>\n new Promise((resolve) => {\n if (!session || isEmpty(session)) {\n resolve({ score: 0, empty: true });\n }\n\n session = normalizeSession(session);\n\n if (env.mode !== 'evaluate') {\n resolve({ score: undefined, completed: undefined });\n } else {\n const enabled = partialScoring.enabled(question, env, true);\n const totalCorrect = question.tokens.filter((t) => t.correct);\n const score = getPartialScore(question, session, totalCorrect);\n resolve({\n score: enabled ? score : score === 1 ? 1 : 0,\n });\n }\n });\n\nexport function createDefaultModel(model = {}) {\n return new Promise((resolve) => {\n resolve({ ...defaults, ...model });\n });\n}\n\nexport const normalizeSession = (session) => ({ selectedTokens: [], ...session });\n\nexport const normalize = (question) => ({ ...defaults, ...question });\n\nexport const model = (question, session, env) => {\n session = session || { selectedToken: [] };\n session.selectedTokens = session.selectedTokens || [];\n const normalizedQuestion = normalize(question);\n\n return new Promise((resolve) => {\n log('[model]', 'normalizedQuestion: ', normalizedQuestion);\n log('[model]', 'session: ', session);\n\n const tokens = normalizeTokens(normalizedQuestion.tokens, session.selectedTokens, env.mode === 'evaluate');\n log('[model] tokens:', tokens);\n\n const correctness =\n env.mode === 'evaluate' ? getCorrectness(normalizedQuestion.tokens, session.selectedTokens) : undefined;\n\n const fb =\n env.mode === 'evaluate' && normalizedQuestion.feedbackEnabled\n ? getFeedbackForCorrectness(correctness, normalizedQuestion.feedback)\n : Promise.resolve(undefined);\n\n fb.then((feedback) => {\n const out = {\n tokens,\n highlightChoices: normalizedQuestion.highlightChoices,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n text: normalizedQuestion.text,\n disabled: env.mode !== 'gather',\n maxSelections: normalizedQuestion.maxSelections,\n correctness,\n env,\n feedback,\n incorrect: env.mode === 'evaluate' ? correctness !== 'correct' : undefined,\n language: normalizedQuestion.language,\n extraCSSRules: normalizedQuestion.extraCSSRules,\n };\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n out.rationale = null;\n out.teacherInstructions = null;\n }\n\n resolve(out);\n });\n });\n};\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { tokens } = question;\n const selectedTokens = tokens.filter((t) => t.correct);\n\n resolve({\n id: '1',\n selectedTokens,\n });\n } else {\n resolve(null);\n }\n });\n};\n\n// remove all html tags\nconst getInnerText = (html) => (html || '').replaceAll(/<[^>]*>/g, '');\n\n// remove all html tags except img and iframe\nconst getContent = (html) => (html || '').replace(/(<(?!img|iframe)([^>]+)>)/gi, '');\n\nexport const validate = (model = {}, config = {}) => {\n const { tokens } = model;\n const { minTokens = 2, maxTokens, maxSelections } = config;\n const errors = {};\n const nbOfTokens = (tokens || []).length;\n\n ['teacherInstructions', 'prompt', 'rationale'].forEach((field) => {\n if (config[field]?.required && !getContent(model[field])) {\n errors[field] = 'This field is required.';\n }\n });\n\n const nbOfSelections = (tokens || []).reduce((acc, token) => (token.correct ? acc + 1 : acc), 0);\n\n if (nbOfTokens < minTokens) {\n errors.tokensError = `There should be at least ${minTokens} tokens defined.`;\n } else if (nbOfTokens > maxTokens) {\n errors.tokensError = `No more than ${maxTokens} tokens should be defined.`;\n }\n\n if (nbOfSelections < 1) {\n errors.selectionsError = 'There should be at least 1 token selected.';\n } else if (nbOfSelections > maxSelections) {\n errors.selectionsError = `No more than ${maxSelections} tokens should be selected.`;\n }\n\n return errors;\n};\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.js"],"names":["log","equalTokens","token1","token2","start","end","oldStart","oldEnd","normalizeTokens","tokens","selectedTokens","evaluateMode","map","token","isCorrect","correct","isMissing","find","selectedToken","undefined","getCorrectness","selected","filter","t","length","correctSelected","getCorrectSelected","s","findIndex","getPartialScore","question","session","totalCorrect","correctCount","correctTokens","extraSelected","incorrectCount","count","positiveCount","parseFloat","toFixed","outcome","env","Promise","resolve","score","empty","normalizeSession","mode","completed","enabled","partialScoring","createDefaultModel","model","defaults","normalize","normalizedQuestion","correctness","fb","feedbackEnabled","feedback","then","out","highlightChoices","prompt","promptEnabled","text","disabled","maxSelections","incorrect","language","extraCSSRules","role","rationale","rationaleEnabled","teacherInstructions","teacherInstructionsEnabled","createCorrectResponseSession","id","getInnerText","html","replaceAll","getContent","replace","validate","config","minTokens","maxTokens","errors","nbOfTokens","forEach","field","required","nbOfSelections","reduce","acc","tokensError","selectionsError"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,qCAAN,CAAZ;;AAEA,IAAMC,WAAW,GAAG,SAAdA,WAAc;AAAA,MAACC,MAAD,uEAAU,EAAV;AAAA,MAAcC,MAAd,uEAAuB,EAAvB;AAAA,SACjB,CAAAD,MAAM,SAAN,IAAAA,MAAM,WAAN,YAAAA,MAAM,CAAEE,KAAR,OAAkBD,MAAlB,aAAkBA,MAAlB,uBAAkBA,MAAM,CAAEC,KAA1B,KAAmC,CAAAF,MAAM,SAAN,IAAAA,MAAM,WAAN,YAAAA,MAAM,CAAEG,GAAR,OAAgBF,MAAhB,aAAgBA,MAAhB,uBAAgBA,MAAM,CAAEE,GAAxB,CAApC,IACA;AACC,GAAAH,MAAM,SAAN,IAAAA,MAAM,WAAN,YAAAA,MAAM,CAAEE,KAAR,OAAkBD,MAAlB,aAAkBA,MAAlB,uBAAkBA,MAAM,CAAEG,QAA1B,KAAsC,CAAAJ,MAAM,SAAN,IAAAA,MAAM,W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M,CAACQ,WAAP,0BAAqCT,SAArC;AACD;;AAED,MAAIM,cAAc,GAAG,CAArB,EAAwB;AACtBL,IAAAA,MAAM,CAACS,eAAP,GAAyB,4CAAzB;AACD,GAFD,MAEO,IAAIJ,cAAc,GAAGzB,aAArB,EAAoC;AACzCoB,IAAAA,MAAM,CAACS,eAAP,0BAAyC7B,aAAzC;AACD;;AAED,SAAOoB,MAAP;AACD,CA3BM","sourcesContent":["import debug from 'debug';\nimport isEmpty from 'lodash/isEmpty';\nimport { getFeedbackForCorrectness } from '@pie-lib/pie-toolbox/feedback';\nimport { partialScoring } from '@pie-lib/pie-toolbox/controller-utils';\nimport defaults from './defaults';\n\nconst log = debug('@pie-element:select-text:controller');\n\nconst equalTokens = (token1 = {}, token2 = {}) =>\n (token1?.start === token2?.start && token1?.end === token2?.end) ||\n // this case is used for the cases when the token's start & end were recalculated\n (token1?.start === token2?.oldStart && token1?.end === token2?.oldEnd);\n\nconst normalizeTokens = (tokens = [], selectedTokens = [], evaluateMode = false) =>\n (tokens || []).map((token) => {\n const isCorrect = !!token.correct;\n // search if correct token is missing from session\n const isMissing = isCorrect && !(selectedTokens || []).find((selectedToken) => equalTokens(token, selectedToken));\n\n return {\n ...token,\n correct: evaluateMode ? isCorrect : undefined,\n isMissing: evaluateMode ? isMissing : undefined,\n };\n });\n\nexport const getCorrectness = (tokens, selected) => {\n const correct = tokens.filter((t) => t.correct === true);\n\n if (correct.length === 0) {\n return 'unknown';\n }\n\n const correctSelected = getCorrectSelected(tokens, selected);\n\n if (correctSelected.length === selected.length) {\n if (correctSelected.length === correct.length) {\n return 'correct';\n } else if (correctSelected.length > 0) {\n return 'partially-correct';\n }\n }\n\n if (correctSelected.length > 0) {\n return 'partially-correct';\n }\n\n return 'incorrect';\n};\n\nconst getCorrectSelected = (tokens, selected) =>\n (selected || []).filter((s) => tokens.findIndex((token) => token.correct && equalTokens(token, s)) !== -1);\n\nexport const getPartialScore = (question, session, totalCorrect) => {\n if (!session || isEmpty(session)) {\n return 0;\n }\n\n const correctCount = getCorrectSelected(question.tokens, session.selectedTokens).length;\n const correctTokens = (question.tokens || []).filter((t) => t.correct === true);\n const extraSelected = session.selectedTokens ? session.selectedTokens.length > correctTokens.length : 0;\n const incorrectCount = extraSelected ? session.selectedTokens && session.selectedTokens.length - correctCount : 0;\n const count = correctCount - incorrectCount;\n const positiveCount = count < 0 ? 0 : count;\n\n return totalCorrect.length ? parseFloat((positiveCount / totalCorrect.length).toFixed(2)) : 0;\n};\n\nexport const outcome = (question, session, env) =>\n new Promise((resolve) => {\n if (!session || isEmpty(session)) {\n resolve({ score: 0, empty: true });\n }\n\n session = normalizeSession(session);\n\n if (env.mode !== 'evaluate') {\n resolve({ score: undefined, completed: undefined });\n } else {\n const enabled = partialScoring.enabled(question, env, true);\n const totalCorrect = question.tokens.filter((t) => t.correct);\n const score = getPartialScore(question, session, totalCorrect);\n resolve({\n score: enabled ? score : score === 1 ? 1 : 0,\n });\n }\n });\n\nexport function createDefaultModel(model = {}) {\n return new Promise((resolve) => {\n resolve({ ...defaults, ...model });\n });\n}\n\nexport const normalizeSession = (session) => ({ selectedTokens: [], ...session });\n\nexport const normalize = (question) => ({ ...defaults, ...question });\n\nexport const model = (question, session, env) => {\n session = session || { selectedToken: [] };\n session.selectedTokens = session.selectedTokens || [];\n const normalizedQuestion = normalize(question);\n\n return new Promise((resolve) => {\n log('[model]', 'normalizedQuestion: ', normalizedQuestion);\n log('[model]', 'session: ', session);\n\n const tokens = normalizeTokens(normalizedQuestion.tokens, session.selectedTokens, env.mode === 'evaluate');\n log('[model] tokens:', tokens);\n\n const correctness =\n env.mode === 'evaluate' ? getCorrectness(normalizedQuestion.tokens, session.selectedTokens) : undefined;\n\n const fb =\n env.mode === 'evaluate' && normalizedQuestion.feedbackEnabled\n ? getFeedbackForCorrectness(correctness, normalizedQuestion.feedback)\n : Promise.resolve(undefined);\n\n fb.then((feedback) => {\n const out = {\n tokens,\n highlightChoices: normalizedQuestion.highlightChoices,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n text: normalizedQuestion.text,\n disabled: env.mode !== 'gather',\n maxSelections: normalizedQuestion.maxSelections,\n correctness,\n env,\n feedback,\n incorrect: env.mode === 'evaluate' ? correctness !== 'correct' : undefined,\n language: normalizedQuestion.language,\n extraCSSRules: normalizedQuestion.extraCSSRules,\n };\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n out.rationale = null;\n out.teacherInstructions = null;\n }\n\n resolve(out);\n });\n });\n};\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { tokens } = question;\n const selectedTokens = tokens.filter((t) => t.correct);\n\n resolve({\n id: '1',\n selectedTokens,\n });\n } else {\n resolve(null);\n }\n });\n};\n\n// remove all html tags\nconst getInnerText = (html) => (html || '').replaceAll(/<[^>]*>/g, '');\n\n// remove all html tags except img, iframe and source tag for audio\nconst getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');\n\nexport const validate = (model = {}, config = {}) => {\n const { tokens } = model;\n const { minTokens = 2, maxTokens, maxSelections } = config;\n const errors = {};\n const nbOfTokens = (tokens || []).length;\n\n ['teacherInstructions', 'prompt', 'rationale'].forEach((field) => {\n if (config[field]?.required && !getContent(model[field])) {\n errors[field] = 'This field is required.';\n }\n });\n\n const nbOfSelections = (tokens || []).reduce((acc, token) => (token.correct ? acc + 1 : acc), 0);\n\n if (nbOfTokens < minTokens) {\n errors.tokensError = `There should be at least ${minTokens} tokens defined.`;\n } else if (nbOfTokens > maxTokens) {\n errors.tokensError = `No more than ${maxTokens} tokens should be defined.`;\n }\n\n if (nbOfSelections < 1) {\n errors.selectionsError = 'There should be at least 1 token selected.';\n } else if (nbOfSelections > maxSelections) {\n errors.selectionsError = `No more than ${maxSelections} tokens should be selected.`;\n }\n\n return errors;\n};\n"],"file":"index.js"}
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@pie-element/select-text-controller",
3
3
  "private": true,
4
- "version": "6.2.6",
4
+ "version": "6.2.7",
5
5
  "description": "",
6
6
  "main": "lib/index.js",
7
7
  "module": "src/index.js",
8
8
  "dependencies": {
9
- "@pie-lib/pie-toolbox": "2.17.4",
9
+ "@pie-lib/pie-toolbox": "2.17.6",
10
10
  "debug": "^3.1.0",
11
11
  "lodash": "^4.17.15"
12
12
  },
package/lib/main.js CHANGED
@@ -105,11 +105,13 @@ var Main = /*#__PURE__*/function (_React$Component) {
105
105
  mode = _ref.mode;
106
106
 
107
107
  var selectedTokens = showCorrectAnswer ? this.correctAnswer() : session.selectedTokens;
108
+ var showRationale = model.rationale && ((0, _renderUi.hasText)(model.rationale) || (0, _renderUi.hasMedia)(model.rationale));
109
+ var showTeacherInstructions = model.teacherInstructions && ((0, _renderUi.hasText)(model.teacherInstructions) || (0, _renderUi.hasMedia)(model.teacherInstructions));
108
110
  log('[render] selectedTokens:', selectedTokens);
109
111
  return /*#__PURE__*/_react["default"].createElement(_renderUi.UiLayout, {
110
112
  extraCSSRules: extraCSSRules,
111
113
  className: classes.mainContainer
112
- }, model.teacherInstructions && (0, _renderUi.hasText)(model.teacherInstructions) && (!model.animationsDisabled ? /*#__PURE__*/_react["default"].createElement(_renderUi.Collapsible, {
114
+ }, showTeacherInstructions && (!model.animationsDisabled ? /*#__PURE__*/_react["default"].createElement(_renderUi.Collapsible, {
113
115
  labels: {
114
116
  hidden: 'Show Teacher Instructions',
115
117
  visible: 'Hide Teacher Instructions'
@@ -157,7 +159,7 @@ var Main = /*#__PURE__*/function (_React$Component) {
157
159
  animationsDisabled: model.animationsDisabled
158
160
  }), mode === 'evaluate' && /*#__PURE__*/_react["default"].createElement(_textSelect.Legend, {
159
161
  language: model.language
160
- }), model.rationale && (0, _renderUi.hasText)(model.rationale) && (!model.animationsDisabled ? /*#__PURE__*/_react["default"].createElement(_renderUi.Collapsible, {
162
+ }), showRationale && (!model.animationsDisabled ? /*#__PURE__*/_react["default"].createElement(_renderUi.Collapsible, {
161
163
  labels: {
162
164
  hidden: 'Show Rationale',
163
165
  visible: 'Hide Rationale'
package/lib/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/main.jsx"],"names":["log","Types","model","PropTypes","object","session","onSelectionChange","func","isRequired","Main","props","setState","showCorrectAnswer","state","tokens","filter","t","correct","alwaysShowCorrect","nextProps","classes","env","extraCSSRules","mode","selectedTokens","correctAnswer","mainContainer","teacherInstructions","animationsDisabled","hidden","visible","collapsible","prompt","disabled","incorrect","toggleShowCorrect","language","textSelect","text","selection","newSelections","map","select","token","find","start","end","highlightChoices","maxSelections","rationale","correctness","feedback","React","Component","StyledMain","theme","color","backgroundColor","background","marginBottom","spacing","unit","marginTop","whiteSpace","verticalAlign","Stateful","change"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,qBAAN,CAAZ;AAEA,IAAMC,KAAK,GAAG;AACZC,EAAAA,KAAK,EAAEC,sBAAUC,MADL;AAEZC,EAAAA,OAAO,EAAEF,sBAAUC,MAFP;AAGZE,EAAAA,iBAAiB,EAAEH,sBAAUI,IAAV,CAAeC;AAHtB,CAAd;;IAMaC,I;;;;;AAKX,gBAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AADiB,0GAgBC,YAAM;AACxB,YAAKC,QAAL,CAAc;AAAEC,QAAAA,iBAAiB,EAAE,CAAC,MAAKC,KAAL,CAAWD;AAAjC,OAAd;AACD,KAlBkB;AAAA,sGAoBH,YAAM;AACpB,UAAQV,KAAR,GAAkB,MAAKW,KAAvB,CAAQX,KAAR;AAEA,aAAOA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,CAA6B,OAAKO,KAAL,CAAWR,OAAX,CAAmBmB,cAAhD;AACD,OAFD;AAGD,KAjBkB;AAEjB,WAAKX,KAAL,GAAa;AACXX,MAAAA,KAAK,EAAEQ,KAAK,CAACR,KADF;AAEXG,MAAAA,OAAO,EAAEK,KAAK,CAACL;AAFJ,KAAb;AAFiB;AAMlB;;;;WAED,0CAAiCc,SAAjC,EAA4C;AAC1C,WAAKR,QAAL,CAAc;AAAET,QAAAA,KAAK,EAAEiB,SAAS,CAACjB,KAAnB;AAA0BG,QAAAA,OAAO,EAAEc,SAAS,CAACd;AAA7C,OAAd;AACD;;;WASD,kBAAS;AACP,yBAA2B,KAAKQ,KAAhC;AAAA,UAAQX,KAAR,gBAAQA,KAAR;AAAA,UAAeG,OAAf,gBAAeA,OAAf;AACA,0BAAO,gCAAC,UAAD;AAAY,QAAA,KAAK,EAAEH,KAAnB;AAA0B,QAAA,OAAO,EAAEG,OAAnC;AAA4C,QAAA,iBAAiB,EAAE,KAAK6D;AAApE,QAAP;AACD;;;EAzBmCd,kBAAMC,S;;;iCAAvBY,Q,eACAhE,K","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { TextSelect, Legend } from '@pie-lib/pie-toolbox/text-select';\nimport {CorrectAnswerToggle} from '@pie-lib/pie-toolbox/correct-answer-toggle';\nimport { color, Feedback, Collapsible, hasText, PreviewPrompt, UiLayout } from '@pie-lib/pie-toolbox/render-ui';\nimport { withStyles } from '@material-ui/core/styles';\nimport generateModel from './utils';\n\nimport debug from 'debug';\n\nconst log = debug('@pie-ui:select-text');\n\nconst Types = {\n model: PropTypes.object,\n session: PropTypes.object,\n onSelectionChange: PropTypes.func.isRequired,\n};\n\nexport class Main extends React.Component {\n static propTypes = { ...Types, classes: PropTypes.object.isRequired };\n\n static defaultProps = {};\n\n constructor(props) {\n super(props);\n\n this.state = {\n showCorrectAnswer: this.props.model.alwaysShowCorrect || false,\n model: generateModel(props.model),\n };\n }\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n this.setState({\n showCorrectAnswer: !!nextProps.model.alwaysShowCorrect,\n model: generateModel(nextProps.model),\n });\n }\n\n toggleShowCorrect = () => {\n this.setState({ showCorrectAnswer: !this.state.showCorrectAnswer });\n };\n\n correctAnswer = () => {\n const { model } = this.state;\n\n return model.tokens.filter((t) => t.correct);\n };\n\n render() {\n const { session, onSelectionChange, classes } = this.props;\n const { showCorrectAnswer, model } = this.state;\n const { env, extraCSSRules } = model;\n const { mode } = env || {};\n\n\n const selectedTokens = showCorrectAnswer ? this.correctAnswer() : session.selectedTokens;\n\n log('[render] selectedTokens:', selectedTokens);\n\n return (\n <UiLayout extraCSSRules={extraCSSRules} className={classes.mainContainer}>\n {model.teacherInstructions &&\n hasText(model.teacherInstructions) &&\n (!model.animationsDisabled ? (\n <Collapsible\n labels={{ hidden: 'Show Teacher Instructions', visible: 'Hide Teacher Instructions' }}\n className={classes.collapsible}\n >\n <PreviewPrompt prompt={model.teacherInstructions} />\n </Collapsible>\n ) : (\n <div className={classes.prompt}>\n <PreviewPrompt prompt={model.teacherInstructions} />\n </div>\n ))}\n\n <div className={classes.prompt}>\n <PreviewPrompt prompt={model.prompt} />\n </div>\n\n {!model.alwaysShowCorrect && (\n <CorrectAnswerToggle\n show={model.disabled && model.incorrect}\n toggled={showCorrectAnswer}\n onToggle={this.toggleShowCorrect}\n language={model.language}\n />\n )}\n\n <TextSelect\n className={classes.textSelect}\n disabled={model.disabled}\n text={model.text}\n tokens={model.tokens}\n selectedTokens={selectedTokens}\n onChange={(selection) => {\n const newSelections = selection.map((select) => {\n const token = model.tokens.find(({ start, end }) => select.start === start && select.end === end);\n\n // needed for getScore when tokens position is recalculated, to keep oldStart and oldEnd\n if (token) {\n return token;\n }\n\n return select;\n });\n\n onSelectionChange(newSelections);\n }}\n highlightChoices={model.highlightChoices}\n maxNoOfSelections={model.maxSelections}\n animationsDisabled={model.animationsDisabled}\n />\n {mode === 'evaluate' && <Legend language={model.language} />}\n\n {model.rationale &&\n hasText(model.rationale) &&\n (!model.animationsDisabled ? (\n <Collapsible\n labels={{ hidden: 'Show Rationale', visible: 'Hide Rationale' }}\n className={classes.collapsible}\n >\n <PreviewPrompt prompt={model.rationale} />\n </Collapsible>\n ) : (\n <div className={classes.prompt}>\n <PreviewPrompt prompt={model.rationale} />\n </div>\n ))}\n\n {model.correctness && model.feedback && !showCorrectAnswer && (\n <Feedback correctness={model.correctness} feedback={model.feedback} />\n )}\n </UiLayout>\n );\n }\n}\n\nconst StyledMain = withStyles((theme) => ({\n mainContainer: {\n color: color.text(),\n backgroundColor: color.background(),\n },\n textSelect: {\n marginBottom: theme.spacing.unit,\n marginTop: theme.spacing.unit * 2,\n whiteSpace: 'normal',\n },\n prompt: {\n verticalAlign: 'middle',\n marginBottom: theme.spacing.unit,\n },\n collapsible: {\n marginBottom: theme.spacing.unit * 2,\n },\n}))(Main);\n\nexport default class Stateful extends React.Component {\n static propTypes = Types;\n\n constructor(props) {\n super(props);\n this.state = {\n model: props.model,\n session: props.session,\n };\n }\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n this.setState({ model: nextProps.model, session: nextProps.session });\n }\n\n change = (selectedTokens) => {\n const session = { ...this.state.session, selectedTokens };\n this.setState({ session }, () => {\n this.props.onSelectionChange(this.state.session.selectedTokens);\n });\n };\n\n render() {\n const { model, session } = this.state;\n return <StyledMain model={model} session={session} onSelectionChange={this.change} />;\n }\n}\n"],"file":"main.js"}
1
+ {"version":3,"sources":["../src/main.jsx"],"names":["log","Types","model","PropTypes","object","session","onSelectionChange","func","isRequired","Main","props","setState","showCorrectAnswer","state","tokens","filter","t","correct","alwaysShowCorrect","nextProps","classes","env","extraCSSRules","mode","selectedTokens","correctAnswer","showRationale","rationale","showTeacherInstructions","teacherInstructions","mainContainer","animationsDisabled","hidden","visible","collapsible","prompt","disabled","incorrect","toggleShowCorrect","language","textSelect","text","selection","newSelections","map","select","token","find","start","end","highlightChoices","maxSelections","correctness","feedback","React","Component","StyledMain","theme","color","backgroundColor","background","marginBottom","spacing","unit","marginTop","whiteSpace","verticalAlign","Stateful","change"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,qBAAN,CAAZ;AAEA,IAAMC,KAAK,GAAG;AACZC,EAAAA,KAAK,EAAEC,sBAAUC,MADL;AAEZC,EAAAA,OAAO,EAAEF,sBAAUC,MAFP;AAGZE,EAAAA,iBAAiB,EAAEH,sBAAUI,IAAV,CAAeC;AAHtB,CAAd;;IAMaC,I;;;;;AAKX,gBAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AADiB,0GAgBC,YAAM;AACxB,YAAKC,QAAL,CAAc;AAAEC,QAAAA,iBAAiB,EAAE,CAAC,MAAKC,KAAL,CAAWD;AAAjC,OAAd;AACD,KAlBkB;AAAA,sGAoBH,YAAM;AACpB,UAAQV,KAAR,GAAkB,MAAKW,KAAvB,CAAQX,KAAR;AAEA,aAAOA,KAAK,CAACY,MAAN,CAAaC,MAAb,CAAoB,UAACC,CAAD;AAAA,eAAOA,CAAC,CAACC,OAAT;AAAA,OAApB,CAAP;AACD,KAxBkB;AAGjB,UAAKJ,KAAL,GAAa;AACXD,MAAAA,iBAAiB,EAAE,MAAKF,KAAL,CAAWR,KAAX,CAAiBgB,iBAAjB,IAAsC,KAD9C;AAEXhB,MAAAA,KAAK,EAAE,uBAAcQ,KAAK,CAACR,KAApB;AAFI,KAAb;AAHiB;AAOlB;;;;WAED,0CAAiCiB,SAAjC,EAA4C;AAC1C,WAAKR,QAAL,CAAc;AACZC,QAAAA,iBAAiB,EAAE,CAAC,CAACO,SAAS,CAACjB,KAAV,CAAgBgB,iBADzB;AAEZhB,QAAAA,KAAK,EAAE,uBAAciB,SAAS,CAACjB,KAAxB;AAFK,OAAd;AAID;;;WAYD,kBAAS;AACP,wBAAgD,KAAKQ,KAArD;AAAA,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hC;AAAA,UAAQX,KAAR,gBAAQA,KAAR;AAAA,UAAeG,OAAf,gBAAeA,OAAf;AACA,0BAAO,gCAAC,UAAD;AAAY,QAAA,KAAK,EAAEH,KAAnB;AAA0B,QAAA,OAAO,EAAEG,OAAnC;AAA4C,QAAA,iBAAiB,EAAE,KAAK+D;AAApE,QAAP;AACD;;;EAzBmCd,kBAAMC,S;;;iCAAvBY,Q,eACAlE,K","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { TextSelect, Legend } from '@pie-lib/pie-toolbox/text-select';\nimport {CorrectAnswerToggle} from '@pie-lib/pie-toolbox/correct-answer-toggle';\nimport {color, Feedback, Collapsible, hasText, hasMedia, PreviewPrompt, UiLayout} from '@pie-lib/pie-toolbox/render-ui';\nimport { withStyles } from '@material-ui/core/styles';\nimport generateModel from './utils';\n\nimport debug from 'debug';\n\nconst log = debug('@pie-ui:select-text');\n\nconst Types = {\n model: PropTypes.object,\n session: PropTypes.object,\n onSelectionChange: PropTypes.func.isRequired,\n};\n\nexport class Main extends React.Component {\n static propTypes = { ...Types, classes: PropTypes.object.isRequired };\n\n static defaultProps = {};\n\n constructor(props) {\n super(props);\n\n this.state = {\n showCorrectAnswer: this.props.model.alwaysShowCorrect || false,\n model: generateModel(props.model),\n };\n }\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n this.setState({\n showCorrectAnswer: !!nextProps.model.alwaysShowCorrect,\n model: generateModel(nextProps.model),\n });\n }\n\n toggleShowCorrect = () => {\n this.setState({ showCorrectAnswer: !this.state.showCorrectAnswer });\n };\n\n correctAnswer = () => {\n const { model } = this.state;\n\n return model.tokens.filter((t) => t.correct);\n };\n\n render() {\n const { session, onSelectionChange, classes } = this.props;\n const { showCorrectAnswer, model } = this.state;\n const { env, extraCSSRules } = model;\n const { mode } = env || {};\n\n\n const selectedTokens = showCorrectAnswer ? this.correctAnswer() : session.selectedTokens;\n const showRationale = model.rationale && (hasText(model.rationale) || hasMedia(model.rationale));\n const showTeacherInstructions = model.teacherInstructions && (hasText(model.teacherInstructions) || hasMedia(model.teacherInstructions));\n\n log('[render] selectedTokens:', selectedTokens);\n\n return (\n <UiLayout extraCSSRules={extraCSSRules} className={classes.mainContainer}>\n {showTeacherInstructions &&\n (!model.animationsDisabled ? (\n <Collapsible\n labels={{ hidden: 'Show Teacher Instructions', visible: 'Hide Teacher Instructions' }}\n className={classes.collapsible}\n >\n <PreviewPrompt prompt={model.teacherInstructions} />\n </Collapsible>\n ) : (\n <div className={classes.prompt}>\n <PreviewPrompt prompt={model.teacherInstructions} />\n </div>\n ))}\n\n <div className={classes.prompt}>\n <PreviewPrompt prompt={model.prompt} />\n </div>\n\n {!model.alwaysShowCorrect && (\n <CorrectAnswerToggle\n show={model.disabled && model.incorrect}\n toggled={showCorrectAnswer}\n onToggle={this.toggleShowCorrect}\n language={model.language}\n />\n )}\n\n <TextSelect\n className={classes.textSelect}\n disabled={model.disabled}\n text={model.text}\n tokens={model.tokens}\n selectedTokens={selectedTokens}\n onChange={(selection) => {\n const newSelections = selection.map((select) => {\n const token = model.tokens.find(({ start, end }) => select.start === start && select.end === end);\n\n // needed for getScore when tokens position is recalculated, to keep oldStart and oldEnd\n if (token) {\n return token;\n }\n\n return select;\n });\n\n onSelectionChange(newSelections);\n }}\n highlightChoices={model.highlightChoices}\n maxNoOfSelections={model.maxSelections}\n animationsDisabled={model.animationsDisabled}\n />\n {mode === 'evaluate' && <Legend language={model.language} />}\n\n {showRationale &&\n (!model.animationsDisabled ? (\n <Collapsible\n labels={{ hidden: 'Show Rationale', visible: 'Hide Rationale' }}\n className={classes.collapsible}\n >\n <PreviewPrompt prompt={model.rationale} />\n </Collapsible>\n ) : (\n <div className={classes.prompt}>\n <PreviewPrompt prompt={model.rationale} />\n </div>\n ))}\n\n {model.correctness && model.feedback && !showCorrectAnswer && (\n <Feedback correctness={model.correctness} feedback={model.feedback} />\n )}\n </UiLayout>\n );\n }\n}\n\nconst StyledMain = withStyles((theme) => ({\n mainContainer: {\n color: color.text(),\n backgroundColor: color.background(),\n },\n textSelect: {\n marginBottom: theme.spacing.unit,\n marginTop: theme.spacing.unit * 2,\n whiteSpace: 'normal',\n },\n prompt: {\n verticalAlign: 'middle',\n marginBottom: theme.spacing.unit,\n },\n collapsible: {\n marginBottom: theme.spacing.unit * 2,\n },\n}))(Main);\n\nexport default class Stateful extends React.Component {\n static propTypes = Types;\n\n constructor(props) {\n super(props);\n this.state = {\n model: props.model,\n session: props.session,\n };\n }\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n this.setState({ model: nextProps.model, session: nextProps.session });\n }\n\n change = (selectedTokens) => {\n const session = { ...this.state.session, selectedTokens };\n this.setState({ session }, () => {\n this.props.onSelectionChange(this.state.session.selectedTokens);\n });\n };\n\n render() {\n const { model, session } = this.state;\n return <StyledMain model={model} session={session} onSelectionChange={this.change} />;\n }\n}\n"],"file":"main.js"}
@@ -1,5 +1,5 @@
1
- import {_dll_react, _dll_prop_types, _dll_classnames, _dll_react_dom, _dll_debug, _dll_lodash, _dll_react_dom_server} from "../../../@pie-lib/pie-toolbox-math-rendering-module@4.1.3/module/index.js";
2
- import {_dll_pie_lib__pie_toolbox_config_ui, _dll_pie_lib__pie_toolbox_editable_html} from "../../../@pie-lib/pie-toolbox-module@7.0.2/module/index.js";
1
+ import {_dll_react, _dll_prop_types, _dll_classnames, _dll_react_dom, _dll_debug, _dll_lodash, _dll_react_dom_server} from "../../../@pie-lib/pie-toolbox-math-rendering-module@4.1.5/module/index.js";
2
+ import {_dll_pie_lib__pie_toolbox_config_ui, _dll_pie_lib__pie_toolbox_editable_html} from "../../../@pie-lib/pie-toolbox-module@7.0.4/module/index.js";
3
3
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
4
  function getDefaultExportFromCjs(x) {
5
5
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -114760,10 +114760,6 @@ const require$$23 = _dll_debug;
114760
114760
  }
114761
114761
  if (typeof window !== 'undefined') {
114762
114762
  (0, _html.RegisterHTMLHandler)((0, _browserAdaptor.browserAdaptor)());
114763
- if (window.MathJax && window.MathJax.Menu) {
114764
- console.log('Prevent MathJax v2 from interfering with v3 MenuHandler');
114765
- delete window.MathJax.Menu;
114766
- }
114767
114763
  }
114768
114764
  var sreReady = false;
114769
114765
  (0, _system.engineReady)().then(function () {
@@ -114881,9 +114877,7 @@ const require$$23 = _dll_debug;
114881
114877
  };
114882
114878
  var mml = new _mathml.MathML(mmlConfig);
114883
114879
  var customMmlFactory = new _MmlFactory.MmlFactory(_objectSpread(_objectSpread({}, _MmlFactory.MmlFactory.defaultNodes), _mstack.mmlNodes));
114884
- var withAssistive = (0, _assistiveMml.AssistiveMmlHandler)(_mathjax.mathjax.handlers.handlesDocument(docProvided));
114885
- var handler = window.MathJax && window.MathJax.Menu ? withAssistive : (0, _MenuHandler.MenuHandler)(withAssistive);
114886
- var classFactory = (0, _semanticEnrich.EnrichHandler)(handler, mml);
114880
+ var classFactory = (0, _semanticEnrich.EnrichHandler)((0, _MenuHandler.MenuHandler)((0, _assistiveMml.AssistiveMmlHandler)(_mathjax.mathjax.handlers.handlesDocument(docProvided))), mml);
114887
114881
  var html = classFactory.create(docProvided, {
114888
114882
  compileError: function compileError(mj, math, err) {
114889
114883
  console.log('bad math?:', math);
@@ -114894,13 +114888,6 @@ const require$$23 = _dll_debug;
114894
114888
  console.error(err);
114895
114889
  doc.typesetError(math, err);
114896
114890
  },
114897
- menuOptions: {
114898
- settings: {
114899
- assistiveMml: true,
114900
- collapsible: false,
114901
- explorer: false
114902
- }
114903
- },
114904
114891
  sre: {
114905
114892
  speech: 'deep'
114906
114893
  },
@@ -114935,19 +114922,13 @@ const require$$23 = _dll_debug;
114935
114922
  var attemptRender = function attemptRender() {
114936
114923
  var _updatedDocument$math, _updatedDocument$math2;
114937
114924
  var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
114938
- var usesMenuHandler = !(window.MathJax && window.MathJax.Menu);
114939
114925
  var updatedDocument = _this.html.findMath(elements.length ? {
114940
114926
  elements: elements
114941
114927
  } : {}).compile();
114942
114928
  if (!temporary && sreReady) {
114943
114929
  updatedDocument = updatedDocument.enrich();
114944
114930
  }
114945
- updatedDocument = updatedDocument.getMetrics().typeset().assistiveMml().attachSpeech();
114946
- if (usesMenuHandler) {
114947
- console.log('Using MenuHandler');
114948
- updatedDocument = updatedDocument.addMenu();
114949
- }
114950
- updatedDocument = updatedDocument.updateDocument();
114931
+ updatedDocument = updatedDocument.getMetrics().typeset().assistiveMml().attachSpeech().addMenu().updateDocument();
114951
114932
  if (!enrichSpeechInitialized && (0, _typeof2["default"])((_updatedDocument$math = updatedDocument.math.list) === null || _updatedDocument$math === void 0 ? void 0 : (_updatedDocument$math2 = _updatedDocument$math.next) === null || _updatedDocument$math2 === void 0 ? void 0 : _updatedDocument$math2.data) === 'object') {
114952
114933
  enrichSpeechInitialized = true;
114953
114934
  }
@@ -125165,9 +125146,9 @@ Object.defineProperty(hasText$1, "__esModule", {
125165
125146
  value: true
125166
125147
  });
125167
125148
  hasText$1.hasText = void 0;
125168
- var dp = new DOMParser();
125149
+ var dp$1 = new DOMParser();
125169
125150
  var markupToText = function markupToText(s) {
125170
- var root = dp.parseFromString(s, 'text/html');
125151
+ var root = dp$1.parseFromString(s, 'text/html');
125171
125152
  return root.body.textContent;
125172
125153
  };
125173
125154
  var hasText = function hasText(s) {
@@ -125178,6 +125159,20 @@ var hasText = function hasText(s) {
125178
125159
  return !!(tc && tc.trim());
125179
125160
  };
125180
125161
  hasText$1.hasText = hasText;
125162
+ var hasMedia$1 = {};
125163
+ Object.defineProperty(hasMedia$1, "__esModule", {
125164
+ value: true
125165
+ });
125166
+ hasMedia$1.hasMedia = void 0;
125167
+ var dp = new DOMParser();
125168
+ var hasMedia = function hasMedia(s) {
125169
+ if (!s) {
125170
+ return false;
125171
+ }
125172
+ var root = dp.parseFromString(s, 'text/html');
125173
+ return !!root.body.querySelector('img') || !!root.body.querySelector('video') || !!root.body.querySelector('audio');
125174
+ };
125175
+ hasMedia$1.hasMedia = hasMedia;
125181
125176
  var enableAudioAutoplayImage = {};
125182
125177
  (function (exports) {
125183
125178
  Object.defineProperty(exports, "__esModule", {
@@ -125255,6 +125250,12 @@ getDefaultExportFromCjs(enableAudioAutoplayImage);
125255
125250
  }
125256
125251
  });
125257
125252
  exports.color = void 0;
125253
+ Object.defineProperty(exports, "hasMedia", {
125254
+ enumerable: true,
125255
+ get: function get() {
125256
+ return _hasMedia.hasMedia;
125257
+ }
125258
+ });
125258
125259
  Object.defineProperty(exports, "hasText", {
125259
125260
  enumerable: true,
125260
125261
  get: function get() {
@@ -125283,6 +125284,7 @@ getDefaultExportFromCjs(enableAudioAutoplayImage);
125283
125284
  var color$1 = _interopRequireWildcard(color);
125284
125285
  exports.color = color$1;
125285
125286
  var _hasText = hasText$1;
125287
+ var _hasMedia = hasMedia$1;
125286
125288
  var _enableAudioAutoplayImage = _interopRequireDefault(enableAudioAutoplayImage);
125287
125289
  function _getRequireWildcardCache(nodeInterop) {
125288
125290
  if (typeof WeakMap !== "function") return null;
@@ -20097,8 +20097,8 @@ const createCorrectResponseSession = (question, env) => {
20097
20097
  });
20098
20098
  };
20099
20099
 
20100
- // remove all html tags except img and iframe
20101
- const getContent = (html) => (html || '').replace(/(<(?!img|iframe)([^>]+)>)/gi, '');
20100
+ // remove all html tags except img, iframe and source tag for audio
20101
+ const getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');
20102
20102
 
20103
20103
  const validate = (model = {}, config = {}) => {
20104
20104
  const { tokens } = model;
package/module/element.js CHANGED
@@ -1,5 +1,5 @@
1
- import {_dll_react, _dll_prop_types, _dll_react_dom, _dll_classnames, _dll_debug, _dll_lodash, _dll_react_dom_server, _dll_pie_lib__pie_toolbox_math_rendering} from "../../../@pie-lib/pie-toolbox-math-rendering-module@4.1.3/module/index.js";
2
- import {_dll_pie_lib__pie_toolbox_correct_answer_toggle, _dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@7.0.2/module/index.js";
1
+ import {_dll_react, _dll_prop_types, _dll_react_dom, _dll_classnames, _dll_debug, _dll_lodash, _dll_react_dom_server, _dll_pie_lib__pie_toolbox_math_rendering} from "../../../@pie-lib/pie-toolbox-math-rendering-module@4.1.5/module/index.js";
2
+ import {_dll_pie_lib__pie_toolbox_correct_answer_toggle, _dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@7.0.4/module/index.js";
3
3
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
4
  function getDefaultExportFromCjs(x) {
5
5
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -111588,10 +111588,6 @@ const require$$23 = _dll_debug;
111588
111588
  }
111589
111589
  if (typeof window !== 'undefined') {
111590
111590
  (0, _html.RegisterHTMLHandler)((0, _browserAdaptor.browserAdaptor)());
111591
- if (window.MathJax && window.MathJax.Menu) {
111592
- console.log('Prevent MathJax v2 from interfering with v3 MenuHandler');
111593
- delete window.MathJax.Menu;
111594
- }
111595
111591
  }
111596
111592
  var sreReady = false;
111597
111593
  (0, _system.engineReady)().then(function () {
@@ -111709,9 +111705,7 @@ const require$$23 = _dll_debug;
111709
111705
  };
111710
111706
  var mml = new _mathml.MathML(mmlConfig);
111711
111707
  var customMmlFactory = new _MmlFactory.MmlFactory(_objectSpread(_objectSpread({}, _MmlFactory.MmlFactory.defaultNodes), _mstack.mmlNodes));
111712
- var withAssistive = (0, _assistiveMml.AssistiveMmlHandler)(_mathjax.mathjax.handlers.handlesDocument(docProvided));
111713
- var handler = window.MathJax && window.MathJax.Menu ? withAssistive : (0, _MenuHandler.MenuHandler)(withAssistive);
111714
- var classFactory = (0, _semanticEnrich.EnrichHandler)(handler, mml);
111708
+ var classFactory = (0, _semanticEnrich.EnrichHandler)((0, _MenuHandler.MenuHandler)((0, _assistiveMml.AssistiveMmlHandler)(_mathjax.mathjax.handlers.handlesDocument(docProvided))), mml);
111715
111709
  var html = classFactory.create(docProvided, {
111716
111710
  compileError: function compileError(mj, math, err) {
111717
111711
  console.log('bad math?:', math);
@@ -111722,13 +111716,6 @@ const require$$23 = _dll_debug;
111722
111716
  console.error(err);
111723
111717
  doc.typesetError(math, err);
111724
111718
  },
111725
- menuOptions: {
111726
- settings: {
111727
- assistiveMml: true,
111728
- collapsible: false,
111729
- explorer: false
111730
- }
111731
- },
111732
111719
  sre: {
111733
111720
  speech: 'deep'
111734
111721
  },
@@ -111763,19 +111750,13 @@ const require$$23 = _dll_debug;
111763
111750
  var attemptRender = function attemptRender() {
111764
111751
  var _updatedDocument$math, _updatedDocument$math2;
111765
111752
  var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
111766
- var usesMenuHandler = !(window.MathJax && window.MathJax.Menu);
111767
111753
  var updatedDocument = _this.html.findMath(elements.length ? {
111768
111754
  elements: elements
111769
111755
  } : {}).compile();
111770
111756
  if (!temporary && sreReady) {
111771
111757
  updatedDocument = updatedDocument.enrich();
111772
111758
  }
111773
- updatedDocument = updatedDocument.getMetrics().typeset().assistiveMml().attachSpeech();
111774
- if (usesMenuHandler) {
111775
- console.log('Using MenuHandler');
111776
- updatedDocument = updatedDocument.addMenu();
111777
- }
111778
- updatedDocument = updatedDocument.updateDocument();
111759
+ updatedDocument = updatedDocument.getMetrics().typeset().assistiveMml().attachSpeech().addMenu().updateDocument();
111779
111760
  if (!enrichSpeechInitialized && (0, _typeof2["default"])((_updatedDocument$math = updatedDocument.math.list) === null || _updatedDocument$math === void 0 ? void 0 : (_updatedDocument$math2 = _updatedDocument$math.next) === null || _updatedDocument$math2 === void 0 ? void 0 : _updatedDocument$math2.data) === 'object') {
111780
111761
  enrichSpeechInitialized = true;
111781
111762
  }
@@ -122711,9 +122692,9 @@ Object.defineProperty(hasText$2, "__esModule", {
122711
122692
  value: true
122712
122693
  });
122713
122694
  hasText$2.hasText = void 0;
122714
- var dp = new DOMParser();
122695
+ var dp$1 = new DOMParser();
122715
122696
  var markupToText = function markupToText(s) {
122716
- var root = dp.parseFromString(s, 'text/html');
122697
+ var root = dp$1.parseFromString(s, 'text/html');
122717
122698
  return root.body.textContent;
122718
122699
  };
122719
122700
  var hasText$1 = function hasText(s) {
@@ -122724,6 +122705,20 @@ var hasText$1 = function hasText(s) {
122724
122705
  return !!(tc && tc.trim());
122725
122706
  };
122726
122707
  hasText$2.hasText = hasText$1;
122708
+ var hasMedia$2 = {};
122709
+ Object.defineProperty(hasMedia$2, "__esModule", {
122710
+ value: true
122711
+ });
122712
+ hasMedia$2.hasMedia = void 0;
122713
+ var dp = new DOMParser();
122714
+ var hasMedia$1 = function hasMedia(s) {
122715
+ if (!s) {
122716
+ return false;
122717
+ }
122718
+ var root = dp.parseFromString(s, 'text/html');
122719
+ return !!root.body.querySelector('img') || !!root.body.querySelector('video') || !!root.body.querySelector('audio');
122720
+ };
122721
+ hasMedia$2.hasMedia = hasMedia$1;
122727
122722
  var enableAudioAutoplayImage = {};
122728
122723
  (function (exports) {
122729
122724
  Object.defineProperty(exports, "__esModule", {
@@ -122801,6 +122796,12 @@ getDefaultExportFromCjs(enableAudioAutoplayImage);
122801
122796
  }
122802
122797
  });
122803
122798
  exports.color = void 0;
122799
+ Object.defineProperty(exports, "hasMedia", {
122800
+ enumerable: true,
122801
+ get: function get() {
122802
+ return _hasMedia.hasMedia;
122803
+ }
122804
+ });
122804
122805
  Object.defineProperty(exports, "hasText", {
122805
122806
  enumerable: true,
122806
122807
  get: function get() {
@@ -122829,6 +122830,7 @@ getDefaultExportFromCjs(enableAudioAutoplayImage);
122829
122830
  var color = _interopRequireWildcard(color$1);
122830
122831
  exports.color = color;
122831
122832
  var _hasText = hasText$2;
122833
+ var _hasMedia = hasMedia$2;
122832
122834
  var _enableAudioAutoplayImage = _interopRequireDefault(enableAudioAutoplayImage);
122833
122835
  function _getRequireWildcardCache(nodeInterop) {
122834
122836
  if (typeof WeakMap !== "function") return null;
@@ -129066,6 +129068,7 @@ const {color: color} = _dll_pie_lib__pie_toolbox_render_ui;
129066
129068
  const {Feedback: Feedback} = _dll_pie_lib__pie_toolbox_render_ui;
129067
129069
  const {Collapsible: Collapsible} = _dll_pie_lib__pie_toolbox_render_ui;
129068
129070
  const {hasText: hasText} = _dll_pie_lib__pie_toolbox_render_ui;
129071
+ const {hasMedia: hasMedia} = _dll_pie_lib__pie_toolbox_render_ui;
129069
129072
  const {PreviewPrompt: PreviewPrompt} = _dll_pie_lib__pie_toolbox_render_ui;
129070
129073
  const {UiLayout: UiLayout} = _dll_pie_lib__pie_toolbox_render_ui;
129071
129074
  const _jsxFileName = "/home/circleci/repo/packages/select-text/src/main.jsx";
@@ -129119,6 +129122,8 @@ class Main extends React$1.Component {
129119
129122
  const {env, extraCSSRules} = model;
129120
129123
  const {mode} = env || ({});
129121
129124
  const selectedTokens = showCorrectAnswer ? this.correctAnswer() : session.selectedTokens;
129125
+ const showRationale = model.rationale && (hasText(model.rationale) || hasMedia(model.rationale));
129126
+ const showTeacherInstructions = model.teacherInstructions && (hasText(model.teacherInstructions) || hasMedia(model.teacherInstructions));
129122
129127
  log('[render] selectedTokens:', selectedTokens);
129123
129128
  return React$1.createElement(UiLayout, {
129124
129129
  extraCSSRules: extraCSSRules,
@@ -129126,9 +129131,9 @@ class Main extends React$1.Component {
129126
129131
  __self: this,
129127
129132
  __source: {
129128
129133
  fileName: _jsxFileName,
129129
- lineNumber: 62
129134
+ lineNumber: 64
129130
129135
  }
129131
- }, model.teacherInstructions && hasText(model.teacherInstructions) && (!model.animationsDisabled ? React$1.createElement(Collapsible, {
129136
+ }, showTeacherInstructions && (!model.animationsDisabled ? React$1.createElement(Collapsible, {
129132
129137
  labels: {
129133
129138
  hidden: 'Show Teacher Instructions',
129134
129139
  visible: 'Hide Teacher Instructions'
@@ -129137,42 +129142,42 @@ class Main extends React$1.Component {
129137
129142
  __self: this,
129138
129143
  __source: {
129139
129144
  fileName: _jsxFileName,
129140
- lineNumber: 66
129145
+ lineNumber: 67
129141
129146
  }
129142
129147
  }, React$1.createElement(PreviewPrompt, {
129143
129148
  prompt: model.teacherInstructions,
129144
129149
  __self: this,
129145
129150
  __source: {
129146
129151
  fileName: _jsxFileName,
129147
- lineNumber: 70
129152
+ lineNumber: 71
129148
129153
  }
129149
129154
  })) : React$1.createElement('div', {
129150
129155
  className: classes.prompt,
129151
129156
  __self: this,
129152
129157
  __source: {
129153
129158
  fileName: _jsxFileName,
129154
- lineNumber: 73
129159
+ lineNumber: 74
129155
129160
  }
129156
129161
  }, React$1.createElement(PreviewPrompt, {
129157
129162
  prompt: model.teacherInstructions,
129158
129163
  __self: this,
129159
129164
  __source: {
129160
129165
  fileName: _jsxFileName,
129161
- lineNumber: 74
129166
+ lineNumber: 75
129162
129167
  }
129163
129168
  }))), React$1.createElement('div', {
129164
129169
  className: classes.prompt,
129165
129170
  __self: this,
129166
129171
  __source: {
129167
129172
  fileName: _jsxFileName,
129168
- lineNumber: 78
129173
+ lineNumber: 79
129169
129174
  }
129170
129175
  }, React$1.createElement(PreviewPrompt, {
129171
129176
  prompt: model.prompt,
129172
129177
  __self: this,
129173
129178
  __source: {
129174
129179
  fileName: _jsxFileName,
129175
- lineNumber: 79
129180
+ lineNumber: 80
129176
129181
  }
129177
129182
  })), !model.alwaysShowCorrect && React$1.createElement(CorrectAnswerToggle, {
129178
129183
  show: model.disabled && model.incorrect,
@@ -129182,7 +129187,7 @@ class Main extends React$1.Component {
129182
129187
  __self: this,
129183
129188
  __source: {
129184
129189
  fileName: _jsxFileName,
129185
- lineNumber: 83
129190
+ lineNumber: 84
129186
129191
  }
129187
129192
  }), React$1.createElement(textSelect$2.TextSelect, {
129188
129193
  className: classes.textSelect,
@@ -129206,16 +129211,16 @@ class Main extends React$1.Component {
129206
129211
  __self: this,
129207
129212
  __source: {
129208
129213
  fileName: _jsxFileName,
129209
- lineNumber: 91
129214
+ lineNumber: 92
129210
129215
  }
129211
129216
  }), mode === 'evaluate' && React$1.createElement(textSelect$2.Legend, {
129212
129217
  language: model.language,
129213
129218
  __self: this,
129214
129219
  __source: {
129215
129220
  fileName: _jsxFileName,
129216
- lineNumber: 115
129221
+ lineNumber: 116
129217
129222
  }
129218
- }), model.rationale && hasText(model.rationale) && (!model.animationsDisabled ? React$1.createElement(Collapsible, {
129223
+ }), showRationale && (!model.animationsDisabled ? React$1.createElement(Collapsible, {
129219
129224
  labels: {
129220
129225
  hidden: 'Show Rationale',
129221
129226
  visible: 'Hide Rationale'
package/module/index.html CHANGED
@@ -2,7 +2,7 @@
2
2
  <!doctype html>
3
3
  <html>
4
4
  <head>
5
- <title>@pie-element/select-text@9.5.6</title>
5
+ <title>@pie-element/select-text@9.5.7</title>
6
6
  <script
7
7
  type="module"
8
8
  src="https://cdn.jsdelivr.net/npm/@pslb/demo-el@^1.0.0/dist/demo-el/demo-el.esm.js"></script>
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@pie-element/select-text",
3
- "version": "9.5.6",
3
+ "version": "9.5.7",
4
4
  "modules": [
5
5
  {
6
6
  "name": "@pie-lib/pie-toolbox-math-rendering-module",
7
- "version": "4.1.3"
7
+ "version": "4.1.5"
8
8
  },
9
9
  {
10
10
  "name": "@pie-lib/pie-toolbox-module",
11
- "version": "7.0.2"
11
+ "version": "7.0.4"
12
12
  }
13
13
  ]
14
14
  }
package/module/print.html CHANGED
@@ -2,7 +2,7 @@
2
2
  <!doctype html>
3
3
  <html>
4
4
  <head>
5
- <title>@pie-element/select-text@9.5.6</title>
5
+ <title>@pie-element/select-text@9.5.7</title>
6
6
  <link
7
7
  href="https://fonts.googleapis.com/css?family=Roboto&display=swap"
8
8
  rel="stylesheet"
package/module/print.js CHANGED
@@ -1,5 +1,5 @@
1
- import {_dll_react, _dll_prop_types, _dll_react_dom, _dll_classnames, _dll_debug, _dll_lodash, _dll_react_dom_server, _dll_pie_lib__pie_toolbox_math_rendering} from "../../../@pie-lib/pie-toolbox-math-rendering-module@4.1.3/module/index.js";
2
- import {_dll_pie_lib__pie_toolbox_correct_answer_toggle, _dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@7.0.2/module/index.js";
1
+ import {_dll_react, _dll_prop_types, _dll_react_dom, _dll_classnames, _dll_debug, _dll_lodash, _dll_react_dom_server, _dll_pie_lib__pie_toolbox_math_rendering} from "../../../@pie-lib/pie-toolbox-math-rendering-module@4.1.5/module/index.js";
2
+ import {_dll_pie_lib__pie_toolbox_correct_answer_toggle, _dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@7.0.4/module/index.js";
3
3
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
4
  function getDefaultExportFromCjs(x) {
5
5
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -111551,10 +111551,6 @@ const require$$23 = _dll_debug;
111551
111551
  }
111552
111552
  if (typeof window !== 'undefined') {
111553
111553
  (0, _html.RegisterHTMLHandler)((0, _browserAdaptor.browserAdaptor)());
111554
- if (window.MathJax && window.MathJax.Menu) {
111555
- console.log('Prevent MathJax v2 from interfering with v3 MenuHandler');
111556
- delete window.MathJax.Menu;
111557
- }
111558
111554
  }
111559
111555
  var sreReady = false;
111560
111556
  (0, _system.engineReady)().then(function () {
@@ -111672,9 +111668,7 @@ const require$$23 = _dll_debug;
111672
111668
  };
111673
111669
  var mml = new _mathml.MathML(mmlConfig);
111674
111670
  var customMmlFactory = new _MmlFactory.MmlFactory(_objectSpread(_objectSpread({}, _MmlFactory.MmlFactory.defaultNodes), _mstack.mmlNodes));
111675
- var withAssistive = (0, _assistiveMml.AssistiveMmlHandler)(_mathjax.mathjax.handlers.handlesDocument(docProvided));
111676
- var handler = window.MathJax && window.MathJax.Menu ? withAssistive : (0, _MenuHandler.MenuHandler)(withAssistive);
111677
- var classFactory = (0, _semanticEnrich.EnrichHandler)(handler, mml);
111671
+ var classFactory = (0, _semanticEnrich.EnrichHandler)((0, _MenuHandler.MenuHandler)((0, _assistiveMml.AssistiveMmlHandler)(_mathjax.mathjax.handlers.handlesDocument(docProvided))), mml);
111678
111672
  var html = classFactory.create(docProvided, {
111679
111673
  compileError: function compileError(mj, math, err) {
111680
111674
  console.log('bad math?:', math);
@@ -111685,13 +111679,6 @@ const require$$23 = _dll_debug;
111685
111679
  console.error(err);
111686
111680
  doc.typesetError(math, err);
111687
111681
  },
111688
- menuOptions: {
111689
- settings: {
111690
- assistiveMml: true,
111691
- collapsible: false,
111692
- explorer: false
111693
- }
111694
- },
111695
111682
  sre: {
111696
111683
  speech: 'deep'
111697
111684
  },
@@ -111726,19 +111713,13 @@ const require$$23 = _dll_debug;
111726
111713
  var attemptRender = function attemptRender() {
111727
111714
  var _updatedDocument$math, _updatedDocument$math2;
111728
111715
  var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
111729
- var usesMenuHandler = !(window.MathJax && window.MathJax.Menu);
111730
111716
  var updatedDocument = _this.html.findMath(elements.length ? {
111731
111717
  elements: elements
111732
111718
  } : {}).compile();
111733
111719
  if (!temporary && sreReady) {
111734
111720
  updatedDocument = updatedDocument.enrich();
111735
111721
  }
111736
- updatedDocument = updatedDocument.getMetrics().typeset().assistiveMml().attachSpeech();
111737
- if (usesMenuHandler) {
111738
- console.log('Using MenuHandler');
111739
- updatedDocument = updatedDocument.addMenu();
111740
- }
111741
- updatedDocument = updatedDocument.updateDocument();
111722
+ updatedDocument = updatedDocument.getMetrics().typeset().assistiveMml().attachSpeech().addMenu().updateDocument();
111742
111723
  if (!enrichSpeechInitialized && (0, _typeof2["default"])((_updatedDocument$math = updatedDocument.math.list) === null || _updatedDocument$math === void 0 ? void 0 : (_updatedDocument$math2 = _updatedDocument$math.next) === null || _updatedDocument$math2 === void 0 ? void 0 : _updatedDocument$math2.data) === 'object') {
111743
111724
  enrichSpeechInitialized = true;
111744
111725
  }
@@ -122674,9 +122655,9 @@ Object.defineProperty(hasText$2, "__esModule", {
122674
122655
  value: true
122675
122656
  });
122676
122657
  hasText$2.hasText = void 0;
122677
- var dp = new DOMParser();
122658
+ var dp$1 = new DOMParser();
122678
122659
  var markupToText = function markupToText(s) {
122679
- var root = dp.parseFromString(s, 'text/html');
122660
+ var root = dp$1.parseFromString(s, 'text/html');
122680
122661
  return root.body.textContent;
122681
122662
  };
122682
122663
  var hasText$1 = function hasText(s) {
@@ -122687,6 +122668,20 @@ var hasText$1 = function hasText(s) {
122687
122668
  return !!(tc && tc.trim());
122688
122669
  };
122689
122670
  hasText$2.hasText = hasText$1;
122671
+ var hasMedia$2 = {};
122672
+ Object.defineProperty(hasMedia$2, "__esModule", {
122673
+ value: true
122674
+ });
122675
+ hasMedia$2.hasMedia = void 0;
122676
+ var dp = new DOMParser();
122677
+ var hasMedia$1 = function hasMedia(s) {
122678
+ if (!s) {
122679
+ return false;
122680
+ }
122681
+ var root = dp.parseFromString(s, 'text/html');
122682
+ return !!root.body.querySelector('img') || !!root.body.querySelector('video') || !!root.body.querySelector('audio');
122683
+ };
122684
+ hasMedia$2.hasMedia = hasMedia$1;
122690
122685
  var enableAudioAutoplayImage = {};
122691
122686
  (function (exports) {
122692
122687
  Object.defineProperty(exports, "__esModule", {
@@ -122764,6 +122759,12 @@ getDefaultExportFromCjs(enableAudioAutoplayImage);
122764
122759
  }
122765
122760
  });
122766
122761
  exports.color = void 0;
122762
+ Object.defineProperty(exports, "hasMedia", {
122763
+ enumerable: true,
122764
+ get: function get() {
122765
+ return _hasMedia.hasMedia;
122766
+ }
122767
+ });
122767
122768
  Object.defineProperty(exports, "hasText", {
122768
122769
  enumerable: true,
122769
122770
  get: function get() {
@@ -122792,6 +122793,7 @@ getDefaultExportFromCjs(enableAudioAutoplayImage);
122792
122793
  var color = _interopRequireWildcard(color$1);
122793
122794
  exports.color = color;
122794
122795
  var _hasText = hasText$2;
122796
+ var _hasMedia = hasMedia$2;
122795
122797
  var _enableAudioAutoplayImage = _interopRequireDefault(enableAudioAutoplayImage);
122796
122798
  function _getRequireWildcardCache(nodeInterop) {
122797
122799
  if (typeof WeakMap !== "function") return null;
@@ -129029,6 +129031,7 @@ const {color: color} = _dll_pie_lib__pie_toolbox_render_ui;
129029
129031
  const {Feedback: Feedback} = _dll_pie_lib__pie_toolbox_render_ui;
129030
129032
  const {Collapsible: Collapsible} = _dll_pie_lib__pie_toolbox_render_ui;
129031
129033
  const {hasText: hasText} = _dll_pie_lib__pie_toolbox_render_ui;
129034
+ const {hasMedia: hasMedia} = _dll_pie_lib__pie_toolbox_render_ui;
129032
129035
  const {PreviewPrompt: PreviewPrompt} = _dll_pie_lib__pie_toolbox_render_ui;
129033
129036
  const {UiLayout: UiLayout} = _dll_pie_lib__pie_toolbox_render_ui;
129034
129037
  const _jsxFileName = "/home/circleci/repo/packages/select-text/src/main.jsx";
@@ -129082,6 +129085,8 @@ class Main extends React$1.Component {
129082
129085
  const {env, extraCSSRules} = model;
129083
129086
  const {mode} = env || ({});
129084
129087
  const selectedTokens = showCorrectAnswer ? this.correctAnswer() : session.selectedTokens;
129088
+ const showRationale = model.rationale && (hasText(model.rationale) || hasMedia(model.rationale));
129089
+ const showTeacherInstructions = model.teacherInstructions && (hasText(model.teacherInstructions) || hasMedia(model.teacherInstructions));
129085
129090
  log$1('[render] selectedTokens:', selectedTokens);
129086
129091
  return React$1.createElement(UiLayout, {
129087
129092
  extraCSSRules: extraCSSRules,
@@ -129089,9 +129094,9 @@ class Main extends React$1.Component {
129089
129094
  __self: this,
129090
129095
  __source: {
129091
129096
  fileName: _jsxFileName,
129092
- lineNumber: 62
129097
+ lineNumber: 64
129093
129098
  }
129094
- }, model.teacherInstructions && hasText(model.teacherInstructions) && (!model.animationsDisabled ? React$1.createElement(Collapsible, {
129099
+ }, showTeacherInstructions && (!model.animationsDisabled ? React$1.createElement(Collapsible, {
129095
129100
  labels: {
129096
129101
  hidden: 'Show Teacher Instructions',
129097
129102
  visible: 'Hide Teacher Instructions'
@@ -129100,42 +129105,42 @@ class Main extends React$1.Component {
129100
129105
  __self: this,
129101
129106
  __source: {
129102
129107
  fileName: _jsxFileName,
129103
- lineNumber: 66
129108
+ lineNumber: 67
129104
129109
  }
129105
129110
  }, React$1.createElement(PreviewPrompt, {
129106
129111
  prompt: model.teacherInstructions,
129107
129112
  __self: this,
129108
129113
  __source: {
129109
129114
  fileName: _jsxFileName,
129110
- lineNumber: 70
129115
+ lineNumber: 71
129111
129116
  }
129112
129117
  })) : React$1.createElement('div', {
129113
129118
  className: classes.prompt,
129114
129119
  __self: this,
129115
129120
  __source: {
129116
129121
  fileName: _jsxFileName,
129117
- lineNumber: 73
129122
+ lineNumber: 74
129118
129123
  }
129119
129124
  }, React$1.createElement(PreviewPrompt, {
129120
129125
  prompt: model.teacherInstructions,
129121
129126
  __self: this,
129122
129127
  __source: {
129123
129128
  fileName: _jsxFileName,
129124
- lineNumber: 74
129129
+ lineNumber: 75
129125
129130
  }
129126
129131
  }))), React$1.createElement('div', {
129127
129132
  className: classes.prompt,
129128
129133
  __self: this,
129129
129134
  __source: {
129130
129135
  fileName: _jsxFileName,
129131
- lineNumber: 78
129136
+ lineNumber: 79
129132
129137
  }
129133
129138
  }, React$1.createElement(PreviewPrompt, {
129134
129139
  prompt: model.prompt,
129135
129140
  __self: this,
129136
129141
  __source: {
129137
129142
  fileName: _jsxFileName,
129138
- lineNumber: 79
129143
+ lineNumber: 80
129139
129144
  }
129140
129145
  })), !model.alwaysShowCorrect && React$1.createElement(CorrectAnswerToggle, {
129141
129146
  show: model.disabled && model.incorrect,
@@ -129145,7 +129150,7 @@ class Main extends React$1.Component {
129145
129150
  __self: this,
129146
129151
  __source: {
129147
129152
  fileName: _jsxFileName,
129148
- lineNumber: 83
129153
+ lineNumber: 84
129149
129154
  }
129150
129155
  }), React$1.createElement(textSelect$2.TextSelect, {
129151
129156
  className: classes.textSelect,
@@ -129169,16 +129174,16 @@ class Main extends React$1.Component {
129169
129174
  __self: this,
129170
129175
  __source: {
129171
129176
  fileName: _jsxFileName,
129172
- lineNumber: 91
129177
+ lineNumber: 92
129173
129178
  }
129174
129179
  }), mode === 'evaluate' && React$1.createElement(textSelect$2.Legend, {
129175
129180
  language: model.language,
129176
129181
  __self: this,
129177
129182
  __source: {
129178
129183
  fileName: _jsxFileName,
129179
- lineNumber: 115
129184
+ lineNumber: 116
129180
129185
  }
129181
- }), model.rationale && hasText(model.rationale) && (!model.animationsDisabled ? React$1.createElement(Collapsible, {
129186
+ }), showRationale && (!model.animationsDisabled ? React$1.createElement(Collapsible, {
129182
129187
  labels: {
129183
129188
  hidden: 'Show Rationale',
129184
129189
  visible: 'Hide Rationale'
package/package.json CHANGED
@@ -4,19 +4,19 @@
4
4
  "access": "public"
5
5
  },
6
6
  "repository": "pie-framework/pie-elements",
7
- "version": "9.5.7-next.8+a98d9306e",
7
+ "version": "9.5.8-next.0+6e96523fc",
8
8
  "description": "",
9
9
  "dependencies": {
10
10
  "@material-ui/core": "^3.9.2",
11
11
  "@pie-framework/pie-player-events": "^0.1.0",
12
- "@pie-lib/pie-toolbox": "2.17.4",
12
+ "@pie-lib/pie-toolbox": "2.17.6",
13
13
  "prop-types": "^15.6.1",
14
14
  "react": "^16.8.1",
15
15
  "react-dom": "^16.8.1"
16
16
  },
17
17
  "author": "",
18
18
  "license": "ISC",
19
- "gitHead": "a98d9306e52686234b7c27133fcca6f04500c448",
19
+ "gitHead": "6e96523fcee4d604e6e3e014c42e3353e771a37e",
20
20
  "scripts": {
21
21
  "postpublish": "../../scripts/postpublish"
22
22
  },