@pie-element/match 11.0.5-esm.1 → 11.1.0-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 +63 -0
- package/configure/CHANGELOG.md +63 -0
- package/configure/lib/add-row.js +27 -73
- package/configure/lib/add-row.js.map +1 -1
- package/configure/lib/answer-config-block.js +262 -335
- package/configure/lib/answer-config-block.js.map +1 -1
- package/configure/lib/common.js +18 -33
- package/configure/lib/common.js.map +1 -1
- package/configure/lib/configure.js +330 -420
- package/configure/lib/configure.js.map +1 -1
- package/configure/lib/defaults.js +5 -4
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/general-config-block.js +123 -190
- package/configure/lib/general-config-block.js.map +1 -1
- package/configure/lib/index.js +117 -190
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/row.js +269 -377
- package/configure/lib/row.js.map +1 -1
- package/configure/lib/utils.js +4 -15
- package/configure/lib/utils.js.map +1 -1
- package/configure/package.json +15 -14
- package/controller/CHANGELOG.md +49 -0
- package/controller/lib/defaults.js +2 -3
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +173 -301
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +6 -6
- package/lib/answer-grid.js +142 -242
- package/lib/answer-grid.js.map +1 -1
- package/lib/index.js +59 -108
- package/lib/index.js.map +1 -1
- package/lib/main.js +123 -191
- package/lib/main.js.map +1 -1
- package/package.json +18 -29
- package/esm/configure.js +0 -3936
- package/esm/configure.js.map +0 -1
- package/esm/controller.js +0 -428
- package/esm/controller.js.map +0 -1
- package/esm/element.js +0 -472
- package/esm/element.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":["log","getResponseCorrectness","model","answers","env","isPartialScoring","partialScoring","enabled","rows","checkboxMode","choiceMode","Object","keys","length","totalCorrectAnswers","getTotalCorrectAnswers","getTotalCorrect","correctAnswers","incorrectAnswers","checkboxes","getCheckboxes","getCorrectRadios","getCorrectness","question","mode","forEach","row","answer","id","values","v","i","matchingTable","layout","noOfTotalCorrectAnswers","value","getPartialScore","totalCorrect","total","extraAnswers","score","parseFloat","toFixed","getOutComeScore","correctness","outcome","session","Promise","resolve","undefined","completed","empty","out","createDefaultModel","defaults","normalize","updateSession","normalizedQuestion","correctResponse","correctInfo","lockChoiceOrder","fb","feedbackEnabled","feedback","then","extraCSSRules","promptEnabled","prompt","essentials","allowFeedback","shuffled","disabled","view","role","teacherInstructions","teacherInstructionsEnabled","rationale","rationaleEnabled","assign","createCorrectResponseSession","r","getInnerText","html","replaceAll","getContent","replace","validate","config","headers","minQuestions","maxQuestions","maxLengthQuestionsHeading","maxAnswers","maxLengthAnswers","maxLengthFirstColumnHeading","rowsErrors","columnsErrors","errors","field","required","noOfRowsError","index","title","identicalAnswer","slice","some","hasCorrectResponse","columnsLengthError","headersContent","map","heading","shift","headerIndex","head","hasRowErrors","error","noCorrectAnswer","includes","correctResponseError","hasColumnErrors"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAIA;;;;;;;;AAFA,IAAMA,GAAG,GAAG,uBAAM,+BAAN,CAAZ;;AAIA,IAAMC,sBAAsB,GAAG,SAAzBA,sBAAyB,CAACC,KAAD,EAAQC,OAAR,EAA8B;AAAA,MAAbC,GAAa,uEAAP,EAAO;;AAC3D,MAAMC,gBAAgB,GAAGC,gCAAeC,OAAf,CAAuBL,KAAvB,EAA8BE,GAA9B,CAAzB;;AACA,MAAMI,IAAI,GAAGN,KAAK,CAACM,IAAnB;AACA,MAAMC,YAAY,GAAGP,KAAK,CAACQ,UAAN,KAAqB,UAA1C;;AAEA,MAAI,CAACP,OAAD,IAAYQ,MAAM,CAACC,IAAP,CAAYT,OAAZ,EAAqBU,MAArB,KAAgC,CAAhD,EAAmD;AACjD,WAAO,YAAP;AACD;;AAED,MAAMC,mBAAmB,GAAGL,YAAY,GAAGM,sBAAsB,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AA,KAA/B,CAAxB;;AAIA,QAAID,eAAJ,EAAqB;AACnBnB,MAAAA,MAAM,CAACqB,oBAAP,GACE5G,UAAU,KAAK,OAAf,GACI,2DADJ,GAEI,sEAHN;AAID;AACF;;AAED,MAAM6G,eAAe,GAAG5G,MAAM,CAACkB,MAAP,CAAcmE,aAAd,EAA6BS,IAA7B,CAAkC,UAACU,KAAD;AAAA,WAAW,CAACA,KAAK,IAAI,EAAV,EAActG,MAAzB;AAAA,GAAlC,CAAxB;;AAEA,MAAI0G,eAAJ,EAAqB;AACnBtB,IAAAA,MAAM,CAACD,aAAP,GAAuBA,aAAvB;AACD;;AAED,SAAOC,MAAP;AACD,CA3GM","sourcesContent":["import isEqual from 'lodash/isEqual';\nimport isEmpty from 'lodash/isEmpty';\nimport cloneDeep from 'lodash/cloneDeep';\nimport { getFeedbackForCorrectness } from '@pie-lib/feedback';\nimport { lockChoices, getShuffledChoices, partialScoring } from '@pie-lib/controller-utils';\nimport debug from 'debug';\n\nconst log = debug('@pie-element:match:controller');\n\nimport defaults from './defaults';\n\nconst getResponseCorrectness = (model, answers, env = {}) => {\n const isPartialScoring = partialScoring.enabled(model, env);\n const rows = model.rows;\n const checkboxMode = model.choiceMode === 'checkbox';\n\n if (!answers || Object.keys(answers).length === 0) {\n return 'unanswered';\n }\n\n const totalCorrectAnswers = checkboxMode ? getTotalCorrectAnswers(model) : getTotalCorrect(model);\n let correctAnswers;\n let incorrectAnswers = 0;\n\n if (checkboxMode) {\n const checkboxes = getCheckboxes(rows, answers);\n\n correctAnswers = checkboxes.correctAnswers;\n incorrectAnswers = checkboxes.incorrectAnswers;\n } else {\n correctAnswers = getCorrectRadios(rows, answers);\n }\n\n if (totalCorrectAnswers === correctAnswers && !incorrectAnswers) {\n return 'correct';\n } else if (correctAnswers === 0) {\n return 'incorrect';\n } else if (isPartialScoring) {\n return 'partial';\n }\n\n return 'incorrect';\n};\n\nconst getCorrectness = (question, env, answers = {}) => {\n if (env.mode === 'evaluate') {\n return getResponseCorrectness(question, answers, env);\n }\n};\n\nconst getCheckboxes = (rows, answers) => {\n let correctAnswers = 0;\n let incorrectAnswers = 0;\n\n rows.forEach((row) => {\n const answer = answers[row.id];\n\n if (answer) {\n row.values.forEach((v, i) => {\n if (answer[i] && answer[i] === v) {\n correctAnswers += 1;\n } else if (answer[i] && answer[i] !== v) {\n incorrectAnswers += 1;\n }\n });\n }\n });\n\n return { correctAnswers, incorrectAnswers };\n};\n\nconst getCorrectRadios = (rows, answers) => {\n let correctAnswers = 0;\n\n rows.forEach((row) => {\n if (isEqual(row.values, answers[row.id])) {\n correctAnswers += 1;\n }\n });\n\n return correctAnswers;\n};\n\nconst getTotalCorrect = (question) => {\n const checkboxMode = question.choiceMode === 'checkbox';\n const matchingTable = checkboxMode ? question.layout - 1 : 1;\n return (question.rows.length || 0) * matchingTable;\n};\n\nconst getTotalCorrectAnswers = (question) => {\n let noOfTotalCorrectAnswers = 0;\n\n question.rows.forEach((row) => {\n row.values.forEach((value) => {\n if (value) {\n noOfTotalCorrectAnswers += 1;\n }\n });\n });\n\n return noOfTotalCorrectAnswers;\n};\n\nconst getPartialScore = (question, answers) => {\n const checkboxMode = question.choiceMode === 'checkbox';\n\n if (checkboxMode) {\n const { correctAnswers, incorrectAnswers } = getCheckboxes(question.rows, answers);\n const totalCorrect = getTotalCorrectAnswers(question);\n\n const total = totalCorrect === 0 ? 1 : totalCorrect;\n\n if (correctAnswers + incorrectAnswers > totalCorrect) {\n const extraAnswers = correctAnswers + incorrectAnswers - totalCorrect;\n const score = parseFloat(((correctAnswers - extraAnswers) / total).toFixed(2));\n\n return score < 0 ? 0 : score;\n } else {\n return parseFloat((correctAnswers / total).toFixed(2));\n }\n } else {\n const correctAnswers = getCorrectRadios(question.rows, answers);\n const totalCorrect = getTotalCorrect(question) === 0 ? 1 : getTotalCorrect(question);\n\n return parseFloat((correctAnswers / totalCorrect).toFixed(2));\n }\n};\n\nconst getOutComeScore = (question, env, answers = {}) => {\n const correctness = getCorrectness(question, env, answers);\n const isPartialScoring = partialScoring.enabled(question, env);\n\n return correctness === 'correct'\n ? 1\n : correctness === 'partial' && isPartialScoring\n ? getPartialScore(question, answers)\n : 0;\n};\n\nexport const outcome = (question, session, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate') {\n resolve({ score: undefined, completed: undefined });\n } else {\n if (!session || isEmpty(session)) {\n resolve({ score: 0, empty: true });\n }\n\n const out = {\n score: getOutComeScore(question, env, session.answers),\n };\n\n resolve(out);\n }\n });\n};\n\nexport function createDefaultModel(model = {}) {\n return new Promise((resolve) => {\n resolve({\n ...defaults,\n ...model,\n });\n });\n}\n\nexport const normalize = (question) => ({ ...defaults, ...question });\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.\n */\nexport function model(question, session, env, updateSession) {\n return new Promise(async (resolve) => {\n const normalizedQuestion = cloneDeep(normalize(question));\n let correctness, score;\n\n if ((!session || isEmpty(session)) && env.mode === 'evaluate') {\n correctness = 'unanswered';\n score = '0%';\n } else {\n correctness = getCorrectness(normalizedQuestion, env, session && session.answers);\n score = `${getOutComeScore(normalizedQuestion, env, session && session.answers) * 100}%`;\n }\n\n const correctResponse = {};\n const correctInfo = {\n score,\n correctness,\n };\n\n const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);\n\n if (!lockChoiceOrder) {\n normalizedQuestion.rows = await getShuffledChoices(normalizedQuestion.rows, session, updateSession, 'id');\n }\n\n normalizedQuestion.rows.forEach((row) => {\n correctResponse[row.id] = row.values;\n\n if (env.mode !== 'evaluate') {\n delete row.values;\n }\n });\n\n const fb =\n env.mode === 'evaluate' && normalizedQuestion.feedbackEnabled\n ? getFeedbackForCorrectness(correctInfo.correctness, normalizedQuestion.feedback)\n : Promise.resolve(undefined);\n\n fb.then((feedback) => {\n const { extraCSSRules, feedbackEnabled, promptEnabled, prompt, lockChoiceOrder, ...essentials } =\n normalizedQuestion;\n const out = {\n ...essentials,\n extraCSSRules,\n allowFeedback: feedbackEnabled,\n prompt: promptEnabled ? prompt : null,\n shuffled: !lockChoiceOrder,\n feedback,\n disabled: env.mode !== 'gather',\n view: env.mode === 'view',\n };\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n } else {\n out.rationale = null;\n out.teacherInstructions = null;\n }\n\n if (env.mode === 'evaluate') {\n Object.assign(out, {\n correctResponse,\n correctness: correctInfo,\n });\n }\n\n log('out: ', out);\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 { rows } = question;\n const answers = {};\n\n rows.forEach((r) => {\n answers[r.id] = r.values;\n });\n\n resolve({\n answers,\n id: '1',\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 { rows, choiceMode, headers } = model;\n const {\n minQuestions,\n maxQuestions,\n maxLengthQuestionsHeading,\n maxAnswers,\n maxLengthAnswers,\n maxLengthFirstColumnHeading,\n } = config;\n const rowsErrors = {};\n const columnsErrors = {};\n const errors = {};\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 if (rows.length < minQuestions) {\n errors.noOfRowsError = `There should be at least ${minQuestions} question rows.`;\n } else if (rows.length > maxQuestions) {\n errors.noOfRowsError = `No more than ${maxQuestions} question rows should be defined.`;\n }\n\n (rows || []).forEach((row, index) => {\n const { id, values = [], title } = row;\n rowsErrors[id] = '';\n\n if (maxLengthQuestionsHeading && getInnerText(title).length > maxLengthQuestionsHeading) {\n rowsErrors[id] += `Content length should be maximum ${maxLengthQuestionsHeading} characters. `;\n }\n\n if (!getContent(title)) {\n rowsErrors[id] += 'Content should not be empty. ';\n } else {\n // check for identical content with the previous answers\n const identicalAnswer = rows.slice(0, index).some((r) => getContent(r.title) === getContent(title));\n\n if (identicalAnswer) {\n rowsErrors[id] += 'Content should be unique. ';\n }\n }\n\n const hasCorrectResponse = values.some((value) => !!value);\n\n if (!hasCorrectResponse) {\n rowsErrors[id] += 'No correct response defined.';\n }\n });\n\n if (maxAnswers && headers.length - 1 > maxAnswers) {\n errors.columnsLengthError = `There should be maximum ${maxAnswers} answers.`;\n }\n\n if (maxLengthFirstColumnHeading && headers[0].length > maxLengthFirstColumnHeading) {\n columnsErrors[0] = `Content length should be maximum ${maxLengthFirstColumnHeading} characters.`;\n }\n\n const headersContent = (headers || []).map((heading) => getContent(heading));\n headersContent.shift(); // remove first column since it does not require validation\n\n headersContent.forEach((heading, index) => {\n const headerIndex = index + 1; // we need to add 1 because we removed first header from validation\n columnsErrors[headerIndex] = '';\n\n if (maxLengthAnswers && getInnerText(heading).length > maxLengthAnswers) {\n columnsErrors[headerIndex] += `Content length should be maximum ${maxLengthAnswers} characters. `;\n }\n\n if (!heading) {\n columnsErrors[headerIndex] += 'Content should not be empty.';\n } else {\n // check for identical content with the previous headers\n const identicalAnswer = headersContent.slice(0, index).some((head) => head === heading);\n\n if (identicalAnswer) {\n columnsErrors[index + 1] += 'Content should be unique.';\n }\n }\n });\n\n const hasRowErrors = Object.values(rowsErrors).some((error) => (error || '').length);\n\n if (hasRowErrors) {\n errors.rowsErrors = rowsErrors;\n\n const noCorrectAnswer = Object.values(rowsErrors).some((error) =>\n (error || '').includes('No correct response defined.'),\n );\n\n if (noCorrectAnswer) {\n errors.correctResponseError =\n choiceMode === 'radio'\n ? 'There should be a correct response defined for every row.'\n : 'There should be at least one correct response defined for every row.';\n }\n }\n\n const hasColumnErrors = Object.values(columnsErrors).some((error) => (error || '').length);\n\n if (hasColumnErrors) {\n errors.columnsErrors = columnsErrors;\n }\n\n return errors;\n};\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_lodashEs","require","_feedback","_controllerUtils","_debug","_interopRequireDefault","_defaults","log","debug","getResponseCorrectness","model","answers","env","isPartialScoring","partialScoring","enabled","rows","checkboxMode","choiceMode","Object","keys","length","totalCorrectAnswers","getTotalCorrectAnswers","getTotalCorrect","correctAnswers","incorrectAnswers","checkboxes","getCheckboxes","getCorrectRadios","getCorrectness","question","mode","forEach","row","answer","id","values","v","i","isEqual","matchingTable","layout","noOfTotalCorrectAnswers","value","getPartialScore","totalCorrect","total","extraAnswers","score","parseFloat","toFixed","getOutComeScore","correctness","outcome","session","Promise","resolve","undefined","completed","isEmpty","empty","out","exports","createDefaultModel","defaults","normalize","updateSession","normalizedQuestion","cloneDeep","correctResponse","correctInfo","lockChoiceOrder","lockChoices","getShuffledChoices","feedback","feedbackEnabled","getFeedbackForCorrectness","extraCSSRules","promptEnabled","prompt","_","essentials","allowFeedback","shuffled","disabled","view","role","teacherInstructions","teacherInstructionsEnabled","rationale","rationaleEnabled","assign","createCorrectResponseSession","r","getInnerText","html","replaceAll","getContent","replace","validate","config","headers","minQuestions","maxQuestions","maxLengthQuestionsHeading","maxAnswers","maxLengthAnswers","maxLengthFirstColumnHeading","rowsErrors","columnsErrors","errors","field","required","noOfRowsError","index","title","identicalAnswer","slice","some","hasCorrectResponse","columnsLengthError","headersContent","map","heading","shift","headerIndex","head","hasRowErrors","error","noCorrectAnswer","includes","correctResponseError","hasColumnErrors"],"sources":["../src/index.js"],"sourcesContent":["import { cloneDeep, isEmpty, isEqual } from 'lodash-es';\nimport { getFeedbackForCorrectness } from '@pie-lib/feedback';\nimport { lockChoices, getShuffledChoices, partialScoring } from '@pie-lib/controller-utils';\nimport debug from 'debug';\n\nconst log = debug('@pie-element:match:controller');\n\nimport defaults from './defaults';\n\nconst getResponseCorrectness = (model, answers, env = {}) => {\n const isPartialScoring = partialScoring.enabled(model, env);\n const rows = model.rows;\n const checkboxMode = model.choiceMode === 'checkbox';\n\n if (!answers || Object.keys(answers).length === 0) {\n return 'unanswered';\n }\n\n const totalCorrectAnswers = checkboxMode ? getTotalCorrectAnswers(model) : getTotalCorrect(model);\n let correctAnswers;\n let incorrectAnswers = 0;\n\n if (checkboxMode) {\n const checkboxes = getCheckboxes(rows, answers);\n\n correctAnswers = checkboxes.correctAnswers;\n incorrectAnswers = checkboxes.incorrectAnswers;\n } else {\n correctAnswers = getCorrectRadios(rows, answers);\n }\n\n if (totalCorrectAnswers === correctAnswers && !incorrectAnswers) {\n return 'correct';\n } else if (correctAnswers === 0) {\n return 'incorrect';\n } else if (isPartialScoring) {\n return 'partial';\n }\n\n return 'incorrect';\n};\n\nconst getCorrectness = (question, env, answers = {}) => {\n if (env.mode === 'evaluate') {\n return getResponseCorrectness(question, answers, env);\n }\n};\n\nconst getCheckboxes = (rows, answers) => {\n let correctAnswers = 0;\n let incorrectAnswers = 0;\n\n rows.forEach((row) => {\n const answer = answers[row.id];\n\n if (answer) {\n row.values.forEach((v, i) => {\n if (answer[i] && answer[i] === v) {\n correctAnswers += 1;\n } else if (answer[i] && answer[i] !== v) {\n incorrectAnswers += 1;\n }\n });\n }\n });\n\n return { correctAnswers, incorrectAnswers };\n};\n\nconst getCorrectRadios = (rows, answers) => {\n let correctAnswers = 0;\n\n rows.forEach((row) => {\n if (isEqual(row.values, answers[row.id])) {\n correctAnswers += 1;\n }\n });\n\n return correctAnswers;\n};\n\nconst getTotalCorrect = (question) => {\n const checkboxMode = question.choiceMode === 'checkbox';\n const matchingTable = checkboxMode ? question.layout - 1 : 1;\n return (question.rows.length || 0) * matchingTable;\n};\n\nconst getTotalCorrectAnswers = (question) => {\n let noOfTotalCorrectAnswers = 0;\n\n question.rows.forEach((row) => {\n row.values.forEach((value) => {\n if (value) {\n noOfTotalCorrectAnswers += 1;\n }\n });\n });\n\n return noOfTotalCorrectAnswers;\n};\n\nconst getPartialScore = (question, answers) => {\n const checkboxMode = question.choiceMode === 'checkbox';\n\n if (checkboxMode) {\n const { correctAnswers, incorrectAnswers } = getCheckboxes(question.rows, answers);\n const totalCorrect = getTotalCorrectAnswers(question);\n\n const total = totalCorrect === 0 ? 1 : totalCorrect;\n\n if (correctAnswers + incorrectAnswers > totalCorrect) {\n const extraAnswers = correctAnswers + incorrectAnswers - totalCorrect;\n const score = parseFloat(((correctAnswers - extraAnswers) / total).toFixed(2));\n\n return score < 0 ? 0 : score;\n } else {\n return parseFloat((correctAnswers / total).toFixed(2));\n }\n } else {\n const correctAnswers = getCorrectRadios(question.rows, answers);\n const totalCorrect = getTotalCorrect(question) === 0 ? 1 : getTotalCorrect(question);\n\n return parseFloat((correctAnswers / totalCorrect).toFixed(2));\n }\n};\n\nconst getOutComeScore = (question, env, answers = {}) => {\n const correctness = getCorrectness(question, env, answers);\n const isPartialScoring = partialScoring.enabled(question, env);\n\n return correctness === 'correct'\n ? 1\n : correctness === 'partial' && isPartialScoring\n ? getPartialScore(question, answers)\n : 0;\n};\n\nexport const outcome = (question, session, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate') {\n resolve({ score: undefined, completed: undefined });\n } else {\n if (!session || isEmpty(session)) {\n resolve({ score: 0, empty: true });\n }\n\n const out = {\n score: getOutComeScore(question, env, session.answers),\n };\n\n resolve(out);\n }\n });\n};\n\nexport function createDefaultModel(model = {}) {\n return new Promise((resolve) => {\n resolve({\n ...defaults,\n ...model,\n });\n });\n}\n\nexport const normalize = (question) => ({ ...defaults, ...question });\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.\n */\nexport async function model(question, session, env, updateSession) {\n const normalizedQuestion = cloneDeep(normalize(question));\n let correctness, score;\n\n if ((!session || isEmpty(session)) && env.mode === 'evaluate') {\n correctness = 'unanswered';\n score = '0%';\n } else {\n correctness = getCorrectness(normalizedQuestion, env, session && session.answers);\n score = `${getOutComeScore(normalizedQuestion, env, session && session.answers) * 100}%`;\n }\n\n const correctResponse = {};\n const correctInfo = {\n score,\n correctness,\n };\n\n const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);\n\n if (!lockChoiceOrder) {\n normalizedQuestion.rows = await getShuffledChoices(normalizedQuestion.rows, session, updateSession, 'id');\n }\n\n normalizedQuestion.rows.forEach((row) => {\n correctResponse[row.id] = row.values;\n\n if (env.mode !== 'evaluate') {\n delete row.values;\n }\n });\n\n const feedback =\n env.mode === 'evaluate' && normalizedQuestion.feedbackEnabled\n ? await getFeedbackForCorrectness(correctInfo.correctness, normalizedQuestion.feedback)\n : undefined;\n\n const {\n extraCSSRules,\n feedbackEnabled,\n promptEnabled,\n prompt,\n lockChoiceOrder: _,\n ...essentials\n } = normalizedQuestion;\n const out = {\n ...essentials,\n extraCSSRules,\n allowFeedback: feedbackEnabled,\n prompt: promptEnabled ? prompt : null,\n shuffled: !lockChoiceOrder,\n feedback,\n disabled: env.mode !== 'gather',\n view: env.mode === 'view',\n };\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n } else {\n out.rationale = null;\n out.teacherInstructions = null;\n }\n\n if (env.mode === 'evaluate') {\n Object.assign(out, {\n correctResponse,\n correctness: correctInfo,\n });\n }\n\n log('out: ', out);\n return out;\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { rows } = question;\n const answers = {};\n\n rows.forEach((r) => {\n answers[r.id] = r.values;\n });\n\n resolve({\n answers,\n id: '1',\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 { rows, choiceMode, headers } = model;\n const {\n minQuestions,\n maxQuestions,\n maxLengthQuestionsHeading,\n maxAnswers,\n maxLengthAnswers,\n maxLengthFirstColumnHeading,\n } = config;\n const rowsErrors = {};\n const columnsErrors = {};\n const errors = {};\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 if (rows.length < minQuestions) {\n errors.noOfRowsError = `There should be at least ${minQuestions} question rows.`;\n } else if (rows.length > maxQuestions) {\n errors.noOfRowsError = `No more than ${maxQuestions} question rows should be defined.`;\n }\n\n (rows || []).forEach((row, index) => {\n const { id, values = [], title } = row;\n rowsErrors[id] = '';\n\n if (maxLengthQuestionsHeading && getInnerText(title).length > maxLengthQuestionsHeading) {\n rowsErrors[id] += `Content length should be maximum ${maxLengthQuestionsHeading} characters. `;\n }\n\n if (!getContent(title)) {\n rowsErrors[id] += 'Content should not be empty. ';\n } else {\n // check for identical content with the previous answers\n const identicalAnswer = rows.slice(0, index).some((r) => getContent(r.title) === getContent(title));\n\n if (identicalAnswer) {\n rowsErrors[id] += 'Content should be unique. ';\n }\n }\n\n const hasCorrectResponse = values.some((value) => !!value);\n\n if (!hasCorrectResponse) {\n rowsErrors[id] += 'No correct response defined.';\n }\n });\n\n if (maxAnswers && headers.length - 1 > maxAnswers) {\n errors.columnsLengthError = `There should be maximum ${maxAnswers} answers.`;\n }\n\n if (maxLengthFirstColumnHeading && headers[0].length > maxLengthFirstColumnHeading) {\n columnsErrors[0] = `Content length should be maximum ${maxLengthFirstColumnHeading} characters.`;\n }\n\n const headersContent = (headers || []).map((heading) => getContent(heading));\n headersContent.shift(); // remove first column since it does not require validation\n\n headersContent.forEach((heading, index) => {\n const headerIndex = index + 1; // we need to add 1 because we removed first header from validation\n columnsErrors[headerIndex] = '';\n\n if (maxLengthAnswers && getInnerText(heading).length > maxLengthAnswers) {\n columnsErrors[headerIndex] += `Content length should be maximum ${maxLengthAnswers} characters. `;\n }\n\n if (!heading) {\n columnsErrors[headerIndex] += 'Content should not be empty.';\n } else {\n // check for identical content with the previous headers\n const identicalAnswer = headersContent.slice(0, index).some((head) => head === heading);\n\n if (identicalAnswer) {\n columnsErrors[index + 1] += 'Content should be unique.';\n }\n }\n });\n\n const hasRowErrors = Object.values(rowsErrors).some((error) => (error || '').length);\n\n if (hasRowErrors) {\n errors.rowsErrors = rowsErrors;\n\n const noCorrectAnswer = Object.values(rowsErrors).some((error) =>\n (error || '').includes('No correct response defined.'),\n );\n\n if (noCorrectAnswer) {\n errors.correctResponseError =\n choiceMode === 'radio'\n ? 'There should be a correct response defined for every row.'\n : 'There should be at least one correct response defined for every row.';\n }\n }\n\n const hasColumnErrors = Object.values(columnsErrors).some((error) => (error || '').length);\n\n if (hasColumnErrors) {\n errors.columnsErrors = columnsErrors;\n }\n\n return errors;\n};\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAIA,IAAAK,SAAA,GAAAD,sBAAA,CAAAJ,OAAA;AAFA,MAAMM,GAAG,GAAG,IAAAC,cAAK,EAAC,+BAA+B,CAAC;AAIlD,MAAMC,sBAAsB,GAAGA,CAACC,KAAK,EAAEC,OAAO,EAAEC,GAAG,GAAG,CAAC,CAAC,KAAK;EAC3D,MAAMC,gBAAgB,GAAGC,+BAAc,CAACC,OAAO,CAACL,KAAK,EAAEE,GAAG,CAAC;EAC3D,MAAMI,IAAI,GAAGN,KAAK,CAACM,IAAI;EACvB,MAAMC,YAAY,GAAGP,KAAK,CAACQ,UAAU,KAAK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MAAM;AACf,CAAC;AAAChD,OAAA,CAAAqC,QAAA,GAAAA,QAAA","ignoreList":[]}
|
package/controller/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/match-controller",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "9.1.0-next.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "src/index.js",
|
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
"test": "./node_modules/.bin/jest"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@pie-lib/controller-utils": "
|
|
13
|
-
"@pie-lib/feedback": "
|
|
14
|
-
"debug": "^
|
|
12
|
+
"@pie-lib/controller-utils": "1.1.1-next.1",
|
|
13
|
+
"@pie-lib/feedback": "1.1.1-next.1",
|
|
14
|
+
"debug": "^4.1.1"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"babel-jest": "^
|
|
17
|
+
"babel-jest": "^29.7.0",
|
|
18
18
|
"babel-preset-env": "^1.6.1",
|
|
19
19
|
"babel-preset-stage-0": "^6.24.1",
|
|
20
|
-
"jest": "^
|
|
20
|
+
"jest": "^29.7.0"
|
|
21
21
|
},
|
|
22
22
|
"author": "",
|
|
23
23
|
"license": "ISC"
|
package/lib/answer-grid.js
CHANGED
|
@@ -1,263 +1,163 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
|
-
exports
|
|
9
|
-
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
15
|
-
|
|
16
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
-
|
|
18
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
-
|
|
20
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
-
|
|
7
|
+
exports.default = exports.AnswerGrid = void 0;
|
|
22
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
-
|
|
24
9
|
var _react = _interopRequireDefault(require("react"));
|
|
25
|
-
|
|
26
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
27
|
-
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
var _Checkbox = _interopRequireDefault(require("@material-ui/core/Checkbox"));
|
|
33
|
-
|
|
34
|
-
var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));
|
|
35
|
-
|
|
36
|
-
var _styles = require("@material-ui/core/styles");
|
|
37
|
-
|
|
11
|
+
var _Radio = _interopRequireDefault(require("@mui/material/Radio"));
|
|
12
|
+
var _Checkbox = _interopRequireDefault(require("@mui/material/Checkbox"));
|
|
13
|
+
var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
|
14
|
+
var _styles = require("@mui/material/styles");
|
|
38
15
|
var _renderUi = require("@pie-lib/render-ui");
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
16
|
+
const ControlsContainer = (0, _styles.styled)('div')(({
|
|
17
|
+
theme
|
|
18
|
+
}) => ({
|
|
19
|
+
marginLeft: 'auto',
|
|
20
|
+
marginRight: 'auto',
|
|
21
|
+
marginTop: theme.spacing(1),
|
|
22
|
+
marginBottom: theme.spacing(1)
|
|
23
|
+
}));
|
|
24
|
+
const Column = (0, _styles.styled)('td')({
|
|
25
|
+
padding: '5px 0'
|
|
26
|
+
});
|
|
27
|
+
const EmptyTypography = (0, _styles.styled)(_Typography.default)(({
|
|
28
|
+
theme
|
|
29
|
+
}) => ({
|
|
30
|
+
margin: theme.spacing(2)
|
|
31
|
+
}));
|
|
32
|
+
const RowHeader = (0, _styles.styled)('th')({
|
|
33
|
+
padding: 0
|
|
34
|
+
});
|
|
35
|
+
const RowItem = (0, _styles.styled)('div')(({
|
|
36
|
+
theme,
|
|
37
|
+
isQuestionText
|
|
38
|
+
}) => ({
|
|
39
|
+
padding: theme.spacing(1.5),
|
|
40
|
+
textAlign: isQuestionText ? 'left' : 'center'
|
|
41
|
+
}));
|
|
42
|
+
const Separator = (0, _styles.styled)('tr')({
|
|
43
|
+
border: 0,
|
|
44
|
+
borderTop: `2.5px solid ${_renderUi.color.primaryLight()}`,
|
|
45
|
+
width: '100%'
|
|
46
|
+
});
|
|
47
|
+
const Table = (0, _styles.styled)('table')({
|
|
48
|
+
color: _renderUi.color.text(),
|
|
49
|
+
backgroundColor: _renderUi.color.background(),
|
|
50
|
+
borderCollapse: 'collapse',
|
|
51
|
+
borderSpacing: 0,
|
|
52
|
+
marginBottom: 0
|
|
53
|
+
});
|
|
54
|
+
class AnswerGrid extends _react.default.Component {
|
|
55
|
+
constructor(...args) {
|
|
56
|
+
super(...args);
|
|
57
|
+
(0, _defineProperty2.default)(this, "onRowValueChange", (rowId, answerIndex) => event => {
|
|
58
|
+
const {
|
|
59
|
+
onAnswerChange,
|
|
60
|
+
choiceMode,
|
|
61
|
+
answers
|
|
62
|
+
} = this.props;
|
|
63
|
+
const newAnswers = {
|
|
64
|
+
...answers
|
|
80
65
|
};
|
|
66
|
+
if (choiceMode === 'radio') {
|
|
67
|
+
for (let i = 0; i < newAnswers[rowId].length; i++) {
|
|
68
|
+
newAnswers[rowId][i] = false;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
newAnswers[rowId][answerIndex] = event.target.checked;
|
|
72
|
+
onAnswerChange(newAnswers);
|
|
81
73
|
});
|
|
82
|
-
(0, _defineProperty2
|
|
83
|
-
|
|
74
|
+
(0, _defineProperty2.default)(this, "answerIsCorrect", (rowId, rowValue, rowValueIndex) => {
|
|
75
|
+
const {
|
|
76
|
+
correctAnswers
|
|
77
|
+
} = this.props;
|
|
84
78
|
return correctAnswers[rowId][rowValueIndex] === rowValue && rowValue === true;
|
|
85
79
|
});
|
|
86
|
-
|
|
87
|
-
|
|
80
|
+
// needs a separate method because what isn't correct isn't necessarily incorrect
|
|
81
|
+
(0, _defineProperty2.default)(this, "answerIsIncorrect", (rowId, rowValue, rowValueIndex) => {
|
|
82
|
+
const {
|
|
83
|
+
correctAnswers
|
|
84
|
+
} = this.props;
|
|
88
85
|
return correctAnswers[rowId][rowValueIndex] === true && rowValue === false || correctAnswers[rowId][rowValueIndex] === false && rowValue === true;
|
|
89
86
|
});
|
|
90
|
-
return _this;
|
|
91
87
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
var evaluate = disabled && !view;
|
|
109
|
-
|
|
110
|
-
if (!rows || rows.length === 0) {
|
|
111
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
112
|
-
className: classes.controlsContainer
|
|
113
|
-
}, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
114
|
-
className: classes.empty,
|
|
115
|
-
component: "div"
|
|
116
|
-
}, "There are currently no questions to show."));
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
120
|
-
className: classes.controlsContainer
|
|
121
|
-
}, /*#__PURE__*/_react["default"].createElement("table", {
|
|
122
|
-
className: classes.table
|
|
123
|
-
}, /*#__PURE__*/_react["default"].createElement("colgroup", null, (headers || []).map(function (header, idx) {
|
|
124
|
-
return /*#__PURE__*/_react["default"].createElement("col", {
|
|
125
|
-
key: "col-".concat(idx)
|
|
126
|
-
});
|
|
127
|
-
})), /*#__PURE__*/_react["default"].createElement("thead", null, /*#__PURE__*/_react["default"].createElement("tr", null, (headers || []).map(function (header, idx) {
|
|
128
|
-
return /*#__PURE__*/_react["default"].createElement("th", {
|
|
129
|
-
className: classes.rowHeader,
|
|
130
|
-
key: "th-".concat(idx),
|
|
131
|
-
"data-colno": "".concat(idx),
|
|
132
|
-
scope: "row"
|
|
133
|
-
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
134
|
-
className: (0, _classnames["default"])(classes.rowItem, (0, _defineProperty2["default"])({}, classes.questionText, idx === 0)),
|
|
135
|
-
dangerouslySetInnerHTML: {
|
|
136
|
-
__html: header
|
|
137
|
-
}
|
|
138
|
-
}));
|
|
139
|
-
}))), (rows || []).map(function (row, idx) {
|
|
140
|
-
return /*#__PURE__*/_react["default"].createElement("tbody", {
|
|
141
|
-
key: "row-".concat(idx),
|
|
142
|
-
role: "group"
|
|
143
|
-
}, /*#__PURE__*/_react["default"].createElement("tr", {
|
|
144
|
-
className: classes.separator
|
|
145
|
-
}, /*#__PURE__*/_react["default"].createElement("td", {
|
|
146
|
-
key: "td-title-".concat(idx),
|
|
147
|
-
"data-colno": '0'
|
|
148
|
-
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
149
|
-
className: (0, _classnames["default"])(classes.rowItem, classes.questionText),
|
|
150
|
-
dangerouslySetInnerHTML: {
|
|
151
|
-
__html: row.title
|
|
152
|
-
}
|
|
153
|
-
})), (answers[row.id] || []).map(function (rowItem, answerIndex) {
|
|
154
|
-
var _cx2;
|
|
155
|
-
|
|
156
|
-
return /*#__PURE__*/_react["default"].createElement("td", {
|
|
157
|
-
key: "td-".concat(idx, "-").concat(answerIndex),
|
|
158
|
-
className: classes.column,
|
|
159
|
-
"data-colno": "".concat(answerIndex + 1)
|
|
160
|
-
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
161
|
-
className: classes.rowItem
|
|
162
|
-
}, /*#__PURE__*/_react["default"].createElement(Tag, {
|
|
163
|
-
className: (0, _classnames["default"])(classes.tag, (_cx2 = {}, (0, _defineProperty2["default"])(_cx2, classes.correct, showCorrect && rowItem === true || evaluate && _this2.answerIsCorrect(row.id, rowItem, answerIndex)), (0, _defineProperty2["default"])(_cx2, classes.checked, rowItem === true && !evaluate), (0, _defineProperty2["default"])(_cx2, classes.tagDisabled, disabled), (0, _defineProperty2["default"])(_cx2, classes.incorrect, evaluate && _this2.answerIsIncorrect(row.id, rowItem, answerIndex)), _cx2)),
|
|
164
|
-
disabled: disabled,
|
|
165
|
-
onChange: _this2.onRowValueChange(row.id, answerIndex),
|
|
166
|
-
checked: rowItem === true
|
|
167
|
-
})));
|
|
168
|
-
})));
|
|
169
|
-
})));
|
|
88
|
+
render() {
|
|
89
|
+
const {
|
|
90
|
+
showCorrect,
|
|
91
|
+
headers,
|
|
92
|
+
rows,
|
|
93
|
+
choiceMode,
|
|
94
|
+
answers,
|
|
95
|
+
disabled,
|
|
96
|
+
view
|
|
97
|
+
} = this.props;
|
|
98
|
+
const Tag = choiceMode === 'radio' ? _Radio.default : _Checkbox.default;
|
|
99
|
+
const evaluate = disabled && !view;
|
|
100
|
+
if (!rows || rows.length === 0) {
|
|
101
|
+
return /*#__PURE__*/_react.default.createElement(ControlsContainer, null, /*#__PURE__*/_react.default.createElement(EmptyTypography, {
|
|
102
|
+
component: "div"
|
|
103
|
+
}, "There are currently no questions to show."));
|
|
170
104
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}(_react
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
disabled: _propTypes["default"].bool.isRequired,
|
|
182
|
-
onAnswerChange: _propTypes["default"].func.isRequired,
|
|
183
|
-
choiceMode: _propTypes["default"].string.isRequired,
|
|
184
|
-
rows: _propTypes["default"].array.isRequired,
|
|
185
|
-
headers: _propTypes["default"].array.isRequired,
|
|
186
|
-
answers: _propTypes["default"].object.isRequired
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
var styles = function styles(theme) {
|
|
190
|
-
return {
|
|
191
|
-
controlsContainer: {
|
|
192
|
-
marginLeft: 'auto',
|
|
193
|
-
marginRight: 'auto',
|
|
194
|
-
marginTop: theme.spacing.unit,
|
|
195
|
-
marginBottom: theme.spacing.unit
|
|
196
|
-
},
|
|
197
|
-
column: {
|
|
198
|
-
padding: '5px 0'
|
|
199
|
-
},
|
|
200
|
-
correct: {
|
|
201
|
-
color: "".concat(_renderUi.color.correct(), " !important")
|
|
202
|
-
},
|
|
203
|
-
incorrect: {
|
|
204
|
-
color: "".concat(_renderUi.color.incorrect(), " !important")
|
|
205
|
-
},
|
|
206
|
-
empty: {
|
|
207
|
-
margin: theme.spacing.unit * 2
|
|
208
|
-
},
|
|
209
|
-
rowContainer: {
|
|
210
|
-
display: 'flex',
|
|
211
|
-
alignItems: 'center'
|
|
212
|
-
},
|
|
213
|
-
rowHeader: {
|
|
214
|
-
padding: 0
|
|
215
|
-
},
|
|
216
|
-
rowItem: {
|
|
217
|
-
padding: theme.spacing.unit * 1.5,
|
|
218
|
-
textAlign: 'center'
|
|
219
|
-
},
|
|
220
|
-
separator: {
|
|
221
|
-
border: 0,
|
|
222
|
-
borderTop: "2.5px solid ".concat(_renderUi.color.primaryLight()),
|
|
223
|
-
width: '100%'
|
|
224
|
-
},
|
|
225
|
-
tag: {
|
|
226
|
-
padding: '6px',
|
|
227
|
-
color: _renderUi.color.text(),
|
|
228
|
-
'&:hover': {
|
|
229
|
-
color: _renderUi.color.primaryLight()
|
|
230
|
-
},
|
|
231
|
-
'& input': {
|
|
232
|
-
width: '100% !important'
|
|
105
|
+
return /*#__PURE__*/_react.default.createElement(ControlsContainer, null, /*#__PURE__*/_react.default.createElement(Table, null, /*#__PURE__*/_react.default.createElement("colgroup", null, (headers || []).map((header, idx) => /*#__PURE__*/_react.default.createElement("col", {
|
|
106
|
+
key: `col-${idx}`
|
|
107
|
+
}))), /*#__PURE__*/_react.default.createElement("thead", null, /*#__PURE__*/_react.default.createElement("tr", null, (headers || []).map((header, idx) => /*#__PURE__*/_react.default.createElement(RowHeader, {
|
|
108
|
+
key: `th-${idx}`,
|
|
109
|
+
"data-colno": `${idx}`,
|
|
110
|
+
scope: "row"
|
|
111
|
+
}, /*#__PURE__*/_react.default.createElement(RowItem, {
|
|
112
|
+
isQuestionText: idx === 0,
|
|
113
|
+
dangerouslySetInnerHTML: {
|
|
114
|
+
__html: header
|
|
233
115
|
}
|
|
234
|
-
},
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
},
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
color: _renderUi.color.disabled()
|
|
116
|
+
}))))), (rows || []).map((row, idx) => /*#__PURE__*/_react.default.createElement("tbody", {
|
|
117
|
+
key: `row-${idx}`,
|
|
118
|
+
role: "group"
|
|
119
|
+
}, /*#__PURE__*/_react.default.createElement(Separator, null, /*#__PURE__*/_react.default.createElement("td", {
|
|
120
|
+
key: `td-title-${idx}`,
|
|
121
|
+
"data-colno": '0'
|
|
122
|
+
}, /*#__PURE__*/_react.default.createElement(RowItem, {
|
|
123
|
+
isQuestionText: true,
|
|
124
|
+
dangerouslySetInnerHTML: {
|
|
125
|
+
__html: row.title
|
|
245
126
|
}
|
|
246
|
-
},
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
127
|
+
})), (answers[row.id] || []).map((rowItem, answerIndex) => /*#__PURE__*/_react.default.createElement(Column, {
|
|
128
|
+
key: `td-${idx}-${answerIndex}`,
|
|
129
|
+
"data-colno": `${answerIndex + 1}`
|
|
130
|
+
}, /*#__PURE__*/_react.default.createElement(RowItem, null, /*#__PURE__*/_react.default.createElement(Tag, {
|
|
131
|
+
sx: {
|
|
132
|
+
padding: '6px',
|
|
133
|
+
color: showCorrect && rowItem === true || evaluate && this.answerIsCorrect(row.id, rowItem, answerIndex) ? _renderUi.color.correct() : evaluate && this.answerIsIncorrect(row.id, rowItem, answerIndex) ? _renderUi.color.incorrect() : rowItem === true && !evaluate ? _renderUi.color.primary() : disabled ? _renderUi.color.disabled() : _renderUi.color.text(),
|
|
134
|
+
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
135
|
+
pointerEvents: disabled ? 'initial' : 'auto',
|
|
136
|
+
opacity: disabled ? 0.7 : 1,
|
|
137
|
+
'& input': {
|
|
138
|
+
width: '100% !important'
|
|
139
|
+
},
|
|
140
|
+
'&:hover': {
|
|
141
|
+
color: disabled ? _renderUi.color.disabled() : _renderUi.color.primaryLight()
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
disabled: disabled,
|
|
145
|
+
onChange: this.onRowValueChange(row.id, answerIndex),
|
|
146
|
+
checked: rowItem === true
|
|
147
|
+
})))))))));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
exports.AnswerGrid = AnswerGrid;
|
|
151
|
+
(0, _defineProperty2.default)(AnswerGrid, "propTypes", {
|
|
152
|
+
correctAnswers: _propTypes.default.object,
|
|
153
|
+
view: _propTypes.default.bool.isRequired,
|
|
154
|
+
showCorrect: _propTypes.default.bool.isRequired,
|
|
155
|
+
disabled: _propTypes.default.bool.isRequired,
|
|
156
|
+
onAnswerChange: _propTypes.default.func.isRequired,
|
|
157
|
+
choiceMode: _propTypes.default.string.isRequired,
|
|
158
|
+
rows: _propTypes.default.array.isRequired,
|
|
159
|
+
headers: _propTypes.default.array.isRequired,
|
|
160
|
+
answers: _propTypes.default.object.isRequired
|
|
161
|
+
});
|
|
162
|
+
var _default = exports.default = AnswerGrid;
|
|
263
163
|
//# sourceMappingURL=answer-grid.js.map
|