l-min-components 1.7.1421 → 1.7.1422

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.
@@ -60,6 +60,28 @@ const quizResponses = ({ responses = [], type = "scripted" }) => {
60
60
  });
61
61
  };
62
62
 
63
+ const getColor = (aiScore) => {
64
+ if (!aiScore) return;
65
+ let color = "";
66
+ if (aiScore <= 27) {
67
+ color = "rgba(249, 84, 84, 1)";
68
+ } else if (aiScore >= 28 && aiScore <= 45) {
69
+ color = "rgba(151, 71, 255, 1)";
70
+ } else if (aiScore >= 46 && aiScore <= 60) {
71
+ color = "rgba(219, 136, 13, 1)";
72
+ } else if (aiScore >= 61 && aiScore <= 74) {
73
+ color = "rgba(229, 173, 14, 1)";
74
+ } else if (aiScore >= 75 && aiScore <= 87) {
75
+ color = "rgba(13, 95, 219, 1)";
76
+ } else if (aiScore >= 88 && aiScore <= 94) {
77
+ color = "rgba(13, 125, 150, 1)";
78
+ } else if (aiScore >= 95) {
79
+ color = "rgba(85, 193, 0, 1)";
80
+ }
81
+
82
+ return color;
83
+ };
84
+
63
85
  const dialogueResponses = ({
64
86
  responses = [],
65
87
  type = "scriped",
@@ -85,15 +107,26 @@ const dialogueResponses = ({
85
107
 
86
108
  const getTrabScriptData = (models) => {
87
109
  if (models?.length && models) {
88
- return models
89
- ?.find((item) => item?.id === "speech_analysis")
90
- ?.words?.map((item) => ({
91
- aiScore: item?.["Word Score"],
92
- text: item?.wordText,
93
- }));
110
+ const speechAnalysisModel = models.find(
111
+ (item) => item?.id === "speech_analysis"
112
+ );
113
+
114
+ if (speechAnalysisModel?.words) {
115
+ return speechAnalysisModel.words.map((item) => {
116
+ const aiScore = item?.["Word Score"] || 0;
117
+ let color = getColor(aiScore);
118
+
119
+ return {
120
+ aiScore: aiScore,
121
+ text: item?.wordText,
122
+ color: color,
123
+ };
124
+ });
125
+ }
94
126
  }
95
127
  return null;
96
128
  };
129
+
97
130
  const setupAnalysis = (data, audioData, score) => {
98
131
  if (!data || typeof data !== "object") return;
99
132
  const formatted = [];
@@ -187,6 +220,7 @@ const setupAnalysis = (data, audioData, score) => {
187
220
  data?.speech_analysis?.[0]?.model_data?.["Reference"]
188
221
  ) {
189
222
  const speechAnalysisData = data?.speech_analysis?.[0]?.model_data;
223
+ console.log(speechAnalysisData, "yyyy");
190
224
  const score = speechAnalysisData?.["General Score"] || 0;
191
225
 
192
226
  const words = Object.values(
@@ -294,6 +328,7 @@ const setupAnalysis = (data, audioData, score) => {
294
328
  id: idx + 1,
295
329
  wordText: word?.Word?.toLowerCase(),
296
330
  isGood: word?.["Word Score"] > 45,
331
+ color: getColor(word?.["Word Score"]),
297
332
  optionData,
298
333
  };
299
334
  });
@@ -570,6 +605,12 @@ const grammerCorrectParagraph = (data) => {
570
605
 
571
606
  return paragraph;
572
607
  };
608
+ const formatNumber = (number) => {
609
+ if (!number && typeof number !== "number") return "0.00";
610
+
611
+ const formattedNumber = number?.toFixed(2);
612
+ return formattedNumber;
613
+ };
573
614
  const useReportUtils = () => {
574
615
  return {
575
616
  renderCorrectedSentence,
@@ -584,6 +625,7 @@ const useReportUtils = () => {
584
625
  grammarFeekbackResult,
585
626
  grammarCorrectResult,
586
627
  grammerCorrectParagraph,
628
+ formatNumber,
587
629
  };
588
630
  };
589
631
 
@@ -16,11 +16,11 @@ const GradingModal = ({
16
16
  const [selected, setSelected] = useState("manually");
17
17
  const [value, setValue] = useState(defaultScore || "");
18
18
 
19
- const numberValue = Number(value || 0);
19
+ const numberValue = parseFloat(value || 0);
20
20
  const disable = selected === "manually" && (numberValue > 100 || !value);
21
21
 
22
- const isNumbter = Number(aiValue) || 0;
23
- const isSuggestionNumber = Number(suggestionValue) || 0;
22
+ const isNumbter = parseFloat(aiValue) || 0;
23
+ const isSuggestionNumber = parseFloat(suggestionValue) || 0;
24
24
 
25
25
  const handleSetValue = () => {
26
26
  setScore?.({
@@ -31,9 +31,7 @@ const Response = ({
31
31
  if (isAiWordFlow && typeof response !== "string") {
32
32
  const htmlString = response
33
33
  ?.map((item) => {
34
- return item.aiScore > 45
35
- ? `<span style="color: #30D468;">${item.text}</span>`
36
- : `<span style="color: #F95454;">${item.text}</span>`;
34
+ return `<span style="color: ${item?.color};">${item?.text}</span>`;
37
35
  })
38
36
  .join(" ");
39
37
  return htmlString;
@@ -41,6 +39,7 @@ const Response = ({
41
39
  return response;
42
40
  };
43
41
  const htmlString = setupAiWordFlow();
42
+
44
43
  return (
45
44
  <ResponseContainer>
46
45
  {title && <h3>{title}</h3>}
@@ -21,6 +21,9 @@ export const ResponseContent = styled.div`
21
21
  export const ResponseAiWordFlow = styled.div`
22
22
  color: #4a4d4d;
23
23
  font-size: 16px;
24
+ &::first-letter {
25
+ text-transform: capitalize;
26
+ }
24
27
  `;
25
28
 
26
29
  export const FallbackResponse = styled(ResponseContent)`
@@ -40,5 +43,8 @@ export const FallbackResponse = styled(ResponseContent)`
40
43
  &.good-fallback {
41
44
  color: #30d468;
42
45
  }
46
+ &::first-letter {
47
+ text-transform: capitalize;
48
+ }
43
49
  }
44
50
  `;
@@ -862,52 +862,45 @@ const reading = {
862
862
  };
863
863
 
864
864
  const natchPair = {
865
- question_id: 3113,
866
- question_activity_id: 8410,
865
+ question_id: 3316,
866
+ question_activity_id: 8636,
867
867
  position_index: 0,
868
- title: "Try to match animals and the sound they make",
868
+ title: "Pair 1",
869
869
  type: "MATCH_PAIR",
870
870
  question_data: {
871
871
  type: "MATCH_PAIR",
872
872
  question_title: " ",
873
- question_data: {
874
- Cat: "Meow\n\n",
875
- Cow: "Moo",
876
- Dog: "Bark",
877
- Goat: "Bleat",
878
- Lion: "Roar",
879
- },
873
+ question_data: { Boy: "Girl", Hello: "Word", James: "Doe" },
880
874
  no_of_attempts: 2,
881
- instruction: "Try to match animals and the sound they make",
875
+ instruction: "Pair 1",
882
876
  },
883
877
  answer: {
884
- session_id: "e0b8fb0cc6a0413e8a48af124c402965",
885
- attempt_index: 1,
878
+ session_id: "52e7d900d7d34c7bba2c9fe385609049",
879
+ attempt_index: 8,
886
880
  token_claimed: 0,
887
881
  score: null,
888
882
  marked: false,
889
883
  expire_at: null,
890
- created_at: "2025-07-12T11:35:09.718763Z",
884
+ created_at: "2025-07-21T13:48:18.454224Z",
891
885
  grading_date: null,
892
886
  data: {
893
887
  type: "MATCH_PAIR",
894
- session_id: "1908e1c9f5ab488",
895
- submited_datetime: "2025-07-09T16:23:56.644424Z",
888
+ session_id: "149bdd0fb30745a",
889
+ submited_datetime: "2025-07-20T18:43:25.848341Z",
896
890
  responses: {
897
- 1: { type: "MatchPair", value: "Bark" },
898
- 2: { type: "MatchPair", value: "" },
899
- 3: { type: "MatchPair", value: "Bleat" },
900
- 4: { type: "MatchPair", value: "" },
901
- 5: { type: "MatchPair", value: "Moo" },
891
+ Boy: { type: "MatchPair", value: "Doe" },
892
+ Hello: { type: "MatchPair", value: "Word" },
893
+ James: { type: "MatchPair", value: "Girl" },
902
894
  },
903
895
  },
904
896
  comments: null,
905
897
  },
906
898
  score: 0,
907
- ai_score: 0,
899
+ ai_score: null,
908
900
  grading_data: {},
909
901
  grade_method: "MANUAL",
910
- suggested_score: 0,
902
+ suggested_score: 33.3,
903
+ ai_score_available: true,
911
904
  };
912
905
 
913
906
  const quizScriptedWithImage = {
@@ -40,6 +40,7 @@ import FullAnalysis from "../fullAnalysis";
40
40
  import useApi from "./api";
41
41
  import FullPageLoader from "../../fullPageLoader";
42
42
  import { OutletContext } from "../..";
43
+ import useReportUtils from "../hooks/useRreportUtils";
43
44
 
44
45
  /**
45
46
  * @param {Object} props
@@ -63,6 +64,7 @@ const ReportQuestions = ({
63
64
  const [toggle, setToggle] = useState(null);
64
65
  const { affiliateAccount } = useContext(OutletContext);
65
66
  const enterpriseId = affiliateAccount?.id;
67
+ const { formatNumber } = useReportUtils();
66
68
  const { handleGradeQuestion, gradeQuestionData } = useApi();
67
69
 
68
70
  const question = constants.questions.find(
@@ -124,11 +126,11 @@ const ReportQuestions = ({
124
126
  {gradeQuestionData?.loading && <FullPageLoader fixed hasBackground />}
125
127
  {toggleGrade && (
126
128
  <GradingModal
127
- aiValue={data?.ai_score}
128
- suggestionValue={data?.suggested_score}
129
+ aiValue={formatNumber(data?.ai_score)}
130
+ suggestionValue={formatNumber(data?.suggested_score)}
129
131
  noAi={noAi}
130
132
  setScore={handleScore}
131
- defaultScore={intructorScore}
133
+ defaultScore={formatNumber(intructorScore)}
132
134
  showAIScore={showAIScore}
133
135
  onClose={() => {
134
136
  setToggleGrade(false);
@@ -147,7 +149,7 @@ const ReportQuestions = ({
147
149
  <ScoreHeader>
148
150
  {accountType === "personal" ? (
149
151
  <ScoreBadge>
150
- Instructor’s score: <span>{parseInt(intructorScore || 0)}%</span>
152
+ Instructor’s score: <span>{formatNumber(intructorScore)}%</span>
151
153
  </ScoreBadge>
152
154
  ) : (
153
155
  <>
@@ -158,7 +160,7 @@ const ReportQuestions = ({
158
160
  hidden: !noAi,
159
161
  })}
160
162
  >
161
- Score: <span>{parseInt(data?.suggested_score || 0)}%</span>
163
+ Score: <span>{formatNumber(data?.suggested_score)}%</span>
162
164
  </ScoreBadge>
163
165
  ) : (
164
166
  showAIScore && (
@@ -168,7 +170,7 @@ const ReportQuestions = ({
168
170
  hidden: noAi,
169
171
  })}
170
172
  >
171
- AI score: <span>{parseInt(data?.ai_score || 0)}%</span>
173
+ AI score: <span>{formatNumber(data?.ai_score)}%</span>
172
174
  </ScoreBadge>
173
175
  )
174
176
  )}
@@ -181,7 +183,7 @@ const ReportQuestions = ({
181
183
  }
182
184
  >
183
185
  Instructor’s score:{" "}
184
- <span>{parseInt(intructorScore || 0)}%</span>
186
+ <span>{formatNumber(intructorScore)}%</span>
185
187
  </ScoreBadge>
186
188
  {(accountType === "instructor-personal" ||
187
189
  accountType === "instructor-affiliate") && (
@@ -14,16 +14,14 @@ import ButtonComponent from "../../../button";
14
14
  const MatchPair = ({ data }) => {
15
15
  const [pairPreview, setPairPreview] = useState(null);
16
16
  const getMatchAndCorrectPair = () => {
17
- if (data?.question_data?.question_data) {
18
- const questionList = Object.entries(
19
- data?.question_data?.question_data || {}
20
- );
21
- const answerList = Object.values(data?.answer?.data?.responses || {});
22
-
17
+ const responses = data?.question_data?.question_data;
18
+ if (responses) {
19
+ const questionList = Object.entries(responses || {});
20
+ const answerResponses = data?.answer?.data?.responses;
23
21
  const formattedList = questionList?.map((item, index) => {
24
22
  const match = item?.[0];
25
23
  const correct = item?.[1];
26
- const responseValue = answerList?.[index]?.value;
24
+ const responseValue = answerResponses?.[match]?.value;
27
25
  return {
28
26
  question: match,
29
27
  answer: responseValue,
@@ -38,6 +36,7 @@ const MatchPair = ({ data }) => {
38
36
  };
39
37
 
40
38
  const matchPairList = getMatchAndCorrectPair();
39
+
41
40
  return (
42
41
  <>
43
42
  {pairPreview && (