@cuemath/leap 4.0.8 → 4.1.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.
@@ -12,16 +12,16 @@ const k = ({
12
12
  initialResponseId: r,
13
13
  initialItemIndex: n,
14
14
  lastUnlockedQuestionIndex: o,
15
- lastAttemptableQuestionIndex: i
15
+ lastAttemptableQuestionIndex: c
16
16
  }) => {
17
17
  var u, l;
18
- const a = e.slice(0, o + 1), m = e[o], p = e[i];
19
- if (r && a.find((c) => c.response_id === r))
18
+ const i = e.slice(0, o + 1), m = e[o], p = e[c];
19
+ if (r && i.find((a) => a.response_id === r))
20
20
  return r;
21
21
  if (typeof n == "number" && n <= m.item_number) {
22
- const c = e.find((g) => g.item_number === n);
23
- if (c != null && c.response_id)
24
- return c.response_id;
22
+ const a = e.find((g) => g.item_number === n);
23
+ if (a != null && a.response_id)
24
+ return a.response_id;
25
25
  }
26
26
  if (t === "FIRST" && ((u = e[0]) != null && u.response_id))
27
27
  return e[0].response_id;
@@ -31,9 +31,9 @@ const k = ({
31
31
  return e[0].response_id;
32
32
  throw new Error("Initial question not found");
33
33
  };
34
- function A(e, t) {
34
+ function v(e, t) {
35
35
  var n, o;
36
- const r = Array.isArray(e) ? e.find((i) => i.response_id === t) : e;
36
+ const r = Array.isArray(e) ? e.find((c) => c.response_id === t) : e;
37
37
  if (!r)
38
38
  throw new Error(`Question with id ${t} not found`);
39
39
  return {
@@ -41,27 +41,28 @@ function A(e, t) {
41
41
  itemReference: r.item_reference,
42
42
  itemPosition: r.item_number,
43
43
  questionPosition: r.question_number,
44
- isOkayTypeQuestion: v(r),
44
+ isOkayTypeQuestion: A(r),
45
45
  score: {
46
46
  max_score: ((o = (n = r == null ? void 0 : r.validation) == null ? void 0 : n.valid_response) == null ? void 0 : o.score) ?? 0 * r.metadata.valid_response_count
47
47
  },
48
48
  tags: {
49
49
  ...r.item_tags_map,
50
- instructor_stimulus: r.instructor_stimulus
51
- }
50
+ instructor_stimulus: r.instructor_stimulus ?? ""
51
+ },
52
+ distractor_rationale_response_level: r.metadata.distractor_rationale_response_level
52
53
  };
53
54
  }
54
55
  const x = (e) => e.reduce(
55
56
  (t, r) => ({
56
57
  ...t,
57
- [r.response_id]: A(e, r.response_id)
58
+ [r.response_id]: v(e, r.response_id)
58
59
  }),
59
60
  {}
60
61
  ), Q = (e, t) => {
61
62
  const { actionBar: r } = t;
62
63
  return {
63
64
  questionsContainerWidth: !e.some(
64
- (i) => i.questions.some((a) => a.stimulus_review)
65
+ (c) => c.questions.some((i) => i.stimulus_review)
65
66
  ) ? d : I,
66
67
  maxQuestionWidth: d,
67
68
  actionbarHeight: r === "bottom" ? T : 0
@@ -72,7 +73,7 @@ const x = (e) => e.reduce(
72
73
  block: r,
73
74
  behavior: t ? "smooth" : "instant"
74
75
  });
75
- }, v = (e) => {
76
+ }, A = (e) => {
76
77
  const { type: t, options: r, instructor_stimulus: n } = e;
77
78
  return ("item_type" in e ? e.item_type : void 0) === "overview" || n === "Intro" || n === "SystemIntro" || n === "Concept-Intro" ? !0 : t === "mcq" && (r == null ? void 0 : r.length) === 1;
78
79
  }, P = ({
@@ -250,11 +251,11 @@ export {
250
251
  V as getPuzzleWorksheetBackgroundColor,
251
252
  F as getQuestionBackgroundImage,
252
253
  G as getQuestionBorderColor,
253
- A as getQuestionMetadata,
254
+ v as getQuestionMetadata,
254
255
  Q as getWorksheetDimensions,
255
256
  D as getWorksheetHeaderLayout,
256
257
  X as isConceptIntroWidget,
257
- v as isOkayTypeQuestion,
258
+ A as isOkayTypeQuestion,
258
259
  J as isSATAssessmentNode,
259
260
  P as isTeacherInterventionNeeded,
260
261
  W as scrollToQuestion,
@@ -1 +1 @@
1
- {"version":3,"file":"worksheet-helpers.js","sources":["../../../../src/features/worksheet/worksheet/worksheet-helpers.ts"],"sourcesContent":["import Bulb2Icon from '../../../assets/line-icons/icons/bulb2';\nimport EditStarIcon from '../../../assets/line-icons/icons/edit-star';\nimport Edit2Icon from '../../../assets/line-icons/icons/edit2';\nimport PracticeIcon from '../../../assets/line-icons/icons/practice';\nimport QuestionLetterIcon from '../../../assets/line-icons/icons/question-letter';\nimport Star2Icon from '../../../assets/line-icons/icons/star2';\nimport { type NODE_TYPES } from '../../../types/models/worksheet';\nimport type { TColorNames, THueNames } from '../../ui/types';\nimport EVENTS from '../constants/events';\nimport {\n ACTION_BAR_HEIGHT,\n CLOZE_FORMULA_RESPONSE_LIMIT,\n QUESTION_WIDTH,\n SPLIT_QUESTION_WIDTH,\n} from './constants';\nimport type { TWorksheetQuestionPaperColor } from './worksheet-question/worksheet-question-types';\nimport {\n type ILearnosityItem,\n type ILearnosityQuestion,\n type ILearnosityQuestionResponse,\n type IWorksheetBehavior,\n type IWorksheetHeaderLayoutProps,\n type IWorksheetLayout,\n type IWorksheetQuestion,\n type IWorksheetResponse,\n type TInstructorStimulus,\n type TSectionName,\n} from './worksheet-types';\n\ninterface IGetInitialQuestionId {\n (params: {\n questions: IWorksheetQuestion[];\n initialQuestion: IWorksheetBehavior['initialQuestion'];\n lastUnlockedQuestionIndex: number;\n lastAttemptableQuestionIndex: number;\n initialResponseId?: string;\n initialItemIndex?: number;\n }): string;\n}\n\nconst getInitialQuestionId: IGetInitialQuestionId = ({\n questions,\n initialQuestion,\n initialResponseId,\n initialItemIndex,\n lastUnlockedQuestionIndex,\n lastAttemptableQuestionIndex,\n}) => {\n const unlockedQuestions = questions.slice(0, lastUnlockedQuestionIndex + 1);\n const lastUnlockedQuestion = questions[lastUnlockedQuestionIndex]!;\n const lastAttemptableQuestion = questions[lastAttemptableQuestionIndex]!;\n\n if (initialResponseId && unlockedQuestions.find(q => q.response_id === initialResponseId)) {\n return initialResponseId;\n }\n\n if (\n typeof initialItemIndex === 'number' &&\n initialItemIndex <= lastUnlockedQuestion.item_number\n ) {\n const question = questions.find(q => q.item_number === initialItemIndex);\n\n if (question?.response_id) {\n return question.response_id;\n }\n }\n\n if (initialQuestion === 'FIRST' && questions[0]?.response_id) {\n return questions[0].response_id;\n }\n\n if (initialQuestion === 'CURRENT') {\n return lastAttemptableQuestion.response_id;\n }\n\n if (questions[0]?.response_id) {\n return questions[0].response_id;\n }\n\n throw new Error('Initial question not found');\n};\n\ntype TQuestionMetadata = Pick<\n IWorksheetResponse,\n 'widgetReference' | 'itemReference' | 'itemPosition' | 'questionPosition' | 'isOkayTypeQuestion'\n>;\n\nfunction getQuestionMetadata(\n questions: IWorksheetQuestion[],\n questionId: string,\n): TQuestionMetadata;\nfunction getQuestionMetadata(question: IWorksheetQuestion): TQuestionMetadata;\nfunction getQuestionMetadata(\n questions: IWorksheetQuestion | IWorksheetQuestion[],\n questionId?: string,\n) {\n const question = Array.isArray(questions)\n ? questions.find(q => q.response_id === questionId)\n : questions;\n\n if (!question) {\n throw new Error(`Question with id ${questionId} not found`);\n }\n\n return {\n widgetReference: question.metadata.widget_reference,\n itemReference: question.item_reference,\n itemPosition: question.item_number,\n questionPosition: question.question_number,\n isOkayTypeQuestion: isOkayTypeQuestion(question),\n score: {\n max_score:\n question?.validation?.valid_response?.score ?? 0 * question.metadata.valid_response_count,\n },\n tags: {\n ...question.item_tags_map,\n instructor_stimulus: question.instructor_stimulus,\n },\n };\n}\n\ninterface IGetInitialResponses {\n (questions: IWorksheetQuestion[]): Record<string, IWorksheetResponse>;\n}\n\nconst getInitialResponses: IGetInitialResponses = questions => {\n return questions.reduce(\n (acc, question) => ({\n ...acc,\n [question.response_id]: getQuestionMetadata(questions, question.response_id),\n }),\n {},\n );\n};\n\ninterface IGetWorksheetDimensions {\n (\n items: ILearnosityItem[],\n layout: IWorksheetLayout,\n ): {\n questionsContainerWidth: number;\n maxQuestionWidth: number;\n actionbarHeight: number;\n };\n}\n\nconst getWorksheetDimensions: IGetWorksheetDimensions = (items, layout) => {\n const { actionBar } = layout;\n const isSingleColumn = !items.some(item =>\n item.questions.some(question => question.stimulus_review),\n );\n const actionbarHeight = actionBar === 'bottom' ? ACTION_BAR_HEIGHT : 0;\n\n return {\n questionsContainerWidth: isSingleColumn ? QUESTION_WIDTH : SPLIT_QUESTION_WIDTH,\n maxQuestionWidth: QUESTION_WIDTH,\n actionbarHeight,\n };\n};\n\ninterface IScrollToQuestion {\n (questionId: string, params?: { animation?: boolean; block?: 'start' | 'end' }): void;\n}\n\nconst scrollToQuestion: IScrollToQuestion = (\n questionId,\n { animation = false, block = 'start' } = {},\n) => {\n const $questionEl = document.querySelectorAll(`.widget-${questionId}`)[0];\n\n if ($questionEl) {\n $questionEl.scrollIntoView({\n block,\n behavior: animation ? 'smooth' : 'instant',\n });\n }\n};\n\ninterface IIsOkayTypeQuestion {\n (question: IWorksheetQuestion | ILearnosityQuestion): boolean;\n}\n\nconst isOkayTypeQuestion: IIsOkayTypeQuestion = question => {\n const { type, options, instructor_stimulus } = question;\n const itemType = 'item_type' in question ? question.item_type : undefined;\n\n if (\n itemType === 'overview' ||\n instructor_stimulus === 'Intro' ||\n instructor_stimulus === 'SystemIntro' ||\n instructor_stimulus === 'Concept-Intro'\n ) {\n return true;\n }\n\n return type === 'mcq' && options?.length === 1 ? true : false;\n};\n\ninterface IIsTeacherInterventionNeeded {\n (params: {\n attemptsAfterTeacherInterventionNeeded: number | undefined;\n attemptsHistory: IWorksheetResponse['attemptsHistory'];\n }): boolean;\n}\n\nconst isTeacherInterventionNeeded: IIsTeacherInterventionNeeded = ({\n attemptsAfterTeacherInterventionNeeded,\n attemptsHistory,\n}) => {\n if (\n attemptsAfterTeacherInterventionNeeded &&\n (attemptsHistory?.length ?? 0) >= attemptsAfterTeacherInterventionNeeded\n ) {\n const score = attemptsHistory?.slice(-1)[0]?.score;\n\n if (score && score.score === score.max_score) {\n return false;\n }\n\n return true;\n }\n\n return false;\n};\n\nconst setMathJaxConfigInWindow = (\n logger: (eventName: string, data?: Record<string, unknown>) => void,\n) => {\n window.MathJax = {\n options: {\n enableMenu: false,\n ignoreHtmlClass: 'lrn_noMath',\n compileError: function (doc, math, err) {\n logger(EVENTS.MATHJAX_COMPILE_ERROR);\n doc.compileError(math, err);\n },\n typesetError: function (doc, math, err) {\n logger(EVENTS.MATHJAX_TYPESET_ERROR);\n doc.typesetError(math, err);\n // throw new Error('typesetError');\n },\n },\n tex: {\n inlineMath: [\n ['\\\\(', '\\\\)'],\n ['$$', '$$'],\n ],\n displayMath: [['\\\\[', '\\\\]']],\n macros: {\n abs: ['{|#1|}', 1],\n degree: ['°'],\n longdiv: ['{\\\\enclose{longdiv}{#1}}', 1],\n atomic: ['{_{#1}^{#2}}', 2],\n polyatomic: ['{_{#2}{}^{#1}}', 2],\n circledot: ['{\\\\odot}'],\n parallelogram: ['\\\\unicode{x25B1}'],\n ngtr: ['\\\\unicode{x226F}'],\n nless: ['\\\\unicode{x226E}'],\n MathQuillVarField: ['#1', 1],\n overarc: ['{\\\\overparen{#1}}', 1],\n },\n formatError: (jax, err) => {\n logger(EVENTS.MATHJAX_FORMAT_ERROR, {\n id: err.id,\n message: err.message,\n });\n jax.formatError(err);\n },\n },\n chtml: {\n minScale: 1,\n matchFontHeight: false,\n },\n };\n};\n\ninterface IGetPaperColorByQuestion {\n (question: IWorksheetQuestion): TWorksheetQuestionPaperColor;\n}\n\nconst getPaperColorByQuestion: IGetPaperColorByQuestion = question => {\n const { item_type, instructor_stimulus } = question;\n const lowerCaseInstructorStimulus = instructor_stimulus?.toLowerCase();\n\n switch (item_type) {\n case 'overview':\n case 'learning':\n return 'blue';\n case 'learning-we-do':\n case 'learning-your-turn':\n case 'learning-explore':\n if (\n lowerCaseInstructorStimulus === 'instruction' ||\n lowerCaseInstructorStimulus === 'intro' ||\n lowerCaseInstructorStimulus === 'concept-intro'\n ) {\n return 'blue';\n }\n\n if (lowerCaseInstructorStimulus === 'task') {\n return 'green';\n }\n\n return 'yellow';\n case 'practice-basic':\n case 'practice-regular':\n return 'yellow';\n case 'exit-ticket':\n return 'purple';\n case 'advanced-practice':\n return 'orange';\n default:\n if (lowerCaseInstructorStimulus === 'learn') return 'blue';\n\n if (lowerCaseInstructorStimulus === 'try' || lowerCaseInstructorStimulus === 'apply')\n return 'green';\n\n return 'yellow';\n }\n};\n\nconst getQuestionBackgroundImage = (paperColor: TWorksheetQuestionPaperColor) => {\n return `https://cuemath-intel.s3.ap-southeast-1.amazonaws.com/media/math-canvas/paper-${paperColor}.png`;\n};\n\nconst getQuestionBorderColor = (\n paperColor: TWorksheetQuestionPaperColor,\n isActive?: boolean,\n): TColorNames => {\n if (!isActive) {\n return 'GREY_3';\n }\n\n switch (paperColor) {\n case 'orange':\n case 'white':\n return 'ORANGE_2';\n case 'blue':\n return 'BLUE_2';\n case 'green':\n return 'GREEN_2';\n case 'yellow':\n return 'YELLOW_2';\n case 'purple':\n return 'PURPLE_2';\n default:\n return 'GREY_3';\n }\n};\n\nconst getNavigationSectionBackgroundColor = (sectionName?: TSectionName): TColorNames => {\n switch (sectionName) {\n case 'learning':\n return 'BLUE_1';\n case 'practice':\n case 'practice-basic':\n case 'practice-regular':\n return 'YELLOW_1';\n case 'exit-ticket':\n return 'PURPLE_1';\n case 'advanced':\n return 'ORANGE_1';\n default:\n return 'YELLOW_1';\n }\n};\n\nconst getNavigationSectionName = (sectionName?: TSectionName): string => {\n switch (sectionName) {\n case 'learning':\n return 'Learning';\n case 'practice':\n return 'Practice';\n case 'practice-basic':\n return 'Basic practice';\n case 'practice-regular':\n return 'Regular practice';\n case 'exit-ticket':\n return 'Mini quiz';\n case 'advanced':\n return 'Advanced work';\n default:\n return '';\n }\n};\n\nconst getNavigationSectionIcon = (sectionName?: TSectionName) => {\n switch (sectionName) {\n case 'learning':\n return Bulb2Icon;\n case 'practice':\n return PracticeIcon;\n case 'practice-basic':\n return Edit2Icon;\n case 'practice-regular':\n return EditStarIcon;\n case 'exit-ticket':\n return QuestionLetterIcon;\n case 'advanced':\n return Star2Icon;\n default:\n return Bulb2Icon;\n }\n};\n\nconst isSATAssessmentNode = (nodeType: NODE_TYPES) =>\n nodeType === 'SAT_ENGLISH_ASSESSMENT' || nodeType === 'SAT_MATH_ASSESSMENT';\n\nconst checkIsClozeFormulaResponseInvalid = (response: ILearnosityQuestionResponse) => {\n if (Array.isArray(response.value)) {\n const isInvalid = response.value.some(\n item => typeof item === 'string' && item.length > CLOZE_FORMULA_RESPONSE_LIMIT,\n );\n\n return isInvalid;\n }\n\n return false;\n};\n\nconst getWorksheetHeaderLayout: IWorksheetHeaderLayoutProps = ({\n isPuzzleWorksheet,\n isTestWorksheet,\n imageHue = 'BLUE',\n}) => {\n if (isPuzzleWorksheet) {\n return {\n bgColor: `${imageHue}_3`,\n borderColor: `${imageHue}_4`,\n textColor: 'BLACK_T_87',\n };\n }\n\n if (isTestWorksheet) {\n return {\n bgColor: 'WHITE_3',\n borderColor: 'WHITE_4',\n textColor: 'BLACK_T_87',\n };\n }\n\n return {\n bgColor: 'BLACK',\n borderColor: 'BLACK_4',\n textColor: 'WHITE',\n };\n};\n\ninterface IGetPuzzleWorksheetBackgroundColor {\n (imageHue?: THueNames): TColorNames;\n}\n\nconst getPuzzleWorksheetBackgroundColor: IGetPuzzleWorksheetBackgroundColor = imageHue => {\n if (!imageHue) return 'BLUE_1';\n\n return `${imageHue}_1`;\n};\n\nconst isConceptIntroWidget = (instructorStimulus?: TInstructorStimulus) => {\n if (!instructorStimulus) {\n return false;\n }\n\n const lowerCaseInstructorStimulus = instructorStimulus.toLowerCase();\n\n return lowerCaseInstructorStimulus === 'intro' || lowerCaseInstructorStimulus === 'concept-intro';\n};\n\nexport {\n checkIsClozeFormulaResponseInvalid,\n getInitialQuestionId,\n getInitialResponses,\n getNavigationSectionBackgroundColor,\n getNavigationSectionIcon,\n getNavigationSectionName,\n getPaperColorByQuestion,\n getPuzzleWorksheetBackgroundColor,\n getQuestionBackgroundImage,\n getQuestionBorderColor,\n getQuestionMetadata,\n getWorksheetDimensions,\n getWorksheetHeaderLayout,\n isConceptIntroWidget,\n isOkayTypeQuestion,\n isSATAssessmentNode,\n isTeacherInterventionNeeded,\n scrollToQuestion,\n setMathJaxConfigInWindow,\n};\n"],"names":["getInitialQuestionId","questions","initialQuestion","initialResponseId","initialItemIndex","lastUnlockedQuestionIndex","lastAttemptableQuestionIndex","unlockedQuestions","lastUnlockedQuestion","lastAttemptableQuestion","q","question","_a","_b","getQuestionMetadata","questionId","isOkayTypeQuestion","getInitialResponses","acc","getWorksheetDimensions","items","layout","actionBar","item","QUESTION_WIDTH","SPLIT_QUESTION_WIDTH","ACTION_BAR_HEIGHT","scrollToQuestion","animation","block","$questionEl","type","options","instructor_stimulus","isTeacherInterventionNeeded","attemptsAfterTeacherInterventionNeeded","attemptsHistory","score","setMathJaxConfigInWindow","logger","doc","math","err","EVENTS","jax","getPaperColorByQuestion","item_type","lowerCaseInstructorStimulus","getQuestionBackgroundImage","paperColor","getQuestionBorderColor","isActive","getNavigationSectionBackgroundColor","sectionName","getNavigationSectionName","getNavigationSectionIcon","Bulb2Icon","PracticeIcon","Edit2Icon","EditStarIcon","QuestionLetterIcon","Star2Icon","isSATAssessmentNode","nodeType","checkIsClozeFormulaResponseInvalid","response","CLOZE_FORMULA_RESPONSE_LIMIT","getWorksheetHeaderLayout","isPuzzleWorksheet","isTestWorksheet","imageHue","getPuzzleWorksheetBackgroundColor","isConceptIntroWidget","instructorStimulus"],"mappings":";;;;;;;;AAwCA,MAAMA,IAA8C,CAAC;AAAA,EACnD,WAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,2BAAAC;AAAA,EACA,8BAAAC;AACF,MAAM;;AACJ,QAAMC,IAAoBN,EAAU,MAAM,GAAGI,IAA4B,CAAC,GACpEG,IAAuBP,EAAUI,CAAyB,GAC1DI,IAA0BR,EAAUK,CAA4B;AAEtE,MAAIH,KAAqBI,EAAkB,KAAK,OAAKG,EAAE,gBAAgBP,CAAiB;AAC/E,WAAAA;AAGT,MACE,OAAOC,KAAqB,YAC5BA,KAAoBI,EAAqB,aACzC;AACA,UAAMG,IAAWV,EAAU,KAAK,CAAKS,MAAAA,EAAE,gBA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aAAAC;AAAA,IACT,KAAK;AACI,aAAAC;AAAA,IACT,KAAK;AACI,aAAAC;AAAA,IACT;AACS,aAAAL;AAAA,EACX;AACF,GAEMM,IAAsB,CAACC,MAC3BA,MAAa,4BAA4BA,MAAa,uBAElDC,IAAqC,CAACC,MACtC,MAAM,QAAQA,EAAS,KAAK,IACZA,EAAS,MAAM;AAAA,EAC/B,CAAQ1C,MAAA,OAAOA,KAAS,YAAYA,EAAK,SAAS2C;AAAA,IAM/C,IAGHC,IAAwD,CAAC;AAAA,EAC7D,mBAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,UAAAC,IAAW;AACb,MACMF,IACK;AAAA,EACL,SAAS,GAAGE,CAAQ;AAAA,EACpB,aAAa,GAAGA,CAAQ;AAAA,EACxB,WAAW;AAAA,IAIXD,IACK;AAAA,EACL,SAAS;AAAA,EACT,aAAa;AAAA,EACb,WAAW;AAAA,IAIR;AAAA,EACL,SAAS;AAAA,EACT,aAAa;AAAA,EACb,WAAW;AAAA,GAQTE,IAAwE,CAAYD,MACnFA,IAEE,GAAGA,CAAQ,OAFI,UAKlBE,IAAuB,CAACC,MAA6C;AACzE,MAAI,CAACA;AACI,WAAA;AAGH,QAAA1B,IAA8B0B,EAAmB;AAEhD,SAAA1B,MAAgC,WAAWA,MAAgC;AACpF;"}
1
+ {"version":3,"file":"worksheet-helpers.js","sources":["../../../../src/features/worksheet/worksheet/worksheet-helpers.ts"],"sourcesContent":["import Bulb2Icon from '../../../assets/line-icons/icons/bulb2';\nimport EditStarIcon from '../../../assets/line-icons/icons/edit-star';\nimport Edit2Icon from '../../../assets/line-icons/icons/edit2';\nimport PracticeIcon from '../../../assets/line-icons/icons/practice';\nimport QuestionLetterIcon from '../../../assets/line-icons/icons/question-letter';\nimport Star2Icon from '../../../assets/line-icons/icons/star2';\nimport { type NODE_TYPES } from '../../../types/models/worksheet';\nimport type { TColorNames, THueNames } from '../../ui/types';\nimport EVENTS from '../constants/events';\nimport {\n ACTION_BAR_HEIGHT,\n CLOZE_FORMULA_RESPONSE_LIMIT,\n QUESTION_WIDTH,\n SPLIT_QUESTION_WIDTH,\n} from './constants';\nimport type { TWorksheetQuestionPaperColor } from './worksheet-question/worksheet-question-types';\nimport {\n type ILearnosityItem,\n type ILearnosityQuestion,\n type ILearnosityQuestionResponse,\n type IWorksheetBehavior,\n type IWorksheetHeaderLayoutProps,\n type IWorksheetLayout,\n type IWorksheetQuestion,\n type IWorksheetResponse,\n type TInstructorStimulus,\n type TSectionName,\n} from './worksheet-types';\n\ninterface IGetInitialQuestionId {\n (params: {\n questions: IWorksheetQuestion[];\n initialQuestion: IWorksheetBehavior['initialQuestion'];\n lastUnlockedQuestionIndex: number;\n lastAttemptableQuestionIndex: number;\n initialResponseId?: string;\n initialItemIndex?: number;\n }): string;\n}\n\nconst getInitialQuestionId: IGetInitialQuestionId = ({\n questions,\n initialQuestion,\n initialResponseId,\n initialItemIndex,\n lastUnlockedQuestionIndex,\n lastAttemptableQuestionIndex,\n}) => {\n const unlockedQuestions = questions.slice(0, lastUnlockedQuestionIndex + 1);\n const lastUnlockedQuestion = questions[lastUnlockedQuestionIndex]!;\n const lastAttemptableQuestion = questions[lastAttemptableQuestionIndex]!;\n\n if (initialResponseId && unlockedQuestions.find(q => q.response_id === initialResponseId)) {\n return initialResponseId;\n }\n\n if (\n typeof initialItemIndex === 'number' &&\n initialItemIndex <= lastUnlockedQuestion.item_number\n ) {\n const question = questions.find(q => q.item_number === initialItemIndex);\n\n if (question?.response_id) {\n return question.response_id;\n }\n }\n\n if (initialQuestion === 'FIRST' && questions[0]?.response_id) {\n return questions[0].response_id;\n }\n\n if (initialQuestion === 'CURRENT') {\n return lastAttemptableQuestion.response_id;\n }\n\n if (questions[0]?.response_id) {\n return questions[0].response_id;\n }\n\n throw new Error('Initial question not found');\n};\n\ntype TQuestionMetadata = Pick<\n IWorksheetResponse,\n | 'widgetReference'\n | 'itemReference'\n | 'itemPosition'\n | 'questionPosition'\n | 'isOkayTypeQuestion'\n | 'score'\n | 'tags'\n> & {\n distractor_rationale_response_level?: IWorksheetResponse['distractor_rationale_response_level'];\n};\n\nfunction getQuestionMetadata(\n questions: IWorksheetQuestion[],\n questionId: string,\n): TQuestionMetadata;\nfunction getQuestionMetadata(question: IWorksheetQuestion): TQuestionMetadata;\nfunction getQuestionMetadata(\n questions: IWorksheetQuestion | IWorksheetQuestion[],\n questionId?: string,\n): TQuestionMetadata {\n const question = Array.isArray(questions)\n ? questions.find(q => q.response_id === questionId)\n : questions;\n\n if (!question) {\n throw new Error(`Question with id ${questionId} not found`);\n }\n\n return {\n widgetReference: question.metadata.widget_reference,\n itemReference: question.item_reference,\n itemPosition: question.item_number,\n questionPosition: question.question_number,\n isOkayTypeQuestion: isOkayTypeQuestion(question),\n score: {\n max_score:\n question?.validation?.valid_response?.score ?? 0 * question.metadata.valid_response_count,\n },\n tags: {\n ...question.item_tags_map,\n instructor_stimulus: question.instructor_stimulus ?? '',\n },\n distractor_rationale_response_level: question.metadata.distractor_rationale_response_level,\n };\n}\n\ninterface IGetInitialResponses {\n (questions: IWorksheetQuestion[]): Record<string, IWorksheetResponse>;\n}\n\nconst getInitialResponses: IGetInitialResponses = questions => {\n return questions.reduce(\n (acc, question) => ({\n ...acc,\n [question.response_id]: getQuestionMetadata(questions, question.response_id),\n }),\n {},\n );\n};\n\ninterface IGetWorksheetDimensions {\n (\n items: ILearnosityItem[],\n layout: IWorksheetLayout,\n ): {\n questionsContainerWidth: number;\n maxQuestionWidth: number;\n actionbarHeight: number;\n };\n}\n\nconst getWorksheetDimensions: IGetWorksheetDimensions = (items, layout) => {\n const { actionBar } = layout;\n const isSingleColumn = !items.some(item =>\n item.questions.some(question => question.stimulus_review),\n );\n const actionbarHeight = actionBar === 'bottom' ? ACTION_BAR_HEIGHT : 0;\n\n return {\n questionsContainerWidth: isSingleColumn ? QUESTION_WIDTH : SPLIT_QUESTION_WIDTH,\n maxQuestionWidth: QUESTION_WIDTH,\n actionbarHeight,\n };\n};\n\ninterface IScrollToQuestion {\n (questionId: string, params?: { animation?: boolean; block?: 'start' | 'end' }): void;\n}\n\nconst scrollToQuestion: IScrollToQuestion = (\n questionId,\n { animation = false, block = 'start' } = {},\n) => {\n const $questionEl = document.querySelectorAll(`.widget-${questionId}`)[0];\n\n if ($questionEl) {\n $questionEl.scrollIntoView({\n block,\n behavior: animation ? 'smooth' : 'instant',\n });\n }\n};\n\ninterface IIsOkayTypeQuestion {\n (question: IWorksheetQuestion | ILearnosityQuestion): boolean;\n}\n\nconst isOkayTypeQuestion: IIsOkayTypeQuestion = question => {\n const { type, options, instructor_stimulus } = question;\n const itemType = 'item_type' in question ? question.item_type : undefined;\n\n if (\n itemType === 'overview' ||\n instructor_stimulus === 'Intro' ||\n instructor_stimulus === 'SystemIntro' ||\n instructor_stimulus === 'Concept-Intro'\n ) {\n return true;\n }\n\n return type === 'mcq' && options?.length === 1 ? true : false;\n};\n\ninterface IIsTeacherInterventionNeeded {\n (params: {\n attemptsAfterTeacherInterventionNeeded: number | undefined;\n attemptsHistory: IWorksheetResponse['attemptsHistory'];\n }): boolean;\n}\n\nconst isTeacherInterventionNeeded: IIsTeacherInterventionNeeded = ({\n attemptsAfterTeacherInterventionNeeded,\n attemptsHistory,\n}) => {\n if (\n attemptsAfterTeacherInterventionNeeded &&\n (attemptsHistory?.length ?? 0) >= attemptsAfterTeacherInterventionNeeded\n ) {\n const score = attemptsHistory?.slice(-1)[0]?.score;\n\n if (score && score.score === score.max_score) {\n return false;\n }\n\n return true;\n }\n\n return false;\n};\n\nconst setMathJaxConfigInWindow = (\n logger: (eventName: string, data?: Record<string, unknown>) => void,\n) => {\n window.MathJax = {\n options: {\n enableMenu: false,\n ignoreHtmlClass: 'lrn_noMath',\n compileError: function (doc, math, err) {\n logger(EVENTS.MATHJAX_COMPILE_ERROR);\n doc.compileError(math, err);\n },\n typesetError: function (doc, math, err) {\n logger(EVENTS.MATHJAX_TYPESET_ERROR);\n doc.typesetError(math, err);\n // throw new Error('typesetError');\n },\n },\n tex: {\n inlineMath: [\n ['\\\\(', '\\\\)'],\n ['$$', '$$'],\n ],\n displayMath: [['\\\\[', '\\\\]']],\n macros: {\n abs: ['{|#1|}', 1],\n degree: ['°'],\n longdiv: ['{\\\\enclose{longdiv}{#1}}', 1],\n atomic: ['{_{#1}^{#2}}', 2],\n polyatomic: ['{_{#2}{}^{#1}}', 2],\n circledot: ['{\\\\odot}'],\n parallelogram: ['\\\\unicode{x25B1}'],\n ngtr: ['\\\\unicode{x226F}'],\n nless: ['\\\\unicode{x226E}'],\n MathQuillVarField: ['#1', 1],\n overarc: ['{\\\\overparen{#1}}', 1],\n },\n formatError: (jax, err) => {\n logger(EVENTS.MATHJAX_FORMAT_ERROR, {\n id: err.id,\n message: err.message,\n });\n jax.formatError(err);\n },\n },\n chtml: {\n minScale: 1,\n matchFontHeight: false,\n },\n };\n};\n\ninterface IGetPaperColorByQuestion {\n (question: IWorksheetQuestion): TWorksheetQuestionPaperColor;\n}\n\nconst getPaperColorByQuestion: IGetPaperColorByQuestion = question => {\n const { item_type, instructor_stimulus } = question;\n const lowerCaseInstructorStimulus = instructor_stimulus?.toLowerCase();\n\n switch (item_type) {\n case 'overview':\n case 'learning':\n return 'blue';\n case 'learning-we-do':\n case 'learning-your-turn':\n case 'learning-explore':\n if (\n lowerCaseInstructorStimulus === 'instruction' ||\n lowerCaseInstructorStimulus === 'intro' ||\n lowerCaseInstructorStimulus === 'concept-intro'\n ) {\n return 'blue';\n }\n\n if (lowerCaseInstructorStimulus === 'task') {\n return 'green';\n }\n\n return 'yellow';\n case 'practice-basic':\n case 'practice-regular':\n return 'yellow';\n case 'exit-ticket':\n return 'purple';\n case 'advanced-practice':\n return 'orange';\n default:\n if (lowerCaseInstructorStimulus === 'learn') return 'blue';\n\n if (lowerCaseInstructorStimulus === 'try' || lowerCaseInstructorStimulus === 'apply')\n return 'green';\n\n return 'yellow';\n }\n};\n\nconst getQuestionBackgroundImage = (paperColor: TWorksheetQuestionPaperColor) => {\n return `https://cuemath-intel.s3.ap-southeast-1.amazonaws.com/media/math-canvas/paper-${paperColor}.png`;\n};\n\nconst getQuestionBorderColor = (\n paperColor: TWorksheetQuestionPaperColor,\n isActive?: boolean,\n): TColorNames => {\n if (!isActive) {\n return 'GREY_3';\n }\n\n switch (paperColor) {\n case 'orange':\n case 'white':\n return 'ORANGE_2';\n case 'blue':\n return 'BLUE_2';\n case 'green':\n return 'GREEN_2';\n case 'yellow':\n return 'YELLOW_2';\n case 'purple':\n return 'PURPLE_2';\n default:\n return 'GREY_3';\n }\n};\n\nconst getNavigationSectionBackgroundColor = (sectionName?: TSectionName): TColorNames => {\n switch (sectionName) {\n case 'learning':\n return 'BLUE_1';\n case 'practice':\n case 'practice-basic':\n case 'practice-regular':\n return 'YELLOW_1';\n case 'exit-ticket':\n return 'PURPLE_1';\n case 'advanced':\n return 'ORANGE_1';\n default:\n return 'YELLOW_1';\n }\n};\n\nconst getNavigationSectionName = (sectionName?: TSectionName): string => {\n switch (sectionName) {\n case 'learning':\n return 'Learning';\n case 'practice':\n return 'Practice';\n case 'practice-basic':\n return 'Basic practice';\n case 'practice-regular':\n return 'Regular practice';\n case 'exit-ticket':\n return 'Mini quiz';\n case 'advanced':\n return 'Advanced work';\n default:\n return '';\n }\n};\n\nconst getNavigationSectionIcon = (sectionName?: TSectionName) => {\n switch (sectionName) {\n case 'learning':\n return Bulb2Icon;\n case 'practice':\n return PracticeIcon;\n case 'practice-basic':\n return Edit2Icon;\n case 'practice-regular':\n return EditStarIcon;\n case 'exit-ticket':\n return QuestionLetterIcon;\n case 'advanced':\n return Star2Icon;\n default:\n return Bulb2Icon;\n }\n};\n\nconst isSATAssessmentNode = (nodeType: NODE_TYPES) =>\n nodeType === 'SAT_ENGLISH_ASSESSMENT' || nodeType === 'SAT_MATH_ASSESSMENT';\n\nconst checkIsClozeFormulaResponseInvalid = (response: ILearnosityQuestionResponse) => {\n if (Array.isArray(response.value)) {\n const isInvalid = response.value.some(\n item => typeof item === 'string' && item.length > CLOZE_FORMULA_RESPONSE_LIMIT,\n );\n\n return isInvalid;\n }\n\n return false;\n};\n\nconst getWorksheetHeaderLayout: IWorksheetHeaderLayoutProps = ({\n isPuzzleWorksheet,\n isTestWorksheet,\n imageHue = 'BLUE',\n}) => {\n if (isPuzzleWorksheet) {\n return {\n bgColor: `${imageHue}_3`,\n borderColor: `${imageHue}_4`,\n textColor: 'BLACK_T_87',\n };\n }\n\n if (isTestWorksheet) {\n return {\n bgColor: 'WHITE_3',\n borderColor: 'WHITE_4',\n textColor: 'BLACK_T_87',\n };\n }\n\n return {\n bgColor: 'BLACK',\n borderColor: 'BLACK_4',\n textColor: 'WHITE',\n };\n};\n\ninterface IGetPuzzleWorksheetBackgroundColor {\n (imageHue?: THueNames): TColorNames;\n}\n\nconst getPuzzleWorksheetBackgroundColor: IGetPuzzleWorksheetBackgroundColor = imageHue => {\n if (!imageHue) return 'BLUE_1';\n\n return `${imageHue}_1`;\n};\n\nconst isConceptIntroWidget = (instructorStimulus?: TInstructorStimulus) => {\n if (!instructorStimulus) {\n return false;\n }\n\n const lowerCaseInstructorStimulus = instructorStimulus.toLowerCase();\n\n return lowerCaseInstructorStimulus === 'intro' || lowerCaseInstructorStimulus === 'concept-intro';\n};\n\nexport {\n checkIsClozeFormulaResponseInvalid,\n getInitialQuestionId,\n getInitialResponses,\n getNavigationSectionBackgroundColor,\n getNavigationSectionIcon,\n getNavigationSectionName,\n getPaperColorByQuestion,\n getPuzzleWorksheetBackgroundColor,\n getQuestionBackgroundImage,\n getQuestionBorderColor,\n getQuestionMetadata,\n getWorksheetDimensions,\n getWorksheetHeaderLayout,\n isConceptIntroWidget,\n isOkayTypeQuestion,\n isSATAssessmentNode,\n isTeacherInterventionNeeded,\n scrollToQuestion,\n setMathJaxConfigInWindow,\n};\n"],"names":["getInitialQuestionId","questions","initialQuestion","initialResponseId","initialItemIndex","lastUnlockedQuestionIndex","lastAttemptableQuestionIndex","unlockedQuestions","lastUnlockedQuestion","lastAttemptableQuestion","q","question","_a","_b","getQuestionMetadata","questionId","isOkayTypeQuestion","getInitialResponses","acc","getWorksheetDimensions","items","layout","actionBar","item","QUESTION_WIDTH","SPLIT_QUESTION_WIDTH","ACTION_BAR_HEIGHT","scrollToQuestion","animation","block","$questionEl","type","options","instructor_stimulus","isTeacherInterventionNeeded","attemptsAfterTeacherInterventionNeeded","attemptsHistory","score","setMathJaxConfigInWindow","logger","doc","math","err","EVENTS","jax","getPaperColorByQuestion","item_type","lowerCaseInstructorStimulus","getQuestionBackgroundImage","paperColor","getQuestionBorderColor","isActive","getNavigationSectionBackgroundColor","sectionName","getNavigationSectionName","getNavigationSectionIcon","Bulb2Icon","PracticeIcon","Edit2Icon","EditStarIcon","QuestionLetterIcon","Star2Icon","isSATAssessmentNode","nodeType","checkIsClozeFormulaResponseInvalid","response","CLOZE_FORMULA_RESPONSE_LIMIT","getWorksheetHeaderLayout","isPuzzleWorksheet","isTestWorksheet","imageHue","getPuzzleWorksheetBackgroundColor","isConceptIntroWidget","instructorStimulus"],"mappings":";;;;;;;;AAwCA,MAAMA,IAA8C,CAAC;AAAA,EACnD,WAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,2BAAAC;AAAA,EACA,8BAAAC;AACF,MAAM;;AACJ,QAAMC,IAAoBN,EAAU,MAAM,GAAGI,IAA4B,CAAC,GACpEG,IAAuBP,EAAUI,CAAyB,GAC1DI,IAA0BR,EAAUK,CAA4B;AAEtE,MAAIH,KAAqBI,EAAkB,KAAK,OAAKG,EAAE,gBAAgBP,CAAiB;AAC/E,WAAAA;AAGT,MACE,OAAOC,KAAqB,YAC5BA,KAAoBI,EAAqB,aACzC;AACA,UAAMG,IAAWV,EAAU,KAAK,CAAKS,MAAAA,EAAE,gBAAgBN,CAAgB;AAEvE,QAAIO,KAAA,QAAAA,EAAU;AACZ,aAAOA,EAAS;AAAA,EAEpB;AAEA,MAAIT,MAAoB,aAAWU,IAAAX,EA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T;AACS,aAAAL;AAAA,EACX;AACF,GAEMM,IAAsB,CAACC,MAC3BA,MAAa,4BAA4BA,MAAa,uBAElDC,IAAqC,CAACC,MACtC,MAAM,QAAQA,EAAS,KAAK,IACZA,EAAS,MAAM;AAAA,EAC/B,CAAQ1C,MAAA,OAAOA,KAAS,YAAYA,EAAK,SAAS2C;AAAA,IAM/C,IAGHC,IAAwD,CAAC;AAAA,EAC7D,mBAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,UAAAC,IAAW;AACb,MACMF,IACK;AAAA,EACL,SAAS,GAAGE,CAAQ;AAAA,EACpB,aAAa,GAAGA,CAAQ;AAAA,EACxB,WAAW;AAAA,IAIXD,IACK;AAAA,EACL,SAAS;AAAA,EACT,aAAa;AAAA,EACb,WAAW;AAAA,IAIR;AAAA,EACL,SAAS;AAAA,EACT,aAAa;AAAA,EACb,WAAW;AAAA,GAQTE,IAAwE,CAAYD,MACnFA,IAEE,GAAGA,CAAQ,OAFI,UAKlBE,IAAuB,CAACC,MAA6C;AACzE,MAAI,CAACA;AACI,WAAA;AAGH,QAAA1B,IAA8B0B,EAAmB;AAEhD,SAAA1B,MAAgC,WAAWA,MAAgC;AACpF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"worksheet-types.js","sources":["../../../../src/features/worksheet/worksheet/worksheet-types.ts"],"sourcesContent":["import type { MutableRefObject, ReactElement, ReactNode } from 'react';\n\nimport type { EWorksheetActivity, TNodeTypes } from '../../../types/models/worksheet';\nimport type { IActionData, TPublish, TSubscribe } from '../../cue-canvas/types/cue-canvas';\nimport type { TPublishMouseMove, TSubscribeMouseMove } from '../../pointer-sync/pointer-types';\nimport type { TColorNames, THueNames, TUserTypes } from '../../ui/types';\nimport { type IFile } from '../../hooks/use-s3-helper/use-s3-helper';\nimport type { TWorksheetBlocker } from './worksheet-blocker/worksheet-blocker-types';\n\nexport enum QUESTION_TAGS {\n TRIAL_TOPIC = 'trial-topic',\n QUESTION_CODE = 'question code',\n}\n\nexport enum QUESTIONS_RATING {\n E = 3,\n S = 2, // Just right\n H = 1,\n}\n\nexport interface ILearnosityError {\n code: number;\n consumerKey: string;\n detail: string;\n errorUI: string;\n msg: string;\n}\n\ninterface ILearnosityQuestionMetadata {\n widget_reference: string;\n sheet_reference: string;\n acknowledgements?: string;\n sample_answer?: string;\n hints?: string[];\n solution?: string[];\n teacher_tips?: string[];\n valid_response_count: number;\n source: {\n organisation_id: number;\n };\n}\n\nexport type TInstructorStimulus =\n | 'SystemIntro' // lesson v3\n | 'Intro' // lesson v3\n | 'Concept-Intro' // lesson v3\n | 'Instruction' // lesson v3\n | 'Task' // lesson v3\n | 'Try' // trial v3\n | 'Learn' // trial v3\n | 'Apply'; // trial v3\n\nexport type TItemType =\n | 'overview'\n | 'learning'\n | 'learning-we-do'\n | 'learning-your-turn'\n | 'learning-explore'\n | 'practice'\n | 'practice-basic'\n | 'practice-basic-optional'\n | 'practice-regular'\n | 'practice-regular-optional'\n | 'exit-ticket'\n | 'advanced-we-do'\n | 'advanced-your-turn'\n | 'advanced-explore'\n | 'advanced-practice';\n\nexport type TSectionName =\n | 'overview'\n | 'learning'\n | 'practice'\n | 'practice-basic'\n | 'practice-regular'\n | 'exit-ticket'\n | 'advanced';\n\ninterface IQuestionValidResponse {\n score: number;\n value: unknown[];\n}\n\nexport interface ISheetNudgeBannerInfo {\n bannerBackgroundColor: TColorNames;\n label: string;\n}\n\nexport interface ILearnosityQuestion {\n response_id: string;\n instructor_stimulus?: TInstructorStimulus;\n metadata: ILearnosityQuestionMetadata;\n instant_feedback?: boolean;\n math_renderer?: string;\n template?: string;\n tokenization?: string;\n numberPad?: string[];\n symbols?: unknown[];\n response_container?: Record<string, unknown>;\n ui_style?: Record<string, unknown>;\n shuffle_options?: boolean;\n // for custom type question validation is undefined.\n validation?: {\n scoring_type?: string;\n unscored?: boolean;\n valid_response?: IQuestionValidResponse;\n alt_responses?: IQuestionValidResponse[];\n penalty?: number;\n min_score_if_attempted?: number;\n };\n is_math?: boolean;\n labels?: Record<string, unknown>;\n line?: Record<string, unknown>;\n points?: string[];\n snap_to_ticks?: boolean;\n ticks?: Record<string, unknown>;\n max_length?: number;\n type:\n | 'hotspot'\n | 'tokenhighlight'\n | 'numberline'\n | 'clozeassociation'\n | 'clozetext'\n | 'association'\n | 'classification'\n | 'clozedropdown'\n | 'clozeformula'\n | 'mcq'\n | 'choicematrix'\n | 'plaintext'\n | 'drawing';\n case_sensitive?: boolean;\n show_copy?: boolean;\n show_cut?: boolean;\n show_paste?: boolean;\n spellcheck?: boolean;\n stimulus?: string;\n stimulus_review?: string;\n stimulus_list?: string[];\n image?: Record<string, unknown>;\n areas?: unknown[];\n area_attributes?: Record<string, unknown>;\n possible_responses?: string[][] | string[];\n duplicate_responses?: boolean;\n response_containers?: unknown[];\n options?: Record<string, unknown>[] | string[];\n feedback_attempts?: number;\n stems?: string[];\n multiple_responses?: boolean;\n}\n\nexport interface ILearnosityItem {\n reference: string;\n questions: ILearnosityQuestion[];\n source: Record<string, unknown>;\n content: string;\n metadata: Record<string, unknown> | unknown[];\n workflow: unknown[];\n response_ids: string[];\n feature_ids: unknown[];\n features: unknown[];\n itemType?: TItemType;\n tags?: string[];\n}\n\nexport interface IWorksheetQuestion extends ILearnosityQuestion {\n item_reference: string;\n item_type?: TItemType;\n section_name?: TSectionName;\n is_optional?: boolean;\n /**\n * If true, the question is not a question, but a content only item\n * e.g. Intro, Overview, Instruction etc.\n */\n is_non_question?: boolean;\n concept_intro_stimulus?: string; // Content for concept intro widget\n item_tags: string[];\n item_tags_map: Record<string, string>;\n item_number: number;\n item_display_number: number;\n question_number: number;\n total_questions: number;\n /**\n * if true, scribbler button will be shown on the question\n */\n can_scribble: boolean; // If true, the question can be scribbled on\n}\n\nexport interface ILearnosityQuestionScore {\n score?: number | null;\n max_score: number;\n unscored?: boolean;\n}\n\nexport interface ILearnosityQuestionResponse {\n value: unknown;\n responses?: unknown;\n type: unknown;\n updatedFormat?: boolean;\n wordCount?: number;\n apiVersion: string;\n revision: number;\n feedbackAttemptsCount?: number;\n}\n\ninterface IAttempt {\n response: ILearnosityQuestionResponse;\n score: ILearnosityQuestionScore;\n}\n\ninterface ITeacherReview {\n reviewComment?: string;\n images?: string[];\n}\nexport interface IWorksheetResponse {\n widgetReference: string;\n itemReference: string;\n itemPosition: number; // 0 based\n questionPosition: number; // 0 based\n isOkayTypeQuestion: boolean;\n response?: ILearnosityQuestionResponse;\n /**\n * For non question questions, when user click on start, responseGiven will be true\n */\n responseGiven?: boolean;\n retryEnabled?: boolean;\n simState?: Record<string, unknown>;\n score?: ILearnosityQuestionScore;\n responseEdited?: boolean;\n hintsUsed?: number;\n markedForReview?: boolean;\n attemptsHistory?: IAttempt[];\n validatedByTeacher?: boolean;\n submittedByStudent?: boolean;\n assignStatus?: 'assigned' | 'skipped';\n rating?: number;\n skipped?: boolean;\n doubtResolved?: boolean;\n teacherReview?: ITeacherReview;\n tags?: Record<string, string>;\n timeSpent?: number;\n discussionQuestionOffset?: number;\n}\n\ntype TMathRenderer = 'mathjax' | 'mathquill';\nexport interface ILearnosity {\n ready: () => void;\n questions: () => Record<string, unknown>;\n question: (responseId: string) =>\n | {\n enable: () => boolean;\n disable: () => boolean;\n getQuestion: () => ILearnosityQuestion;\n getMetadata: () => ILearnosityQuestionMetadata;\n getResponse: () => ILearnosityQuestionResponse;\n getScore: (\n callback?: (score: ILearnosityQuestionScore | null) => void,\n ) => ILearnosityQuestionScore;\n validate: (\n options?: { showCorrectAnswers?: boolean; feedbackAttempts?: boolean },\n callback?: () => void,\n ) => void;\n resetValidationUI: () => void;\n on: (eventName: 'changed', callback: () => void) => void;\n off: (eventName: 'changed', callback?: () => void) => void;\n }\n | undefined;\n append: (toAppend: {\n questions: ILearnosityQuestion[];\n responses?: Record<string, unknown>;\n }) => void;\n appendQuestion: (toAppend: {\n questions: ILearnosityQuestion[];\n responses?: Record<string, unknown>;\n }) => void;\n reset: () => void;\n renderMath: (renderer: TMathRenderer) => void;\n}\n\nexport interface IWorksheetBehavior {\n /**\n * If true, Opens the worksheet in resume mode.\n * - If false, Opens the worksheet in review mode.\n */\n canAttempt: boolean;\n /**\n * If true, the user can mark the question for review.\n */\n canMarkForReview: boolean;\n /**\n * The mode of navigation for the worksheet.\n * - `OPEN` mode allows the user to navigate to any question in the worksheet.\n * - `LINEAR` mode allows the user to navigate to the next question only.\n * - `ADAPTIVE` mode allows the user to navigate future questions based on the rating of the current question.\n * - `CURRENT` mode allows the user to navigate to the current question only. Back and forth not allowed.\n */\n navigationMode: 'OPEN' | 'LINEAR' | 'ADAPTIVE' | 'CURRENT';\n /**\n * The initial question to display when the worksheet is loaded.\n * - `FIRST` mode displays the first question in the worksheet.\n * - `CURRENT` mode displays the question that the user was last on.\n */\n initialQuestion: 'FIRST' | 'CURRENT';\n /**\n * If hints are available, on clicking the help button, first availble hint will be shown.\n * Clicking again will show the next hint.\n * If no more hints are available, onHelp will be called.\n */\n hints: boolean;\n /**\n * The time in seconds after which the hints button will be shown.\n */\n hintsTimer?: number; // in seconds\n /**\n * If true, the user can skip the question without attempting it.\n * Skip button will be shown only after the hints are exausted and skipTimer is reached.\n */\n skippable?: boolean;\n /**\n * The time in seconds after which the user can skip the question.\n */\n skippableTime?: number; // in seconds\n /**\n * If true, after the question is system validated, teacher discussion button will be shown when the question has discussion points.\n */\n teacherDiscussionEnabled?: boolean;\n /**\n * If true, teacher validation is needed for the question to proceed\n */\n teacherValidationEnabled: boolean;\n /**\n * If worksheet is attempting outside the class setting\n * This needs teacherValidationEnabled to be true\n * TODO: Consider changing to accept validation type: 'system' | 'teacher' | undefined instead of boolean\n */\n canTeacherValidate: boolean;\n /**\n * If true, questions will be validated and feedback will be shown.\n */\n validation: boolean;\n /**\n * If true, solution wont be shown to the user.\n */\n solutionHidden?: boolean;\n /**\n * If true, questions will be validated and feedback will be shown along with the correct answer.\n */\n review: boolean;\n /**\n * The maximum number of attempts allowed for each question.\n * 0 means unlimited attempts.\n * -1 means attempts will not be validated, hence not pushed to attempt history.\n * -2 means the sheet is a puzzle sheet\n * After reaching the maximum number of attempts, the user cannot attempt the question anymore.\n * If maxAtttmpts reached and canExceedAttempts is true, the user can still attempt the question\n * , also user will have the option to move to next question\n */\n maximumAttempts: number;\n /**\n * If true, the user can exceed the maximum number of attempts.\n */\n canExceedAttempts: boolean;\n\n /**\n * After attemptsAfterTeacherInterventionNeeded incorrect attempts, retry button will be disabled in class, move ahead button will show ouside class.\n */\n attemptsAfterTeacherInterventionNeeded?: number;\n /**\n * If the worksheet minimumAccuracy is not met, on clicking the final submit button, onMinimumAccuracyNotMet will be called.\n */\n minimumAccuracy: number;\n /**\n * Label for the check button\n * For example,\n * - \"Check\" for Checking the answer\n * - \"Submit\" for Submitting the answer when doing assessment\n */\n checkButtonLabel: string;\n /**\n * If attempt is incorrect, we show retry button, this is the label for the retry button\n * For example,\n * - 'Try Again' for retrying the question\n */\n retryButtonLabel: string;\n /**\n * If true show demos calculator https://www.desmos.com/calculator\n */\n canShowDesmosCalc: boolean;\n\n // If true, canvas is enabled and user can use canvas to scribble on the worksheet by toggling the scribble button\n canvasEnabled?: boolean;\n\n // If true, the user can scribble on workheet\n canScribble?: boolean;\n}\n\nexport type TWORKSHEET_QUESTION_MEDIA_TYPE = 'SIMULATION' | 'VIDEO' | 'AUDIO';\n\nexport interface IWorksheetCallbackProps {\n onResponseChange?: (options: {\n responseId: string;\n response: IWorksheetResponse;\n isNewAttempt: boolean;\n question: IWorksheetQuestion;\n }) => void;\n onBulkResponsesChange?: (responses: Record<string, IWorksheetResponse>) => void;\n onResponsesChange?: (responses: Record<string, IWorksheetResponse>) => void;\n onMediaStateChange?: (\n question: IWorksheetQuestion,\n mediaType: TWORKSHEET_QUESTION_MEDIA_TYPE,\n mediaState: Record<string, unknown>,\n ) => void;\n onTeacherValidation?: (questionId: string, rating?: keyof typeof QUESTIONS_RATING) => void;\n onAllowRetry?: (questionId: string) => void;\n onOptionalItemAssignment?: (itemType: TItemType) => void;\n onOptionalItemSkip?: (itemType: TItemType) => void;\n onHelp?: (options: { questionId: string; questionNumber: string }) => void;\n onMinimumAccuracyNotMet?: (accuracy: number) => void;\n onExitTicketStart?: () => void;\n onExitTicketSubmit?: () => void;\n onSubmit?: (\n responses: Record<string, IWorksheetResponse>,\n questions: IWorksheetQuestion[],\n ) => void;\n onActiveQuestionChange?: (question: IWorksheetQuestion) => void;\n onResolveDoubt?: (responseId: string) => void;\n onSkip?: (itemIndex: number, widgetIndex: number) => void;\n onLoaded: () => void;\n onErrored: (error: { code?: number; message: string }) => void;\n onResponsesLoaded?: (responses: Record<string, IWorksheetResponse>) => void;\n openQuestionFeedbackModal?: (itemRef: string) => void;\n}\n\ninterface ICueCanvasCallbackProps {\n onPublishStrokes?: TPublish;\n onReceiveStrokes?: TSubscribe;\n}\n\ninterface ICueCanvasProps {\n initialStrokesData?: Record<string, IActionData[]>;\n}\n\ninterface IPointerSyncCallbackProps {\n onPublishMouseMove?: TPublishMouseMove;\n onSubscribeMouseMove?: TSubscribeMouseMove;\n}\n\nexport interface IWorksheetLayout {\n containerStyle: 'none' | 'card';\n navigationBar: 'none' | 'top' | 'bottom';\n actionBar: 'none' | 'bottom';\n containerWidth: string;\n topOffset: number; // Offset from the top of the screen, for eg: height of the header\n questionsScrollable: boolean;\n minQuestionHeight: string | number;\n minSummaryHeight: string | number;\n showUserPointer?: boolean;\n renderQuestionHeader?: boolean;\n imageHue?: THueNames;\n background?: 'none' | 'paper';\n questionPadding: number;\n}\n\nexport interface ISubjectiveSheetProps {\n onAddReviewComment?: (\n responseId: string,\n commentData: {\n score: ILearnosityQuestionScore;\n teacherReview: ITeacherReview;\n },\n ) => void;\n openImagesReviewModal?: (props: IOpenImageReviewModalProps) => void;\n handleReviewSubmit?: () => void;\n isSubmittingReview?: boolean;\n isReviewPending?: boolean;\n}\n\ninterface IBaseWorksheetProps {\n userType: TUserTypes;\n userId: string;\n studentId: string;\n studentName?: string;\n worksheetName: string;\n initialResponseId?: string;\n initialItemIndex?: number;\n layout: IWorksheetLayout;\n updatedResponses?: Record<string, IWorksheetResponse>;\n worksheetCompleted: boolean;\n showNudgeBanner?: boolean;\n markedAsCompleted?: boolean;\n canResolveDoubt?: boolean;\n actionBarRightElement?: ReactElement; // Extra Elements to be rendered in the action bar\n attemptId?: string;\n itemsSignedRequest: string;\n questionsSignedRequest: string;\n summaryDescription?: ReactElement | null;\n canSubmitWorksheet?: boolean;\n selectedTopics?: string[];\n subjectiveProps?: ISubjectiveSheetProps;\n inClass?: boolean; // If true, the worksheet is rendered inside class\n activityType: EWorksheetActivity | null;\n isDesmosEnabled?: boolean; // If true, the worksheet can show desmos calculator\n nodeType: TNodeTypes; // NodeType of the worksheet\n mode: 'resume' | 'review' | 'preview'; // mode of the worksheet\n loggerRef: MutableRefObject<(eventName: string, data?: Record<string, unknown>) => void>;\n behaviorOverride?: Partial<IWorksheetBehavior>;\n}\n\ninterface IWorksheetPlugins {\n plugins?: {\n stickers?: ReactNode;\n };\n}\n\ninterface IUpdateImages {\n filteredImages: string[];\n newImages: IFile[];\n}\ninterface IOpenImageReviewModalProps {\n isReviewed?: boolean;\n disableScoreForm?: boolean;\n imageUrls?: string[];\n filteredImageUrls?: (props: IUpdateImages) => void;\n uploadedImages?: (IFile | string)[];\n image?: string;\n}\n\nexport interface IWorksheetProps\n extends IBaseWorksheetProps,\n IWorksheetCallbackProps,\n ICueCanvasProps,\n ICueCanvasCallbackProps,\n IPointerSyncCallbackProps,\n IWorksheetPlugins {}\n\nexport interface IWorksheetRef {\n validateQuestion: (\n responseId: string,\n rating?: keyof typeof QUESTIONS_RATING,\n skipRemainingQuestions?: boolean,\n ) => void;\n assignOptionalItems: (itemType: TItemType) => void;\n skipOptionalItems: (itemType: TItemType) => void;\n updateMediaState: (\n responseId: string,\n mediaType: TWORKSHEET_QUESTION_MEDIA_TYPE,\n mediaState: Record<string, unknown>,\n ) => void;\n allowRetry: (responseId: string) => void;\n}\n\ninterface IWorksheetHeaderLayoutArgs {\n isPuzzleWorksheet?: boolean;\n isTestWorksheet?: boolean;\n imageHue?: THueNames;\n}\n\nexport interface IWorksheetHeaderLayoutProps {\n (args: IWorksheetHeaderLayoutArgs): {\n bgColor: TColorNames;\n borderColor?: TColorNames;\n textColor?: TColorNames;\n };\n}\n\nexport type TWorksheetStoreProps = Omit<\n IBaseWorksheetProps,\n 'studentName' | 'itemsSignedRequest' | 'mode'\n> &\n Required<Pick<IBaseWorksheetProps, 'studentName'>> &\n Omit<IWorksheetCallbackProps, 'onLoaded' | 'onErrored'> &\n ICueCanvasProps &\n ICueCanvasCallbackProps &\n IPointerSyncCallbackProps &\n IWorksheetPlugins & {\n behavior: IWorksheetBehavior;\n learnosityItems: ILearnosityItem[];\n learnosityResponses?: Record<string, IWorksheetResponse>;\n learnosity: ILearnosity;\n appendedQuestionIds: string[];\n };\n\nexport enum EActiveQuestionTool {\n TEACHING_TOOLS = 'TEACHING_TOOLS',\n SOLUTION = 'SOLUTION',\n DISCUSSION = 'DISCUSSION',\n}\n\nexport interface IWorksheetStoreState {\n questions: IWorksheetQuestion[];\n renderableQuestions: IWorksheetQuestion[];\n responses: Record<string, IWorksheetResponse>;\n lastUnlockedQuestionIndex: number;\n initialQuestionId: string;\n activeQuestionId: string;\n activeQuestionIndex: number;\n questionsContainerWidth: number;\n maxQuestionWidth: number;\n actionbarHeight: number;\n summaryVisible: boolean;\n calculatorVisible: boolean;\n scribblingEnabled: boolean;\n activeQuestionTool?: EActiveQuestionTool;\n blocker?: TWorksheetBlocker;\n scrolledToInitialQuestion: boolean;\n}\n\n// Actions interface - contains all the methods\ninterface IWorksheetStoreActions {\n mergeWorksheetProps: (data: TWorksheetStoreProps) => void;\n setResponses: (\n responses:\n | IWorksheetStore['responses']\n | ((prevResponses: IWorksheetStore['responses']) => IWorksheetStore['responses']),\n ) => void;\n showSummary: () => void;\n hideSummary: () => void;\n toggleSummary: () => void;\n toggleCalculator: () => void;\n toggleScribble: () => void;\n setBlocker: (blocker?: TWorksheetBlocker) => void;\n /**\n *\n * @param scrollToLastUnlockedQuestion - If true, scrolls to the last unlocked question after removing the blocker. Default is true.\n * @returns\n */\n removeBlocker: (scrollToLastUnlockedQuestion?: boolean) => void;\n updateResponse: (options: {\n responseId: string;\n response: ILearnosityQuestionResponse;\n score: ILearnosityQuestionScore;\n timeSpent: number;\n answerChecked?: boolean;\n }) => void;\n updateMediaState: (\n responseId: string,\n mediaType: TWORKSHEET_QUESTION_MEDIA_TYPE,\n mediaState: Record<string, unknown>,\n ) => void;\n setDiscussionQuestionOffset: (responseId: string, offset: number) => void;\n markForReview: (responseId: string, markedForReview: boolean) => void;\n changeQuestion: (questionId: string, shouldScroll?: boolean, scrollDelay?: number) => void;\n setActiveQuestionTool: (tool: EActiveQuestionTool) => void;\n unsetActiveQuestionTool: () => void;\n destroy: () => void;\n}\n\n// Combined store interface\nexport interface IWorksheetStore\n extends IWorksheetStoreState,\n TWorksheetStoreProps,\n IWorksheetStoreActions {}\n"],"names":["QUESTION_TAGS","QUESTIONS_RATING","EActiveQuestionTool"],"mappings":"AASY,IAAAA,sBAAAA,OACVA,EAAA,cAAc,eACdA,EAAA,gBAAgB,iBAFNA,IAAAA,KAAA,CAAA,CAAA,GAKAC,sBAAAA,OACVA,EAAAA,EAAA,IAAI,CAAJ,IAAA,KACAA,EAAAA,EAAA,IAAI,CAAJ,IAAA,KACAA,EAAAA,EAAA,IAAI,CAAJ,IAAA,KAHUA,IAAAA,KAAA,CAAA,CAAA,GAwjBAC,sBAAAA,OACVA,EAAA,iBAAiB,kBACjBA,EAAA,WAAW,YACXA,EAAA,aAAa,cAHHA,IAAAA,KAAA,CAAA,CAAA;"}
1
+ {"version":3,"file":"worksheet-types.js","sources":["../../../../src/features/worksheet/worksheet/worksheet-types.ts"],"sourcesContent":["import type { MutableRefObject, ReactElement, ReactNode } from 'react';\n\nimport type { EWorksheetActivity, TNodeTypes } from '../../../types/models/worksheet';\nimport type { IActionData, TPublish, TSubscribe } from '../../cue-canvas/types/cue-canvas';\nimport type { TPublishMouseMove, TSubscribeMouseMove } from '../../pointer-sync/pointer-types';\nimport type { TColorNames, THueNames, TUserTypes } from '../../ui/types';\nimport { type IFile } from '../../hooks/use-s3-helper/use-s3-helper';\nimport type { TWorksheetBlocker } from './worksheet-blocker/worksheet-blocker-types';\n\nexport enum QUESTION_TAGS {\n TRIAL_TOPIC = 'trial-topic',\n QUESTION_CODE = 'question code',\n}\n\nexport enum QUESTIONS_RATING {\n E = 3,\n S = 2, // Just right\n H = 1,\n}\n\nexport interface ILearnosityError {\n code: number;\n consumerKey: string;\n detail: string;\n errorUI: string;\n msg: string;\n}\n\ninterface ILearnosityQuestionMetadata {\n widget_reference: string;\n sheet_reference: string;\n acknowledgements?: string;\n sample_answer?: string;\n hints?: string[];\n solution?: string[];\n teacher_tips?: string[];\n valid_response_count: number;\n distractor_rationale_response_level?: string[];\n source: {\n organisation_id: number;\n };\n}\n\nexport type TInstructorStimulus =\n | 'SystemIntro' // lesson v3\n | 'Intro' // lesson v3\n | 'Concept-Intro' // lesson v3\n | 'Instruction' // lesson v3\n | 'Task' // lesson v3\n | 'Try' // trial v3\n | 'Learn' // trial v3\n | 'Apply'; // trial v3\n\nexport type TItemType =\n | 'overview'\n | 'learning'\n | 'learning-we-do'\n | 'learning-your-turn'\n | 'learning-explore'\n | 'practice'\n | 'practice-basic'\n | 'practice-basic-optional'\n | 'practice-regular'\n | 'practice-regular-optional'\n | 'exit-ticket'\n | 'advanced-we-do'\n | 'advanced-your-turn'\n | 'advanced-explore'\n | 'advanced-practice';\n\nexport type TSectionName =\n | 'overview'\n | 'learning'\n | 'practice'\n | 'practice-basic'\n | 'practice-regular'\n | 'exit-ticket'\n | 'advanced';\n\ninterface IQuestionValidResponse {\n score: number;\n value: unknown[];\n}\n\nexport interface ISheetNudgeBannerInfo {\n bannerBackgroundColor: TColorNames;\n label: string;\n}\n\nexport interface ILearnosityQuestion {\n response_id: string;\n instructor_stimulus?: TInstructorStimulus;\n metadata: ILearnosityQuestionMetadata;\n instant_feedback?: boolean;\n math_renderer?: string;\n template?: string;\n tokenization?: string;\n numberPad?: string[];\n symbols?: unknown[];\n response_container?: Record<string, unknown>;\n ui_style?: Record<string, unknown>;\n shuffle_options?: boolean;\n // for custom type question validation is undefined.\n validation?: {\n scoring_type?: string;\n unscored?: boolean;\n valid_response?: IQuestionValidResponse;\n alt_responses?: IQuestionValidResponse[];\n penalty?: number;\n min_score_if_attempted?: number;\n };\n is_math?: boolean;\n labels?: Record<string, unknown>;\n line?: Record<string, unknown>;\n points?: string[];\n snap_to_ticks?: boolean;\n ticks?: Record<string, unknown>;\n max_length?: number;\n type:\n | 'hotspot'\n | 'tokenhighlight'\n | 'numberline'\n | 'clozeassociation'\n | 'clozetext'\n | 'association'\n | 'classification'\n | 'clozedropdown'\n | 'clozeformula'\n | 'mcq'\n | 'choicematrix'\n | 'plaintext'\n | 'drawing';\n case_sensitive?: boolean;\n show_copy?: boolean;\n show_cut?: boolean;\n show_paste?: boolean;\n spellcheck?: boolean;\n stimulus?: string;\n stimulus_review?: string;\n stimulus_list?: string[];\n image?: Record<string, unknown>;\n areas?: unknown[];\n area_attributes?: Record<string, unknown>;\n possible_responses?: string[][] | string[];\n duplicate_responses?: boolean;\n response_containers?: unknown[];\n options?: Record<string, unknown>[] | string[];\n feedback_attempts?: number;\n stems?: string[];\n multiple_responses?: boolean;\n}\n\nexport interface ILearnosityItem {\n reference: string;\n questions: ILearnosityQuestion[];\n source: Record<string, unknown>;\n content: string;\n metadata: Record<string, unknown> | unknown[];\n workflow: unknown[];\n response_ids: string[];\n feature_ids: unknown[];\n features: unknown[];\n itemType?: TItemType;\n tags?: string[];\n}\n\nexport interface IWorksheetQuestion extends ILearnosityQuestion {\n item_reference: string;\n item_type?: TItemType;\n section_name?: TSectionName;\n is_optional?: boolean;\n /**\n * If true, the question is not a question, but a content only item\n * e.g. Intro, Overview, Instruction etc.\n */\n is_non_question?: boolean;\n concept_intro_stimulus?: string; // Content for concept intro widget\n item_tags: string[];\n item_tags_map: Record<string, string>;\n item_number: number;\n item_display_number: number;\n question_number: number;\n total_questions: number;\n /**\n * if true, scribbler button will be shown on the question\n */\n can_scribble: boolean; // If true, the question can be scribbled on\n}\n\nexport interface ILearnosityQuestionScore {\n score?: number | null;\n max_score: number;\n unscored?: boolean;\n}\n\nexport interface ILearnosityQuestionResponse {\n value: unknown;\n responses?: unknown;\n type: unknown;\n updatedFormat?: boolean;\n wordCount?: number;\n apiVersion: string;\n revision: number;\n feedbackAttemptsCount?: number;\n}\n\ninterface IAttempt {\n response: ILearnosityQuestionResponse;\n score: ILearnosityQuestionScore;\n}\n\ninterface ITeacherReview {\n reviewComment?: string;\n images?: string[];\n}\nexport interface IWorksheetResponse {\n widgetReference: string;\n itemReference: string;\n itemPosition: number; // 0 based\n questionPosition: number; // 0 based\n isOkayTypeQuestion: boolean;\n response?: ILearnosityQuestionResponse;\n /**\n * For non question questions, when user click on start, responseGiven will be true\n */\n responseGiven?: boolean;\n retryEnabled?: boolean;\n simState?: Record<string, unknown>;\n score?: ILearnosityQuestionScore;\n responseEdited?: boolean;\n hintsUsed?: number;\n markedForReview?: boolean;\n attemptsHistory?: IAttempt[];\n validatedByTeacher?: boolean;\n submittedByStudent?: boolean;\n assignStatus?: 'assigned' | 'skipped';\n rating?: number;\n skipped?: boolean;\n doubtResolved?: boolean;\n teacherReview?: ITeacherReview;\n tags?: Record<string, string>;\n timeSpent?: number;\n discussionQuestionOffset?: number;\n distractor_rationale_response_level?: string[];\n}\n\ntype TMathRenderer = 'mathjax' | 'mathquill';\nexport interface ILearnosity {\n ready: () => void;\n questions: () => Record<string, unknown>;\n question: (responseId: string) =>\n | {\n enable: () => boolean;\n disable: () => boolean;\n getQuestion: () => ILearnosityQuestion;\n getMetadata: () => ILearnosityQuestionMetadata;\n getResponse: () => ILearnosityQuestionResponse;\n getScore: (\n callback?: (score: ILearnosityQuestionScore | null) => void,\n ) => ILearnosityQuestionScore;\n validate: (\n options?: { showCorrectAnswers?: boolean; feedbackAttempts?: boolean },\n callback?: () => void,\n ) => void;\n resetValidationUI: () => void;\n on: (eventName: 'changed', callback: () => void) => void;\n off: (eventName: 'changed', callback?: () => void) => void;\n }\n | undefined;\n append: (toAppend: {\n questions: ILearnosityQuestion[];\n responses?: Record<string, unknown>;\n }) => void;\n appendQuestion: (toAppend: {\n questions: ILearnosityQuestion[];\n responses?: Record<string, unknown>;\n }) => void;\n reset: () => void;\n renderMath: (renderer: TMathRenderer) => void;\n}\n\nexport interface IWorksheetBehavior {\n /**\n * If true, Opens the worksheet in resume mode.\n * - If false, Opens the worksheet in review mode.\n */\n canAttempt: boolean;\n /**\n * If true, the user can mark the question for review.\n */\n canMarkForReview: boolean;\n /**\n * The mode of navigation for the worksheet.\n * - `OPEN` mode allows the user to navigate to any question in the worksheet.\n * - `LINEAR` mode allows the user to navigate to the next question only.\n * - `ADAPTIVE` mode allows the user to navigate future questions based on the rating of the current question.\n * - `CURRENT` mode allows the user to navigate to the current question only. Back and forth not allowed.\n */\n navigationMode: 'OPEN' | 'LINEAR' | 'ADAPTIVE' | 'CURRENT';\n /**\n * The initial question to display when the worksheet is loaded.\n * - `FIRST` mode displays the first question in the worksheet.\n * - `CURRENT` mode displays the question that the user was last on.\n */\n initialQuestion: 'FIRST' | 'CURRENT';\n /**\n * If hints are available, on clicking the help button, first availble hint will be shown.\n * Clicking again will show the next hint.\n * If no more hints are available, onHelp will be called.\n */\n hints: boolean;\n /**\n * The time in seconds after which the hints button will be shown.\n */\n hintsTimer?: number; // in seconds\n /**\n * If true, the user can skip the question without attempting it.\n * Skip button will be shown only after the hints are exausted and skipTimer is reached.\n */\n skippable?: boolean;\n /**\n * The time in seconds after which the user can skip the question.\n */\n skippableTime?: number; // in seconds\n /**\n * If true, after the question is system validated, teacher discussion button will be shown when the question has discussion points.\n */\n teacherDiscussionEnabled?: boolean;\n /**\n * If true, teacher validation is needed for the question to proceed\n */\n teacherValidationEnabled: boolean;\n /**\n * If worksheet is attempting outside the class setting\n * This needs teacherValidationEnabled to be true\n * TODO: Consider changing to accept validation type: 'system' | 'teacher' | undefined instead of boolean\n */\n canTeacherValidate: boolean;\n /**\n * If true, questions will be validated and feedback will be shown.\n */\n validation: boolean;\n /**\n * If true, solution wont be shown to the user.\n */\n solutionHidden?: boolean;\n /**\n * If true, questions will be validated and feedback will be shown along with the correct answer.\n */\n review: boolean;\n /**\n * The maximum number of attempts allowed for each question.\n * 0 means unlimited attempts.\n * -1 means attempts will not be validated, hence not pushed to attempt history.\n * -2 means the sheet is a puzzle sheet\n * After reaching the maximum number of attempts, the user cannot attempt the question anymore.\n * If maxAtttmpts reached and canExceedAttempts is true, the user can still attempt the question\n * , also user will have the option to move to next question\n */\n maximumAttempts: number;\n /**\n * If true, the user can exceed the maximum number of attempts.\n */\n canExceedAttempts: boolean;\n\n /**\n * After attemptsAfterTeacherInterventionNeeded incorrect attempts, retry button will be disabled in class, move ahead button will show ouside class.\n */\n attemptsAfterTeacherInterventionNeeded?: number;\n /**\n * If the worksheet minimumAccuracy is not met, on clicking the final submit button, onMinimumAccuracyNotMet will be called.\n */\n minimumAccuracy: number;\n /**\n * Label for the check button\n * For example,\n * - \"Check\" for Checking the answer\n * - \"Submit\" for Submitting the answer when doing assessment\n */\n checkButtonLabel: string;\n /**\n * If attempt is incorrect, we show retry button, this is the label for the retry button\n * For example,\n * - 'Try Again' for retrying the question\n */\n retryButtonLabel: string;\n /**\n * If true show demos calculator https://www.desmos.com/calculator\n */\n canShowDesmosCalc: boolean;\n\n // If true, canvas is enabled and user can use canvas to scribble on the worksheet by toggling the scribble button\n canvasEnabled?: boolean;\n\n // If true, the user can scribble on workheet\n canScribble?: boolean;\n}\n\nexport type TWORKSHEET_QUESTION_MEDIA_TYPE = 'SIMULATION' | 'VIDEO' | 'AUDIO';\n\nexport interface IWorksheetCallbackProps {\n onResponseChange?: (options: {\n responseId: string;\n response: IWorksheetResponse;\n isNewAttempt: boolean;\n question: IWorksheetQuestion;\n }) => void;\n onBulkResponsesChange?: (responses: Record<string, IWorksheetResponse>) => void;\n onResponsesChange?: (responses: Record<string, IWorksheetResponse>) => void;\n onMediaStateChange?: (\n question: IWorksheetQuestion,\n mediaType: TWORKSHEET_QUESTION_MEDIA_TYPE,\n mediaState: Record<string, unknown>,\n ) => void;\n onTeacherValidation?: (questionId: string, rating?: keyof typeof QUESTIONS_RATING) => void;\n onAllowRetry?: (questionId: string) => void;\n onOptionalItemAssignment?: (itemType: TItemType) => void;\n onOptionalItemSkip?: (itemType: TItemType) => void;\n onHelp?: (options: { questionId: string; questionNumber: string }) => void;\n onMinimumAccuracyNotMet?: (accuracy: number) => void;\n onExitTicketStart?: () => void;\n onExitTicketSubmit?: () => void;\n onSubmit?: (\n responses: Record<string, IWorksheetResponse>,\n questions: IWorksheetQuestion[],\n ) => void;\n onActiveQuestionChange?: (question: IWorksheetQuestion) => void;\n onResolveDoubt?: (responseId: string) => void;\n onSkip?: (itemIndex: number, widgetIndex: number) => void;\n onLoaded: () => void;\n onErrored: (error: { code?: number; message: string }) => void;\n onResponsesLoaded?: (responses: Record<string, IWorksheetResponse>) => void;\n openQuestionFeedbackModal?: (itemRef: string) => void;\n}\n\ninterface ICueCanvasCallbackProps {\n onPublishStrokes?: TPublish;\n onReceiveStrokes?: TSubscribe;\n}\n\ninterface ICueCanvasProps {\n initialStrokesData?: Record<string, IActionData[]>;\n}\n\ninterface IPointerSyncCallbackProps {\n onPublishMouseMove?: TPublishMouseMove;\n onSubscribeMouseMove?: TSubscribeMouseMove;\n}\n\nexport interface IWorksheetLayout {\n containerStyle: 'none' | 'card';\n navigationBar: 'none' | 'top' | 'bottom';\n actionBar: 'none' | 'bottom';\n containerWidth: string;\n topOffset: number; // Offset from the top of the screen, for eg: height of the header\n questionsScrollable: boolean;\n minQuestionHeight: string | number;\n minSummaryHeight: string | number;\n showUserPointer?: boolean;\n renderQuestionHeader?: boolean;\n imageHue?: THueNames;\n background?: 'none' | 'paper';\n questionPadding: number;\n}\n\nexport interface ISubjectiveSheetProps {\n onAddReviewComment?: (\n responseId: string,\n commentData: {\n score: ILearnosityQuestionScore;\n teacherReview: ITeacherReview;\n },\n ) => void;\n openImagesReviewModal?: (props: IOpenImageReviewModalProps) => void;\n handleReviewSubmit?: () => void;\n isSubmittingReview?: boolean;\n isReviewPending?: boolean;\n}\n\ninterface IBaseWorksheetProps {\n userType: TUserTypes;\n userId: string;\n studentId: string;\n studentName?: string;\n worksheetName: string;\n initialResponseId?: string;\n initialItemIndex?: number;\n layout: IWorksheetLayout;\n updatedResponses?: Record<string, IWorksheetResponse>;\n worksheetCompleted: boolean;\n showNudgeBanner?: boolean;\n markedAsCompleted?: boolean;\n canResolveDoubt?: boolean;\n actionBarRightElement?: ReactElement; // Extra Elements to be rendered in the action bar\n attemptId?: string;\n itemsSignedRequest: string;\n questionsSignedRequest: string;\n summaryDescription?: ReactElement | null;\n canSubmitWorksheet?: boolean;\n selectedTopics?: string[];\n subjectiveProps?: ISubjectiveSheetProps;\n inClass?: boolean; // If true, the worksheet is rendered inside class\n activityType: EWorksheetActivity | null;\n isDesmosEnabled?: boolean; // If true, the worksheet can show desmos calculator\n nodeType: TNodeTypes; // NodeType of the worksheet\n mode: 'resume' | 'review' | 'preview'; // mode of the worksheet\n loggerRef: MutableRefObject<(eventName: string, data?: Record<string, unknown>) => void>;\n behaviorOverride?: Partial<IWorksheetBehavior>;\n}\n\ninterface IWorksheetPlugins {\n plugins?: {\n stickers?: ReactNode;\n };\n}\n\ninterface IUpdateImages {\n filteredImages: string[];\n newImages: IFile[];\n}\ninterface IOpenImageReviewModalProps {\n isReviewed?: boolean;\n disableScoreForm?: boolean;\n imageUrls?: string[];\n filteredImageUrls?: (props: IUpdateImages) => void;\n uploadedImages?: (IFile | string)[];\n image?: string;\n}\n\nexport interface IWorksheetProps\n extends IBaseWorksheetProps,\n IWorksheetCallbackProps,\n ICueCanvasProps,\n ICueCanvasCallbackProps,\n IPointerSyncCallbackProps,\n IWorksheetPlugins {}\n\nexport interface IWorksheetRef {\n validateQuestion: (\n responseId: string,\n rating?: keyof typeof QUESTIONS_RATING,\n skipRemainingQuestions?: boolean,\n ) => void;\n assignOptionalItems: (itemType: TItemType) => void;\n skipOptionalItems: (itemType: TItemType) => void;\n updateMediaState: (\n responseId: string,\n mediaType: TWORKSHEET_QUESTION_MEDIA_TYPE,\n mediaState: Record<string, unknown>,\n ) => void;\n allowRetry: (responseId: string) => void;\n}\n\ninterface IWorksheetHeaderLayoutArgs {\n isPuzzleWorksheet?: boolean;\n isTestWorksheet?: boolean;\n imageHue?: THueNames;\n}\n\nexport interface IWorksheetHeaderLayoutProps {\n (args: IWorksheetHeaderLayoutArgs): {\n bgColor: TColorNames;\n borderColor?: TColorNames;\n textColor?: TColorNames;\n };\n}\n\nexport type TWorksheetStoreProps = Omit<\n IBaseWorksheetProps,\n 'studentName' | 'itemsSignedRequest' | 'mode'\n> &\n Required<Pick<IBaseWorksheetProps, 'studentName'>> &\n Omit<IWorksheetCallbackProps, 'onLoaded' | 'onErrored'> &\n ICueCanvasProps &\n ICueCanvasCallbackProps &\n IPointerSyncCallbackProps &\n IWorksheetPlugins & {\n behavior: IWorksheetBehavior;\n learnosityItems: ILearnosityItem[];\n learnosityResponses?: Record<string, IWorksheetResponse>;\n learnosity: ILearnosity;\n appendedQuestionIds: string[];\n };\n\nexport enum EActiveQuestionTool {\n TEACHING_TOOLS = 'TEACHING_TOOLS',\n SOLUTION = 'SOLUTION',\n DISCUSSION = 'DISCUSSION',\n}\n\nexport interface IWorksheetStoreState {\n questions: IWorksheetQuestion[];\n renderableQuestions: IWorksheetQuestion[];\n responses: Record<string, IWorksheetResponse>;\n lastUnlockedQuestionIndex: number;\n initialQuestionId: string;\n activeQuestionId: string;\n activeQuestionIndex: number;\n questionsContainerWidth: number;\n maxQuestionWidth: number;\n actionbarHeight: number;\n summaryVisible: boolean;\n calculatorVisible: boolean;\n scribblingEnabled: boolean;\n activeQuestionTool?: EActiveQuestionTool;\n blocker?: TWorksheetBlocker;\n scrolledToInitialQuestion: boolean;\n}\n\n// Actions interface - contains all the methods\ninterface IWorksheetStoreActions {\n mergeWorksheetProps: (data: TWorksheetStoreProps) => void;\n setResponses: (\n responses:\n | IWorksheetStore['responses']\n | ((prevResponses: IWorksheetStore['responses']) => IWorksheetStore['responses']),\n ) => void;\n showSummary: () => void;\n hideSummary: () => void;\n toggleSummary: () => void;\n toggleCalculator: () => void;\n toggleScribble: () => void;\n setBlocker: (blocker?: TWorksheetBlocker) => void;\n /**\n *\n * @param scrollToLastUnlockedQuestion - If true, scrolls to the last unlocked question after removing the blocker. Default is true.\n * @returns\n */\n removeBlocker: (scrollToLastUnlockedQuestion?: boolean) => void;\n updateResponse: (options: {\n responseId: string;\n response: ILearnosityQuestionResponse;\n score: ILearnosityQuestionScore;\n timeSpent: number;\n answerChecked?: boolean;\n }) => void;\n updateMediaState: (\n responseId: string,\n mediaType: TWORKSHEET_QUESTION_MEDIA_TYPE,\n mediaState: Record<string, unknown>,\n ) => void;\n setDiscussionQuestionOffset: (responseId: string, offset: number) => void;\n markForReview: (responseId: string, markedForReview: boolean) => void;\n changeQuestion: (questionId: string, shouldScroll?: boolean, scrollDelay?: number) => void;\n setActiveQuestionTool: (tool: EActiveQuestionTool) => void;\n unsetActiveQuestionTool: () => void;\n destroy: () => void;\n}\n\n// Combined store interface\nexport interface IWorksheetStore\n extends IWorksheetStoreState,\n TWorksheetStoreProps,\n IWorksheetStoreActions {}\n"],"names":["QUESTION_TAGS","QUESTIONS_RATING","EActiveQuestionTool"],"mappings":"AASY,IAAAA,sBAAAA,OACVA,EAAA,cAAc,eACdA,EAAA,gBAAgB,iBAFNA,IAAAA,KAAA,CAAA,CAAA,GAKAC,sBAAAA,OACVA,EAAAA,EAAA,IAAI,CAAJ,IAAA,KACAA,EAAAA,EAAA,IAAI,CAAJ,IAAA,KACAA,EAAAA,EAAA,IAAI,CAAJ,IAAA,KAHUA,IAAAA,KAAA,CAAA,CAAA,GA0jBAC,sBAAAA,OACVA,EAAA,iBAAiB,kBACjBA,EAAA,WAAW,YACXA,EAAA,aAAa,cAHHA,IAAAA,KAAA,CAAA,CAAA;"}
package/dist/index.d.ts CHANGED
@@ -2380,6 +2380,7 @@ declare interface ILearnosityQuestionMetadata {
2380
2380
  solution?: string[];
2381
2381
  teacher_tips?: string[];
2382
2382
  valid_response_count: number;
2383
+ distractor_rationale_response_level?: string[];
2383
2384
  source: {
2384
2385
  organisation_id: number;
2385
2386
  };
@@ -5546,6 +5547,7 @@ export declare interface IWorksheetResponse {
5546
5547
  tags?: Record<string, string>;
5547
5548
  timeSpent?: number;
5548
5549
  discussionQuestionOffset?: number;
5550
+ distractor_rationale_response_level?: string[];
5549
5551
  }
5550
5552
 
5551
5553
  export declare enum JOURNEY_ID_STUDENT {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cuemath/leap",
3
- "version": "4.0.8",
3
+ "version": "4.1.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"